Sign up to join our community!
Please sign in to your account!
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
SAP EWM Activity Area Not Determined During Warehouse Task Creation – Step-by-Step Troubleshooting Guide
The error “Activity Area Not Determined” during Warehouse Task (WT) creation in SAP EWM usually occurs when the system cannot link the storage bin, storage type, and activity configuration properly for the picking process. Even if delivery, stock, and Warehouse Process Type (WPT) appear correct, WTRead more
How to Control Warehouse Task Creation Based on Product Shelf Life (SLED) in SAP EWM?
Controlling Warehouse Task Creation Based on Product Shelf Life (SLED) in SAP EWM In pharmaceutical and regulated industries, controlling remaining shelf life during WT creation is critical for compliance. While FEFO and sort rules help, they are not sufficient to fully enforce minimum SLED validatiRead more
Controlling Warehouse Task Creation Based on Product Shelf Life (SLED) in SAP EWM
In pharmaceutical and regulated industries, controlling remaining shelf life during WT creation is critical for compliance. While FEFO and sort rules help, they are not sufficient to fully enforce minimum SLED validation.
A robust design requires a combination of:
Standard configuration
Batch determination strategy
Stock removal control
Enhancement (if strict blocking is required)
Below is the recommended real-project approach.
🔹 1️⃣ Understand Standard System Behavior First
Standard SAP EWM supports:
✔ FEFO (First Expired First Out)
✔ Batch determination
✔ Shelf life relevance in product master
✔ Sort rules based on SLED
However:
❌ Standard FEFO does not block WT creation if minimum remaining shelf life is not met.
❌ It only sorts stock — it does not enforce business rule validation.
That is why configuration alone is often insufficient.
🔹 2️⃣ Outbound Picking – Best Practice Design
✔ Step 1: Maintain SLED & Minimum Remaining Shelf Life
In product master:
Maintain shelf life expiration data
Maintain minimum remaining shelf life
Ensure batch classification is correct.
✔ Step 2: Use FEFO + Sort Rule (First Level Control)
Configure:
Stock removal strategy = FEFO
Sort rule based on expiration date
Batch determination active
This ensures:
👉 System proposes oldest valid stock first.
But this alone does not enforce 90-day rule strictly.
✔ Step 3: Enforce Hard Stop Using BAdI (Recommended for Pharma)
If business requires:
Then enhancement is required.
Commonly Used BAdI in Real Projects:
/SCWM/EX_CORE_STOCK_REMOVAL
or
/SCWM/EX_WHO_CREATE
These BAdIs allow you to:
Validate remaining shelf life dynamically
Compare SLED against current date
Throw error message
Prevent WT creation
This is the most reliable approach in regulated environments.
🔹 3️⃣ Inbound Putaway – Directing Short SLED to Fast-Pick Areas
For inbound control:
✔ Option 1: Storage Type Search Sequence
Define:
Storage type determination based on:
Shelf life remaining
Stock type
Putaway control indicator
But this requires enhancement if dynamic logic is complex.
✔ Option 2 (More Flexible): BAdI for Storage Type Determination
Common BAdI used:
/SCWM/EX_CORE_PTS_DET
This allows:
Reading SLED at GR
Determining remaining days
Assigning storage type dynamically
Short SLED → Fast picking area
Long SLED → Bulk storage
This is widely used in pharma implementations.
🔹 4️⃣ Recommended Overall Architecture
For strict pharma compliance:
✔ Configuration Layer
FEFO strategy
Sort rule
Batch determination
Minimum remaining shelf life in material master
✔ Validation Layer (Enhancement)
BAdI to enforce minimum remaining SLED
Hard error if criteria not met
✔ Putaway Optimization Layer
Dynamic storage type determination via BAdI
This ensures:
Compliance
Audit readiness
Controlled WT creation
🔹 5️⃣ Common Design Mistakes
❌ Relying only on FEFO
❌ Not validating remaining days dynamically
❌ Ignoring time zone/date calculation
❌ Allowing manual override without audit log
❌ Not testing edge cases (partial batch, mixed HU)
🔹 6️⃣ Real Project Recommendation
In pharmaceutical projects:
✔ Always implement enhancement for SLED validation
✔ Log validation messages for audit
✔ Prevent manual bypass
✔ Test year-end date transitions
✔ Document SLED logic in functional specification
Because in regulated industries:
🔑 Final Answer to Your Question
✔ Is configuration alone enough?
No — configuration handles sorting but not strict blocking.
✔ Is BAdI required?
Yes, if business requires minimum remaining shelf life enforcement.
✔ Which BAdIs are commonly used?
/SCWM/EX_CORE_STOCK_REMOVAL/SCWM/EX_WHO_CREATE/SCWM/EX_CORE_PTS_DET(for putaway logic)See less
How to Design an Effective Slotting and Rearrangement Strategy in SAP EWM for High-Pick Warehouses
Designing an Effective Slotting & Rearrangement Strategy in SAP EWM for High-Pick Warehouses Slotting & Rearrangement in SAP EWM is extremely powerful — but in high-volume warehouses, it can easily fail if treated as a purely system-driven exercise. The key principle from real projects is: SRead more
Designing an Effective Slotting & Rearrangement Strategy in SAP EWM for High-Pick Warehouses
Slotting & Rearrangement in SAP EWM is extremely powerful — but in high-volume warehouses, it can easily fail if treated as a purely system-driven exercise.
The key principle from real projects is:
Below is a practical, field-tested approach used in productive implementations.
🔹 1️⃣ Start With Business Segmentation (Not System Criteria)
Before defining slotting rules, segment products into:
Fast movers
Medium movers
Slow movers
Seasonal movers
Promotion-driven SKUs
Use:
Historical picking data
Lines per day
Order frequency
Quantity per order
👉 Do not rely only on material master attributes.
Use real warehouse movement data.
🔹 2️⃣ Defining Meaningful Slotting Criteria
Best practice is to combine physical + demand-based attributes.
✔ Recommended Slotting Criteria Mix
Demand-Based
Pick frequency (lines per day)
Quantity picked per period
ABC classification (based on movement)
Velocity index
Physical-Based
Weight
Volume (cube)
Handling constraints
Hazardous classification
HU type
🔴 Common Mistake
Using only:
Weight
Volume
Static ABC class
Without dynamic demand.
👉 Slotting must be demand-driven in high-pick warehouses.
🔹 3️⃣ Handling Seasonal Fluctuations
For seasonal businesses:
✔ Run slotting simulation quarterly
✔ Maintain season-based classification
✔ Avoid monthly full rearrangement (too disruptive)
Best practice:
Major rearrangement → Quarterly
Minor adjustments → Monthly
High-impact SKUs → As needed
🔹 4️⃣ Rearrangement Strategy – Be Realistic
❌ What Fails in Real Projects
Daily rearrangement proposals
Moving thousands of bins at once
System-generated moves without operational validation
Result:
Warehouse team rejects process
Rearrangement tasks ignored
✅ What Works
✔ Limit rearrangement to top 10–20% movers
✔ Set movement threshold (only move if benefit is significant)
✔ Restrict to specific storage types
✔ Schedule rearrangement during low activity windows
👉 Slotting should optimize 20% SKUs that drive 80% picking.
🔹 5️⃣ Balancing Optimization vs Operational Feasibility
System-optimized bin ≠ Operationally practical bin.
Consider:
Picker route logic
Ergonomic access
Aisle congestion
Replenishment impact
Best practice:
Validate proposals with warehouse supervisor
Run simulation before execution
Implement zone-based picking logic
Slotting must align with physical warehouse layout.
🔹 6️⃣ Performance Considerations in Large Warehouses
When running slotting jobs on 100,000+ bins:
✔ Run in background job
✔ Split by storage type
✔ Limit product selection range
✔ Avoid full-warehouse simulation during peak hours
✔ Monitor system load
Never run large slotting jobs during peak outbound windows.
🔹 7️⃣ Governance & Change Management (Critical for Success)
Slotting often fails due to business resistance.
Best practice:
✔ Create clear approval workflow
✔ Document movement justification
✔ Measure KPI impact (travel time, pick rate)
✔ Show improvement data to business
When business sees reduced picker travel time → acceptance increases.
🔹 8️⃣ Real Project Lessons Learned
✔ What Worked
Quarterly slotting review
Dynamic ABC classification
Limited rearrangement scope
Supervisor validation
KPI tracking
❌ What Failed
Over-automation
Daily rearrangement
Ignoring operational constraints
Moving low-impact SKUs
No performance analysis
🔑 Final Recommendation
For high-pick warehouses:
Make slotting demand-driven
Focus on top-moving SKUs
Limit rearrangement frequency
Validate system proposals operationally
Use slotting as strategic optimization — not daily maintenance
The most successful projects treat slotting as:
See less
Warehouse Task Not Created After Outbound Delivery Replication in SAP EWM – How to Troubleshoot?
When an outbound delivery is successfully replicated to SAP EWM but Warehouse Tasks (WTs) are not created, the issue is usually related to status management, configuration gaps, or background action failures — even if everything appears correct at first glance. Below is a real-project, systematic trRead more
When an outbound delivery is successfully replicated to SAP EWM but Warehouse Tasks (WTs) are not created, the issue is usually related to status management, configuration gaps, or background action failures — even if everything appears correct at first glance.
Below is a real-project, systematic troubleshooting approach.
🔍 1. Check Delivery Status (Most Commonly Missed)
Go to /SCWM/MON → Outbound Delivery Order (ODO) and verify:
Important Status Fields:
Warehouse Process Status
Picking Status
Overall Status
Goods Issue Relevance
WT Creation Relevance
👉 If delivery is not “Released for Picking”, WT will not be created.
Very often, the delivery exists but is not fully warehouse-relevant.
🔍 2. Check Whether Automatic WT Creation Is Triggered
WT creation may depend on:
Manual creation
Automatic creation via PPF
Wave management
Background job
✔ If PPF is used:
Check:
PPF action profile assigned
Action determination successful
Action status processed without error
Missing or inactive PPF action = No automatic WT.
🔍 3. Verify Warehouse Process Type (WPT) Deeply
Even if WPT is “maintained”, check:
Picking control indicator
Stock removal rule
Confirmation control
Activity area assignment
👉 Incorrect picking control can silently prevent WT creation.
This is one of the top root causes.
🔍 4. Validate Storage Type Search & Stock Availability
Even with correct search sequence:
Is stock actually available in correct stock type?
Is stock blocked or in quality?
Is batch determination failing?
Is stock in different availability group?
Check:
/SCWM/MON → Stock Overview
Product warehouse view
👉 If no valid source bin is found, WT will not be created.
🔍 5. Check Wave Management (If Active)
If wave management is used:
Delivery may require wave release
WT is created only after wave release
Check wave status
Many projects forget this dependency.
🔍 6. Queue & WOCR Validation
Even if queue exists:
Is correct queue determined?
Is resource assigned to that queue?
Is WOCR restricting WT grouping?
Incorrect queue determination can prevent processing.
🔍 7. Check Application Logs (Very Important)
Go to SLG1 and check for:
Object: /SCWM/DELIVERY
Object: /SCWM/WAVE
Object: /SCWM/WHSE_TASK
Often errors appear in logs but not on delivery UI.
🔍 8. Check qRFC Queues
Even if no visible errors:
Check SMQ1 / SMQ2
Look for stuck or temporary blocked entries
Reprocess failed messages if needed
Queue issues can delay WT creation.
🔍 9. Confirm Delivery Is Not Blocked
Check:
Credit block
Incompletion log
Delivery block indicators
GI relevance
Blocked deliveries will not trigger picking.
🔍 10. Product & Warehouse Data Validation
Check in /SCWM/MAT1:
Warehouse product maintained
Activity area assigned
Storage type indicators correct
No inconsistent stock removal rule
Missing activity area assignment is a common hidden cause.
✅ Most Common Real Project Root Causes
From real implementations, WT not created is usually due to:
Delivery not fully released for picking
Missing or failed PPF action
Incorrect picking control in WPT
No valid source stock found
Wave not released
Activity area not assigned
Queue mismatch
Application log errors
✅ Recommended Troubleshooting Order (Production Safe)
Follow this sequence:
1️⃣ Check delivery status
2️⃣ Check PPF action
3️⃣ Check stock availability
4️⃣ Validate WPT
5️⃣ Review wave status
6️⃣ Check application logs
7️⃣ Check queues
This minimizes business impact and avoids unnecessary configuration changes.
🔑 Final Project Insight
In 80% of cases, the issue is not a system error, but:
Status not properly triggered
Automatic action not configured
Warehouse process control misaligned
Always validate process flow sequence, not just configuration.
See less
Common Design Mistakes in SAP TM–EWM Integration and How to Avoid Them in Real Projects
SAP TM–EWM integration is powerful but often fails due to unclear process ownership and poor orchestration design. In real projects, most issues are not technical — they are design and governance mistakes. Below are the most common mistakes observed in productive implementations and how to avoid theRead more
How to Design an Efficient Physical Inventory Strategy in SAP EWM for Audit Compliance and Minimal Operational Disruption
Designing an Efficient & Audit-Compliant Physical Inventory Strategy in SAP EWM Designing a Physical Inventory (PI) process in SAP EWM for large, 24/7 warehouses requires balancing audit compliance, system performance, and operational continuity. A well-designed PI strategy should minimize businRead more
Designing an Efficient & Audit-Compliant Physical Inventory Strategy in SAP EWM
Designing a Physical Inventory (PI) process in SAP EWM for large, 24/7 warehouses requires balancing audit compliance, system performance, and operational continuity. A well-designed PI strategy should minimize business disruption while ensuring full traceability of inventory adjustments.
Below are best-practice design principles used in real SAP EWM projects.
🔹 1. Full PI vs Continuous PI (Cycle Counting) – Recommended Approach
✔ Avoid Pure Annual Full PI
Annual full PI in large warehouses causes:
Operational downtime
Performance issues
Increased error rates
Use full PI only for audit reconciliation or exception handling
✔ Prefer Continuous PI (Cycle Counting)
Recommended approach:
Use cycle counting as the primary PI method
Schedule small, frequent PI documents
Count bins/products based on risk and movement frequency
👉 This approach satisfies auditors while keeping operations running.
🔹 2. Designing PI Areas & Counting Intervals
✔ Define PI Areas Strategically
Create PI areas based on:
Storage type (high rack, picking, bulk, VAS)
Operational criticality
Access restrictions
Example:
High-rack storage → Quarterly PI
Picking areas → Monthly PI
Fast-moving SKUs → More frequent counts
✔ Use ABC Classification
A-class products → Frequent PI
B-class products → Medium frequency
C-class products → Annual or semi-annual PI
👉 This reduces workload and improves accuracy where it matters most.
🔹 3. Controlling & Documenting Inventory Differences (Audit Focus)
✔ Enforce Difference Reason Codes
Mandatory reason codes for all PI differences
Separate codes for:
Damage
Theft
Process error
System issue
👉 Auditors expect clear business justification for every difference.
✔ Block Automatic Posting of Differences
Best practice:
Do not allow direct difference posting
Route differences through:
Supervisor review
Approval workflow
This ensures:
Accountability
Reduced incorrect postings
🔹 4. Authorization & Approval Design for Audit Compliance
✔ Segregation of Duties (SoD)
Design roles such that:
Counter ≠ Approver ≠ Poster
No single user can:
Count
Approve
Post differences
👉 This is a key audit requirement.
✔ Use Change Logs & Application Logs
Activate change documents
Use application logs for:
PI creation
Difference posting
Recount triggers
This provides:
Full traceability
“Who changed what and when”
🔹 5. Performance Best Practices for Large PI Volumes
✔ Avoid Large PI Documents
Do not create PI documents for thousands of bins at once
Split PI documents by:
Storage type
Area
Product group
✔ Schedule PI Jobs During Low Activity
Create and process PI documents during:
Night shifts
Low-volume windows
Avoid peak outbound periods
✔ Monitor System Load
Track PI-related queues and logs
Monitor background job runtime
👉 This prevents performance degradation in productive systems.
🔹 6. Recommended End-to-End PI Design (Summary)
✔ Continuous PI as primary strategy
✔ Risk-based counting (ABC analysis)
✔ Mandatory difference reasons
✔ Supervisor approval before posting
✔ Strict role segregation
✔ Small, controlled PI documents
✔ Regular audit reporting
See less
Stock Mismatch Between SAP EWM and ERP – How to Identify and Resolve the Root Cause?
Stock mismatch between SAP EWM and ERP is a very common production issue and usually indicates that a posting or synchronization step was interrupted or bypassed. Even when no open tasks or queues are visible, inconsistencies can still exist at a deeper level. Below is a practical, real-project trouRead more
Stock mismatch between SAP EWM and ERP is a very common production issue and usually indicates that a posting or synchronization step was interrupted or bypassed. Even when no open tasks or queues are visible, inconsistencies can still exist at a deeper level.
Below is a practical, real-project troubleshooting guide.
1. Understand Where the Mismatch Exists First
Before correcting anything, identify where the inconsistency originates.
Check:
– /SCWM/MON for EWM stock
– MMBE / MB52 for ERP stock
– Compare storage location, batch, and stock type
This helps decide whether EWM or ERP is the leading system for correction.
2. Check for Incomplete or Failed Posting Changes
Posting changes are a top reason for mismatches.
– Check open or canceled posting changes in /SCWM/MON
– Verify whether posting changes were confirmed in EWM but not posted to ERP
3. Verify Physical Inventory Posting in Both Systems
Even if PI documents are closed:
– Verify PI posting in EWM
– Check ERP material documents related to PI
4. Check qRFC Queues Carefully
Recheck SMQ1 / SMQ2 for:
– Stock synchronization queues
– Old or previously failed messages
5. Analyze Application Logs
Check SLG1 with objects:
– /SCWM/ERP
– /SCWM/PI
– /SCWM/POST
6. Check for Manual ERP Movements
Ensure no goods movements were posted directly in ERP using MIGO.
7. Validate Stock Type and Availability Group Mapping
Ensure EWM stock types are correctly mapped to ERP stock types.
Safest Way to Correct Stock Differences:
– If EWM stock is correct, adjust ERP stock
– If ERP stock is correct, adjust EWM stock using posting change or correction tools
Never delete stock directly from database tables.
In most real projects, stock mismatch is caused by incomplete posting changes, PI issues, manual ERP postings, or mapping errors.
See lessSAP EWM Warehouse Task Not Created After Inbound Delivery – Common Causes and Solutions
SAP EWM Warehouse Task Not Created After Inbound Delivery When an inbound delivery is successfully distributed to SAP EWM but Warehouse Tasks (WTs) are not created, the issue is usually related to process configuration gaps or missing master data, even if everything appears correct at first glance.BRead more
SAP EWM Warehouse Task Not Created After Inbound Delivery
When an inbound delivery is successfully distributed to SAP EWM but Warehouse Tasks (WTs) are not created, the issue is usually related to process configuration gaps or missing master data, even if everything appears correct at first glance.
Below is a systematic checklist based on real project experience.
🔍 1. Check Inbound Delivery Item Status
Go to /SCWM/MON
Navigate to the inbound delivery item
Verify the status:
“Putaway Relevance” must be active
Delivery item must be released for warehouse processing
👉 If the delivery is not released, WT creation will not trigger.
🔍 2. Verify Warehouse Process Type (WPT)
Check whether the correct Warehouse Process Type is determined:
Go to SPRO → EWM → Goods Receipt → Warehouse Task → Define Warehouse Process Type
Ensure:
Putaway relevance is active
Correct stock removal/placement control is set
Confirmation control is not blocking WT creation
👉 Wrong or incomplete WPT is one of the most common causes.
🔍 3. Check Putaway Strategy & Storage Type Search
Verify Putaway Strategy in:
Product master (warehouse view)
Storage type search sequence
Ensure:
At least one storage type is found
Storage type allows putaway
No capacity or bin restriction blocks WT creation
👉 If no valid storage type/bin is found, WT will not be created.
🔍 4. Check Product Master Data
In /SCWM/MAT1, confirm:
Putaway control indicator is maintained
Storage section / storage type indicators are correct
Handling Unit requirement matches the process
Batch/SLED settings (if applicable) are consistent
👉 Missing or incorrect product master data often blocks task creation silently.
🔍 5. Check Warehouse Task Creation Settings
Verify whether WT creation is:
Manual
Automatic
Triggered by PPF
If PPF is used:
Check PPF action status
Ensure action is processed successfully
👉 If WT creation is set to manual, system will not create tasks automatically.
🔍 6. Check Queue & Warehouse Order Settings
Ensure a valid queue is determined
Check:
Queue assignment
Warehouse Order Creation Rules (WOCR)
Incorrect queue determination may prevent WT processing.
🔍 7. Check Application Logs & Queues
Always check:
SLG1 – Application logs for hidden errors
SMQ1 / SMQ2 – qRFC queues for stuck messages
👉 Many WT creation issues are visible only in logs, not on the UI.
✅ Final Recommendation (Real Project Insight)
In most productive systems, WT not created after inbound delivery is caused by:
-
-
-
-
-
See lessIncorrect or incomplete Warehouse Process Type
Missing putaway strategy or storage type
Product master data gaps
Delivery not released for warehouse processing
PPF or queue-related issues
RF Picking Confirmation Not Updating Stock in SAP EWM – What Are the Possible Causes and Solutions?
This issue is commonly caused by RF framework configuration gaps or process inconsistencies. Below is a systematic troubleshooting approach based on real project experience. 🔍 1. Check Warehouse Task Confirmation Status Go to /SCWM/MON Verify whether the WT is: Fully confirmed Partially confirmed ReRead more
This issue is commonly caused by RF framework configuration gaps or process inconsistencies. Below is a systematic troubleshooting approach based on real project experience.
🔍 1. Check Warehouse Task Confirmation Status
Go to /SCWM/MON
Verify whether the WT is:
Fully confirmed
Partially confirmed
Reversed automatically
Ensure no follow-up WT is generated and left open
👉 Stock will not update if WT confirmation is incomplete.
🔍 2. Verify RF Logical Transaction & Screen Sequence
Go to /SCWM/RFUI
Check:
Logical transaction assigned correctly
Screen sequence includes confirmation screen
No screen is skipped due to incorrect control parameters
👉 Missing confirmation screen can cause logical completion but no physical stock update.
🔍 3. Validate Warehouse Process Type (WPT)
Ensure correct WPT is determined for RF picking
Check:
Stock removal strategy
Confirmation control
HU requirement settings
👉 Wrong WPT may confirm WT without posting stock movement.
🔍 4. Check Queue & Warehouse Order Creation Rules (WOCR)
Incorrect queue or WOCR may:
Delay posting
Assign WT to wrong resource
Reprocess and confirm again
🔍 5. Inspect Posting Change & Stock Type Settings
Verify whether:
Posting change is required
Stock type (Available / Quality / Blocked) is changing
Incorrect stock type mapping can appear as “no update”
🔍 6. Check RF User & Resource Assignment
Ensure:
RF user is correctly mapped to resource
Resource is active and logged on
Incorrect resource assignment may cause background rollback
🔍 7. Application Logs & Queue Monitoring
Check:
SLG1 (Application Log)
SMQ1 / SMQ2 queues
Look for delayed or stuck updates
✅ Final Recommendation
In most projects, this issue is caused by:
Incorrect RF screen sequence
Missing confirmation control in WPT
Resource not properly assigned
Once RF flow and WPT are aligned, stock updates correctly in real time.
See less
How to delete Outbound Delivery in EWM using ABAP
DATA: lo_spfd TYPE REF TO /scdl/cl_sp_fd_out. DATA: lt_key TYPE /scdl/t_sp_k_head. DATA: lt_key_itm TYPE /scdl/t_sp_k_item. DATA: lv_aspect TYPE /scmb/sp_aspect VALUE '/SCDL/S_SP_A_HEAD'. DATA: lv_aspect_itm TYPE /scmb/sp_aspect VALUE '/SCDL/S_SP_A_ITEM'. DATA: lv_rejected TYPE abap_bool. DATA: lt_rRead more
DATA: lo_spfd TYPE REF TO /scdl/cl_sp_fd_out.
DATA: lt_key TYPE /scdl/t_sp_k_head.
DATA: lt_key_itm TYPE /scdl/t_sp_k_item.
DATA: lv_aspect TYPE /scmb/sp_aspect VALUE ‘/SCDL/S_SP_A_HEAD’.
DATA: lv_aspect_itm TYPE /scmb/sp_aspect VALUE ‘/SCDL/S_SP_A_ITEM’.
DATA: lv_rejected TYPE abap_bool.
DATA: lt_ret TYPE /scdl/t_sp_return_code.
DATA: lt_return TYPE bapiret2_t.
DATA: lv_msg TYPE msgtx.
DATA: lt_outrec TYPE /scdl/t_sp_a_head.
DATA: lt_outrec_itm TYPE /scdl/t_sp_a_item.
DATA: lt_docid TYPE /scwm/dlv_docid_item_tab.
DATA: lt_key_docid TYPE /scdl/t_sp_k_head.
DATA: lo_sp TYPE REF TO /scdl/cl_sp_prd_out.
DATA: lo_dlv TYPE REF TO /scwm/cl_dlv_management_prd.
DATA: lt_sp_k_head TYPE /scdl/t_sp_k_head.
DATA: lt_sp_k_item TYPE /scdl/t_sp_k_item.
DATA: lt_a_head_eew TYPE /scdl/t_sp_a_head_eew_prd.
*–Append messaage for queue start
MESSAGE s171 INTO lv_msg.
PERFORM add_message TABLES lt_return
USING lv_msg.
CREATE OBJECT lo_spfd.
*–Get OD
SELECT docid,
itemid
FROM /scdl/db_dlvi_o
INTO TABLE @lt_key_itm
FOR ALL ENTRIES IN @it_docid
WHERE refdocid = @it_docid-docid.
IF sy-subrc = 0.
lt_key = CORRESPONDING #( lt_key_itm MAPPING
docid = docid ).
*–Fetch corresponding FDO Details
SELECT docid,
itemid,
doccat
INTO TABLE @lt_docid
FROM /scdl/db_dlvi_o
FOR ALL ENTRIES IN @it_docid
WHERE refdocid = @it_docid-docid.
IF lt_docid[] IS NOT INITIAL.
lt_key_docid = CORRESPONDING #( lt_docid MAPPING
docid = docid ).
ENDIF.
DO 5 TIMES.
SELECT *
INTO TABLE @DATA(lt_msl)
FROM /scwm/messagelog
FOR ALL ENTRIES IN @lt_key
WHERE docid EQ @lt_key-docid
AND doccat = ‘FDO’.
IF sy-subrc EQ 0 AND lt_msl IS NOT INITIAL.
READ TABLE lt_msl INTO DATA(ls_msl)
WITH KEY message = /scwm/if_mapping_constants=>sc_m_obdlv_change_revgi.
IF sy-subrc NE 0.
WAIT UP TO 2 SECONDS.
CONTINUE.
ELSE.
LOOP AT lt_msl ASSIGNING FIELD-SYMBOL().
IF -message = /scwm/if_mapping_constants=>sc_m_obdlv_change_revgi.
-status = ‘X’.
ELSEIF -message = /scwm/if_mapping_constants=>sc_m_obdlv_confirm_dec.
-status = ‘X’.
ENDIF.
ENDLOOP.
MODIFY /scwm/messagelog FROM TABLE lt_msl.
COMMIT WORK AND WAIT.
MESSAGE s167 INTO lv_msg.
PERFORM add_message TABLES lt_return
USING lv_msg.
ENDIF.
ENDIF.
ENDDO.
*–Check for errors
IF VALUE #( lt_return[ type = ‘E’ ]-type OPTIONAL ) NE ‘E’.
*–create service provider
DATA(lo_message_box) = NEW /scdl/cl_sp_message_box( ).
*–Create object to instantiate
CREATE OBJECT lo_sp
EXPORTING
io_message_box = lo_message_box
iv_doccat = /scdl/if_dl_doc_c=>sc_doccat_out_fd “sc_doccat_out_prd
iv_mode = /scdl/cl_sp=>sc_mode_classic.
*–Get real warehouse
/scwm/cl_tm=>set_lgnum( iv_lgnum ).
*–Lock dlv
lo_sp->lock(
EXPORTING
inkeys = lt_key
aspect = /scdl/if_sp_c=>sc_asp_head
lockmode = /scdl/if_sp1_locking=>sc_exclusive_lock
IMPORTING
rejected = lv_rejected
return_codes = DATA(lt_return_codes) ).
*–read item details into buffer
lo_sp->select(
EXPORTING
inkeys = lt_key_itm
aspect = /scdl/if_sp_c=>sc_asp_item
IMPORTING
outrecords = lt_outrec_itm
rejected = lv_rejected
return_codes = lt_ret ).
*–read header details into buffer
lo_sp->select(
EXPORTING
inkeys = lt_key
aspect = /scdl/if_sp_c=>sc_asp_head
IMPORTING
outrecords = lt_outrec
rejected = lv_rejected
return_codes = lt_ret ).
*–Delete the FDO
lo_sp->delete(
EXPORTING
inkeys = lt_key
aspect = /scdl/if_sp_c=>sc_asp_head
IMPORTING
rejected = lv_rejected
return_codes = lt_ret
).
*–Check if any error occurred
IF line_exists( lt_return_codes[ failed = abap_true ] ) OR lv_rejected EQ abap_true.
*–Error to fail queue
ELSE.
lo_sp->save(
IMPORTING
rejected = lv_rejected ).
*–Commit / rollback based on errors
IF lv_rejected IS INITIAL.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = abap_true.
CALL METHOD lo_sp->(‘CLEANUP’)
EXPORTING
reason = /scmb/if_sp_transaction=>sc_cleanup_commit.
*–Clear buffers and release locks
/scwm/cl_tm=>cleanup( ).
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
*–Clear buffers and release locks
/scwm/cl_tm=>cleanup( ).
ENDIF.
ENDIF.
See less