SAP MSR20_SO_INVOICE Function Module for Utility FM: Get Invoiced Qty/Amt for SO
MSR20_SO_INVOICE is a standard msr20 so invoice SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Utility FM: Get Invoiced Qty/Amt for SO processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for msr20 so invoice FM, simply by entering the name MSR20_SO_INVOICE into the relevant SAP transaction such as SE37 or SE38.
Function Group: MSR20_SO
Program Name: SAPLMSR20_SO
Main Program:
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function MSR20_SO_INVOICE pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'MSR20_SO_INVOICE'"Utility FM: Get Invoiced Qty/Amt for SO.
EXPORTING
PI_ORDER_NUMBER = "Sales Document
* PI_HEADER_ONLY = "Flag: X = No item determination
IMPORTING
PE_INVOICE_TOTAL = "Total Invoiced Amount in SO Currency
TABLES
* PT_ITEM_INVOICES = "MSR: Order Item Invoices
IMPORTING Parameters details for MSR20_SO_INVOICE
PI_ORDER_NUMBER - Sales Document
Data type: MSR20_ORDER_HEADER-SALESDOCUMENTOptional: No
Call by Reference: No ( called with pass by value option)
PI_HEADER_ONLY - Flag: X = No item determination
Data type: BAPIFLAG-BAPIFLAGOptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for MSR20_SO_INVOICE
PE_INVOICE_TOTAL - Total Invoiced Amount in SO Currency
Data type: MSR20_ORDER_HEADER-INV_TOTALOptional: No
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for MSR20_SO_INVOICE
PT_ITEM_INVOICES - MSR: Order Item Invoices
Data type: MSR20_ORDER_INVOICEOptional: Yes
Call by Reference: Yes
Copy and paste ABAP code example for MSR20_SO_INVOICE Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_pi_order_number | TYPE MSR20_ORDER_HEADER-SALESDOCUMENT, " | |||
| lv_pe_invoice_total | TYPE MSR20_ORDER_HEADER-INV_TOTAL, " | |||
| lt_pt_item_invoices | TYPE STANDARD TABLE OF MSR20_ORDER_INVOICE, " | |||
| lv_pi_header_only | TYPE BAPIFLAG-BAPIFLAG. " |
|   CALL FUNCTION 'MSR20_SO_INVOICE' "Utility FM: Get Invoiced Qty/Amt for SO |
| EXPORTING | ||
| PI_ORDER_NUMBER | = lv_pi_order_number | |
| PI_HEADER_ONLY | = lv_pi_header_only | |
| IMPORTING | ||
| PE_INVOICE_TOTAL | = lv_pe_invoice_total | |
| TABLES | ||
| PT_ITEM_INVOICES | = lt_pt_item_invoices | |
| . " MSR20_SO_INVOICE | ||
ABAP code using 7.40 inline data declarations to call FM MSR20_SO_INVOICE
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single SALESDOCUMENT FROM MSR20_ORDER_HEADER INTO @DATA(ld_pi_order_number). | ||||
| "SELECT single INV_TOTAL FROM MSR20_ORDER_HEADER INTO @DATA(ld_pe_invoice_total). | ||||
| "SELECT single BAPIFLAG FROM BAPIFLAG INTO @DATA(ld_pi_header_only). | ||||
Search for further information about these or an SAP related objects