This document basically explains, how to extract shipment data from R/3 so that one understands the delivered Sales Orders(SOs) at any point in time. The challenge is to get data for a collection of SOs which is a mix of Assemble to Order(ATO) and non-ATO SOs. Moreover, this will also state how to get the configured components from the mix in the ATO SO. One can further restrict or modify the selection criteria based on one’s requirement or business scenario.
The logic as below:
1: Go to the table VBFA which is the sales document flow table. Select all the SO’s, with their line items, material and quantity i.e VBELN, POSNV,MATNR and RFMNG respectively based on the condition that the preceding document was an order(VBTYP_V=C) and subsequent document has had goods movement(VBTYP_N=R) and also the creation date(ERDAT). Please note a shipped SO number may come from VBFA-VBELV.
2: Then go to the table VBAP(SO Items tables) get the plant and Item category(PSTYV) details.
3: Get other header details and customer details, as desried, from VBAK and KNA1 respectively.
4: Based on the Item Category, check if the SO is a ATO order or a standard order i.e whether the material is a configurable material or normal material.
5: If the SO is a non-ATO order, then you may directly show the all the details as quantity, customer, plant, material, and date i.e VBFA-RFMNG, VBAK-KUNNR, VBAP-WERKS, VBFA-MATNR, VBFA-ERDAT. You can sum all the shipment quantities for a particular material for a particular date.
6: If the SO is a ATO order, then you would also need to get the components for that order. Hence you would need to explode the ATO SO. For doing this you have to get the details of the production order or planned order(based on whatever strategy group is set in MRP view). With the SO reference get the Production Order details AFPO-AUFNR and AFPO-PSMNG from table AFPO, i.e VBAP-VBELN=AFPO-KDAUF, VBAP-POSNR=AFPO-KDPOS. Similarly for planned order from PLAF.
7: Fetch all reservation data from RESB based on the production order number(AFPO-AUFNR) or planned order(PLAF-PLNUM) above. Thus you get all component details. You can use the field RESB-KFPOS to get the option components used in the ATO SO.
8: To get the actual quantity for the Option items of a ATO sales order, shipment for any particular date, you need to get the quantity per for that option and multiply the same by the shipment quantity, i.e (RESB-BDMNG/AFPO-PSMNG)*VBFA-RFMNG. Now you can show show the all the details as quantity, customer, plant, material, option material, option material quantity and date i.e VBFA-RFMNG, VBAK-KUNNR, VBAP-WERKS, VBFA-MATNR, RESB-MATNR, (RESB-BDMNG/AFPO-PSMNG)*VBFA-RFMNG, VBFA-ERDAT. You can sum all the shipment quantities for a particular material for a particular date.