Skip to Content
Technical Articles
Author's profile photo Shreyash Agrawal

Create an Outbound Delivery in EWM


Recently I had been working on a requirement of creating an Outbound Delivery in EWM. I searched online and found one beautiful link which gave a start to a journey to achieve this requirement. Journey because I spent 5 days on this and after hours and hours of debugging I was able to bring all pieces together and solve this puzzle. Since I don’t want anyone to spend 5 days to get this, I am writing a detailed step by step process.


Step 1.

Most important class for achieving this requirement is /SCWM/CL_SP_PRD_OUT. Create a subclass of this class. Complete this step by creating a constructor method to set some default values as below.

io_attribute_handler mo_attribute_handler
io_message_handler   mo_message_handler
iv_mode              iv_mode

me->ms_defaultlgnum ‘1710’.
me->ms_defaultshipping_office ‘WH1710’.
me->ms_defaultentitled ‘BP1710’.
me->mv_tzone ‘PST’.


Step 2.

Create an executable program where you will instantiate the newly created class and call its methods. The sequence of call is given in the below steps.


Step 3.

Instantiate the class and again set some defaults

CREATE OBJECT lo_message_box.
iv_mode /scdl/cl_sp=>sc_mode_classic.

*set warehouse that is used
/scwm/cl_tm=>set_lgnum‘<Your Warehouse No.>’ ).


Step 4.

Call Insert method. This method creates a DOCID of the OBD. Read more about aspects, key aspects to understand the process better

CALL METHOD lo_sp->/scmb/if_sp_aspect~insert
inrecords    lt_a_head “lt_head_inrecords “
aspect       ‘/SCWM/S_SP_A_HEAD’
outrecords   lt_a_head_out “lt_head_outrecords “
rejected     lv_rejected
return_codes lt_return_codes.


Step 5.

Call Select method. This is required to get party details. In our case, the party-role we obtain is STPRT which is Ship-to-Party

<lfs_sp_k_head>docid lt_a_head_out[ ]docid.

APPEND INITIAL LINE TO lt_head_party_inkeys ASSIGNING FIELDSYMBOL(<lfs_head_party_inkeys>).
<lfs_head_party_inkeys>docid lt_a_head_out[ ]docid.
<lfs_head_party_inkeys>party_role ‘STPRT’.

inkeys       lt_head_party_inkeys                 ” Restricting Input Keys
aspect       /scwm/if_sp_c=>sc_asp_head_party    ” Aspect Name to Be Read from “/scdl/if_sp_c=>sc_asp_head_partyloc : Gives dump
outrecords   lt_head_party_out                 ” Result Aspects
rejected     lv_rejected                 ” Error on Back End
return_codes lt_return_codes                 ” Table of Return Codes


Step 6.

As we get one records from above step, now we just have to update the party detail with the party number. Note that we haven’t passed counter in the above step, but in this step inorder to update the record, we are passing the counter as one which we received in the out table of previous step. Read more about value indicator. This is a very important step, but if we miss to pass this value indicator you would never be able to achieve this requirement.

LOOP AT lt_head_party_out ASSIGNING FIELDSYMBOL(<lfs_head_party_out>).
APPEND INITIAL LINE TO lt_head_party_inrecords ASSIGNING FIELDSYMBOL(<lfs_head_party_inrecords>).
MOVE-CORRESPONDING <lfs_head_party_out> TO <lfs_head_party_inrecords>.
<lfs_head_party_inrecords>partyno ‘001000010’.
<lfs_head_party_inrecords>value_ind ‘M’.     “Figured out after tons and tons of debugging

CLEAR lt_head_party_out,lv_rejected,lt_return_codes.

CALL METHOD lo_sp->/scmb/if_sp_aspect~update
aspect       /scwm/if_sp_c=>sc_asp_head_party                 ” Aspect that should make change
inrecords    lt_head_party_inrecords                 ” Full Record Update
outrecords   lt_head_party_out
rejected     lv_rejected
return_codes lt_return_codes.


Step 7.

Once you get success in above step, next step is to assign HU to the delivery. For this we use Insert method.

ls_sp_k_headdocid lt_a_head_out[ ]docid.

ls_sp_hudocid lt_a_head_out[ ]docid.
ls_sp_huhuno ‘00112345678000004023’.
ls_sp_hulgnum ‘1710’.
ls_sp_huitemtype ‘ODPG’.
ls_sp_hudoccat ‘PDO’.
ls_sp_hudoctype ‘OPIG’.
APPEND ls_sp_hu TO lt_sp_hu.

CALL METHOD lo_sp->/scmb/if_sp_aspect~insert
inrecords      lt_sp_hu
aspect         ‘/SCWM/S_SP_A_HU’
relation       ‘/SCWM/HEAD_TO_HU’
relation_inkey ls_sp_k_head
outrecords     lt_sp_hu_out
rejected       lv_rejected
return_codes   lt_return_codes.


Step 8.

Once this step also gives you a success, then go ahead to save the transaction. This is the last step and your OBD gets created.

CALL METHOD lo_sp->/scmb/if_sp_transaction~save
rejected lv_rejected.
IF lv_rejected EQ abap_false.
/scwm/cl_tm=>cleanup)“clear buffers and release locks




At step no. 6, you can also call insert after update if you have any more party details to be updated.

I would still say to spend some time debugging so that you would understand the underlying design.

Happy coding!!!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Ashwin Jose
      Ashwin Jose

      This article did save my days and efforts.

      Thanks a lot for taking the trouble to create this blog.

      Keep up the good work.

      Author's profile photo arjun ponnuswamy
      arjun ponnuswamy

      Hi Shreyansh,

      Can you please share your data declarations part for the internal tables used in the methods.

      I am new to EWM and I get dumps for data types i declare. It would be of great help if you can share that.