This blog is result of my 2 days struggle on finding a way to create a SC using only FMs, particularly to create Limit SCs. I saw lot of threads asking and discussing this topic, but no concrete solution. I would like to post the sample code for this.
Assume that you are having a program where you already have the required data to create SCs i.e., item data, accounting data, partner data etc., The you create a FORM like I have shown below. Pass all the required data to the below form. I am not giving here the details of how to fill these tables as the data might vary from case to case.
The important point to note here is to not populate the P_GUID in Accounting, partner, attachment, organisation data, etc tables. Basically where ever there is a need to fill in item guid just leave it as blank. we will fill those details in the below form.
FORM create_limit_sc TABLES pt_item STRUCTURE bbp_pds_sc_item_icu
pt_account STRUCTURE bbp_pds_acc
pt_partner STRUCTURE bbp_pds_partner
pt_longtext STRUCTURE bbp_pds_longtext
pt_limit STRUCTURE bbp_pds_limit
pt_orgdata STRUCTURE bbp_pds_org
pt_item_out STRUCTURE bbp_pds_sc_item_icu
pt_messages_out STRUCTURE bbp_pds_messages
pt_attachment TYPE bbpt_pds_att_t
CHANGING ps_header TYPE bbp_pds_sc_header_ic
ps_header_out type bbp_pds_sc_header_d.
FIELD-SYMBOLS: <fs_item> TYPE bbp_pds_sc_item_icu,