Order to Invoice Sales Cycle using FM/BAPI’s

Hello All,

We keep getting requirements from businesses to create a Z Process  to perform Order , Delivery and Invoicing in the background.

Although there are other option like BDC’s, here I am making attempt to do the same using FM/BAPI’s, this might be useful specially for Consultant who have just started working on Developments.

The Usage is typically for any Development where there is requirement for Mass Automaton of Order to Invoice generation or for a requirement where we need to perform the whole Order to Invoice process in background.

Input to such backend process typically happens through an external source e.g. manually uploading spreadsheet with data containing the input parameters for creating Sales Order

Pre-requisites for this process is that all Configuration (for running foreground process) and determination (Plant, Pricing, Storage location and so on) should be in place.

BAPI/Functional Modules  to be used :

BAPI_SALESORDER_CREATEFROMDAT2

BAPI_OUTB_DELIVERY_CREATE_SLS

WS_DELIVERY_UPDATE

RV_INVOICE_CREATE

PROCESS 1 – SO Creation :

BAPI_SALESORDER_CREATEFROMDAT2 to be used for creation of the same.

Input parameters :

Input in ORDER_HEADER_IN –

DOC_TYPE                  Sales Document Type that is to used

SALES_ORG                Sales Org. that is to used

DISTR_CHAN              Distribution Channel that is to used

DIVISION                     Division that is to used

PURCH_DATE             PO Date that is to be entered in SO header

PURCH_NO_C            PO No. that is to be entered in SO header

Input in ORDER_ITEMS_IN –

MATERIAL                      Material Number

PLANT                             Plant

TARGET_QTY                 Quantity

TARGET_QU                   UoM

Input in ORDER_PARTNERS –

PARTN_ROLE                  Value “SP” to be entered

PARTN_NUMB               Customer No. (Sold-to-Party)

Similarly add and enter the Partner functions (i.e. SH, BP, PY) and it’s corresponding value

Input in ORDER_SCHEDULES_IN –

REQ_QTY                        Quantity

Post Execution of BAPI_SALESORDER_CREATEFROMDAT2 we need to run BAPI_TRANSACTION_COMMIT to get the desired result.

Accordingly using the above mentioned two BAPI’s and passing the required parameters in our coding we can create the Sales Order to complete PROCESS 1.

PROCESS 2 – Delivery Creation :

BAPI_OUTB_DELIVERY_CREATE_SLS to be used for creation of the same.

Input parameters :

Input in SALES_ORDER_ITEMS  –

REF_DOC                        Sales Order No. (VBAK-VBELN) saved in PROCESS 1 is to be passed

Sample screenshot :

Post Execution of BAPI_OUTB_DELIVERY_CREATE_SLS we need to run BAPI_TRANSACTION_COMMIT as mentioned for PROCESS 1 to get the desired result.

Accordingly using the above mentioned BAPI’s and passing the required parameters in our coding we create the Delivery document to complete PROCESS 2.

PROCESS 3 – Picking and PGI of Delivery  :

WS_DELIVERY_UPDATE to be used for the same.

Input parameters :

Input in VBKOK_WA –

VBELN_VL                                        Delivery Number (LIKP-VBELN)created in PROCESS 2 is to be passed

WABUC                                             Value X” to be passed

Sample Screenshot :

SYNCHRON                                     Value X” to be passed

DELIVERY                                        Delivery Number (LIKP-VBELN) created in PROCESS 2 is to be passed

UPDATE_PICKING                          Value X” to be passed

NICHT_SPERREN                            Value X” to be passed

IF_DATABASE_UPDATE                      Value 1” to be passed

IF_ERROR_MESSAGES_SEND_0        Value X” to be passed

Sample Screenshot :

Input in VBPOK_TAB –

VBELN_VL                              Delivery Number (LIKP-VBELN) created in PROCESS 2 is to be passed

POSNR_VL                             Del. Item No. (LIPS-POSNR) created in PROCESS 2 is to be passed

VBELN                                    Sales Order Number (VBAK-VBELN) saved in PROCESS 1 is to be passed

POSNN                                   Sales Order Item No. (VBAP-POSNR) saved in PROCESS 1 is to be passed

MATNR                                  Material (LIPS-MATNR) in Delivery to be passed

WERKS                                   Plant (LIPS-WERKS) in Delivery to be passed

NDIFM                                   Quantity(LIPS-LFIMG) in Delivery to be passed

LFIMG                                    Quantity (LIPS-LFIMG) in Delivery to be passed

LGMNG                                 Quantity (LIPS-LFIMG) in Delivery to be passed

VRKME                                  UoM (LIPS-VRKME) in Delivery to be passed

Input in PROT –

VBELN                           Delivery (LIKP-VBELN) created in PROCESS 2 is to be passed

POSNR                          Delivery Item No. (LIPS-POSNR) created in PROCESS 2 is to be passed

MATNR                         Material (LIPS-MATNR) in Delivery to be passed

LFIMG                            Quantity (LIPS-LFIMG) in Delivery to be passed

VRKME                          UoM (LIPS-VRKME) in Delivery to be passed

Accordingly using the above mentioned FM and passing the required parameters in our coding we complete the picking and PGI of the delivery thereby completing PROCESS 3.

 

PROCESS 4 – Billing document :

RV_INVOICE_CREATE to be used for creation of the same.

Input parameters :

WITH_POSTING                    Value B” to be passed

Input in XKOMFK –

MANDT                        System Client no. (Sy-Clnt value) to be passed

VBELN                          Delivery (LIKP-VBELN) saved in PROCESS 3 is to be passed

Accordingly using the above mentioned FM and passing the required parameters in our coding we complete the Invoice generation process thereby completing PROCESS 4.

The above inputs in this blog is my attempt to make things easier for Consultants to refer when they come across similar Business requirement.

Please note that this is just one of the methods for completing the Order to Invoice cycle in backend using BAPI/FM’s. and there might be other viable options as well.

Would like to know about the other options available from the fellow community members.

Thanks and Regards

 ABHRA