In this blog would like to share the process of E-commerce sales integration with SAP. E-comm site like Amazon / Flipkart / Paytm etc., will provide the data through API or flat file output in Excel / CSV format.
Exact Industry Requirement:
Most of the orders in Third party site will be having a combo product (combo product), if combo product is in order, we have two options
- Creation of Sales BOM and proceeding for PGI and Invoice.
- Creating a combo product through Production order by consuming components and output Materials will be a sale-able Item.
The industry opts for option 2. In this sales order requirement should flow through production order process.
Read More: SAP SD Certification Preparation Guide
Steps involved for this Automation:
Brief process flow as intro
Prerequisites to follow below mentioned steps:
Create a customer as onetime customer since industrial requirement does not have multiple customers for online sales (i.e., web/ e-comm sales). And check box of complete delivery should be enabled.
In order to have a control on Inventory activities, suggested to go ahead with single production order for a period (i.e., one Production Order for month) based on this all required output material will be created as co-product and output will be picked through 101 movement type.
Note: Though creation of production order also can be automated recommended creating production order manually since it’s a onetime activity.
- Orders received from third party website and downloaded to Excel or read through API provided by Service Provider.
- Consider this automated program basically executed through flat file, by reading flat file and this will create a Sales Order.
Since every Third-party site has unique format of output file upload, individual radio buttons been provided of user to select and upload the required Orders.
Validations are in place with Purchase order reference and Purchase order date reference to avoid duplicate Sales order upload.
3. Sales order will be verified and triggered for second stage automation.
Verified Sales orders will be given as input to another program as follows for ease of approach program written with different performs based on activities.
START-OF-SELECTION. *&---------- Reading Sales Order Data ------------------- PERFORM read_so_data. *&---------- Inventory Check for Sales Order Qty -------- PERFORM inventory_check. *&---------- Trans Post creation for L008 - L009 -------- PERFORM trans_post_suggestion. *&---------- Migo of Trans. Posting --------------------- PERFORM trans_post_posting. *&----------- OBD / PGI -------------------------------- PERFORM obd_pgi. *&----------- Invoice Posting -------------------------- PERFORM invoice_post.
And the selection screen for end user shown as follows :
here alternate plant is finding inventory available in alternate plant and proceed with Transfer posting for performing Production/pgi process for the execution plant.
All sales order document flow will be verified and validated before proceeding with OBD and Invoice.
4. A sales order will be picked line item wise and inventory will be verified if inventory available then move to step 9.
SUBMIT rm07mlbs EXPORTING LIST TO MEMORY WITH matnr IN it_mat " Material Number WITH werks EQ p_rplant " Plant WITH bukrs EQ p_bukrs " Company Code WITH kzlso EQ 'X' " Also Select Special Stocks * WITH sobkz EQ 'E' "Special Stock Indicator WITH kznul EQ 'X' " No zero stock lines WITH mb52_noval EQ 'X' "Do not display values WITH mb52_alv_flt EQ 'X' "Generate Non-Hierarchical List AND RETURN.
Wherever inventory check is required in this whole process call standard MB52 through submit and get the result and write required validations.
5. If required inventory is not available, then as already said we have both Regular product (one finished good material) and combi product (having combination of multiple finished goods)
a) For regular product system will suggest for Transfer posting from existing Plant to required plant
CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING goodsmvt_header = wa_gmvt_header_tp goodsmvt_code = *respective movement Code is required * TESTRUN = ' ' * GOODSMVT_REF_EWM = IMPORTING goodsmvt_headret = gmvt_headret_tp * MATERIALDOCUMENT = gmvt_retmtd * MATDOCUMENTYEAR = TABLES goodsmvt_item = gmvt_item_tp * GOODSMVT_SERIALNUMBER = return = rt_bapiret_tp * GOODSMVT_SERV_PART_DATA = * EXTENSIONIN = .
b) For combi product – BOM will be explored and inventory will be verified if available push to next step, not available step 5) 1. will be triggered for the existing BOM components required quantity.
- Explore the BOM for the Combo product and checking the inventory for the components required for the Combo product.
v~meins FROM mast AS z
INNER JOIN stpo AS v ON v~stlnr EQ z~stlnr
INTO CORRESPONDING FIELDS OF TABLE it_mast
FOR ALL ENTRIES IN it_read_so_data
WHERE z~matnr EQ it_read_so_data-matnr
AND z~werks EQ it_read_so_data-werks
AND z~stlan EQ ‘1’.
followed by this IT_MAST will have complete component list and required quantity for a sales order, before proceeding to production order Inventory check initiated and availability check executed.
6. Required BOM quantity available in production plant then production order will be called, and output material will be identified in production order and updated with new required quantity or will be added as a new line item if it’s new material for that production order.
Through BAPI BAPI_PRODORD_GET_DETAIL production order will be read, and Finished goods will be added to prod. ord. as a co-product.
7. Consumption entry of all component of a combi product will be posted with 261 movement type followed by this action GRN of Finished Goods will be proceed with 101 movement type.
Component for the above mentioned Finished Good added into the same prd.ord. followed by GRN consumption entry posted based on selection.
8. Repetition of step 4 for inventory check and proceed as mentioned.
based on availability flag end user can select the Sales order to proceed for OBD.
9. OBD/PGI – BAPI to post the PGI called and committed followed by this Invoice posting and accounting entry posted.
List of all BAPI’s and FM used to achieve above process :
Though most of the FM and BAPI’s are known to most of the SAP consultants like to list for ease of understanding.
ALSM_EXCEL_TO_INTERNAL_TABLE – loading data from excel to internal table.
CS_BOM_EXPL_MAT_V2 – for BOM exploration.
BAPI_SALESORDER_CREATEFROMDAT2 – for Sales order creation with all condition types.
REUSE_ALV_POPUP_TO_SELECT – for all line selection option provided to users
BAPI_PRODORD_GET_DETAIL – for reading the production order data.
HR_JP_MONTH_BEGIN_END_DATE – to validate the production order in posting date’s period.
CO_XT_COMPONENT_ADD – to add components to existing production order if the Finished goods are new to the production in the month. For both co-product or consumption product.
CO_XT_COMPONENT_CHANGE – this is to change the component which already present in the production order. For both co-product or consumption product.
BAPI_DELIVERYPROCESSING_EXEC & WS_DELIVERY_UPDATE – OBD/PGI positing after inventory check.
BAPI_BILLINGDOC_CREATEMULTIPLE – for the creating Invoice based on OBD/PGI
GUI_DOWNLOAD – Output / error file download to specified location for end user verification.
above listed BAPI’s / FM is for present Industrial requirement, If industrial requirement is to create individual production for all Combo product or for any fresh regular finished goods through production order, which also can be addressed through production order creation BAPI, and Production order Post BAPI.