Skip to Content
Technical Articles
Author's profile photo Abhra Sinha

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

PROCESS1 – SO Creation :

BAPI_SALESORDER_CREATEFROMDAT2to be used for creation of the same.

Input parameters :

Input in ORDER_HEADER_IN –

DOC_TYPESales Document Typethat is to used

SALES_ORGSales Org.that is to used

DISTR_CHANDistribution Channelthat is to used

DIVISIONDivisionthat is to used

PURCH_DATEPO Datethat is to be entered in SO header

PURCH_NO_CPO No.that is to be entered in SO header

输入ORDER_ITEMS_IN -

MATERIALMaterial Number

PLANTPlant

TARGET_QTYQuantity

TARGET_QUUoM

Input in ORDER_PARTNERS –

PARTN_ROLE Value “SP” to be entered

PARTN_NUMBCustomer 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_QTYQuantity

Post Execution ofBAPI_SALESORDER_CREATEFROMDAT2we need to runBAPI_TRANSACTION_COMMITto 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 completePROCESS 1.

PROCESS 2 – Delivery Creation :

BAPI_OUTB_DELIVERY_CREATE_SLSto be used for creation of the same.

Input parameters :

Input in SALES_ORDER_ITEMS –

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

Sample screenshot :

Post Execution ofBAPI_OUTB_DELIVERY_CREATE_SLSwe need to runBAPI_TRANSACTION_COMMITas mentioned forPROCESS 1to 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 completePROCESS 2.

PROCESS 3 – Picking and PGI of Delivery :

WS_DELIVERY_UPDATEto be used for the same.

Input parameters :

Input in VBKOK_WA –

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

WABUC ValueX”to be passed

Sample Screenshot :

SYNCHRON ValueX”to be passed

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

UPDATE_PICKING ValueX”to be passed

NICHT_SPERREN ValueX”to be passed

IF_DATABASE_UPDATE Value1”to be passed

IF_ERROR_MESSAGES_SEND_0 ValueX”to be passed

Sample Screenshot :

Input in VBPOK_TAB –

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

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

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

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

MATNR材料(LIPS-MATNR)在交付通过ed

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 inPROCESS 2is to be passed

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

MATNR材料(LIPS-MATNR)在交付通过ed

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 completingPROCESS 3.

PROCESS 4 – Billing document :

RV_INVOICE_CREATEto be used for creation of the same.

Input parameters :

WITH_POSTING ValueB”to be passed

Input in XKOMFK –

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

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

Accordingly using the above mentioned FM and passing the required parameters in our coding we complete the Invoice generation process thereby completingPROCESS 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

Assigned Tags

      1 Comment
      You must beLogged onto comment or reply to a post.
      Author's profile photo Kuldeep Sharma
      Kuldeep Sharma

      Nice Documents https://people.sap.com/abhra.s