SAP Function Modules

MR_CREATE_INVOICE SAP Function module







MR_CREATE_INVOICE is a standard SAP function module available within R/3 SAP systems depending on your version and release level. Below is the pattern details for this FM showing its interface including any import and export parameters, exceptions etc as well as any documentation contributions (Comments) specific to the object.

See here to view full function module documentation and code listing, simply by entering the name MR_CREATE_INVOICE into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: MRBI
Released Date: Not Released
Processing type: Normal fucntion module
Normal function module settings


Pattern for FM MR_CREATE_INVOICE - MR CREATE INVOICE





CALL FUNCTION 'MR_CREATE_INVOICE' "
* EXPORTING
*   i_stblg = '          '      " bkpf-stblg    Reference document to be cancelled (with cancellations)
*   i_stjah = 0000              " bkpf-stjah    Document year of reference document (with cancellations)
*   i_groupid =                 " apqi-groupid
*   i_xusvr = SPACE             " bkpf-xusvr
  IMPORTING
    e_belnr =                   " bkpf-belnr    Number of the created document
    e_gjahr =                   " bkpf-gjahr    Fiscal year of created document
  TABLES
    t_bbkpf =                   " bbkpf         Document header data
    t_mesg =                    " mesg
    t_rbsec =                   " rbsec
    t_rbseg =                   " rbseg         Line item data
    t_rbset =                   " rbset
  EXCEPTIONS
    DOCUMENT_NOT_BOOKED = 1     "
    HEADER_NOT_VALID = 2        "
    POSITIONS_NOT_VALID = 3     "
    .  "  MR_CREATE_INVOICE

ABAP code example for Function Module MR_CREATE_INVOICE





The ABAP code below is a full code listing to execute function module MR_CREATE_INVOICE including all data declarations. The code uses 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 original method of declaring data variables up front. 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).

DATA:
ld_e_belnr  TYPE BKPF-BELNR ,
ld_e_gjahr  TYPE BKPF-GJAHR ,
it_t_bbkpf  TYPE STANDARD TABLE OF BBKPF,"TABLES PARAM
wa_t_bbkpf  LIKE LINE OF it_t_bbkpf ,
it_t_mesg  TYPE STANDARD TABLE OF MESG,"TABLES PARAM
wa_t_mesg  LIKE LINE OF it_t_mesg ,
it_t_rbsec  TYPE STANDARD TABLE OF RBSEC,"TABLES PARAM
wa_t_rbsec  LIKE LINE OF it_t_rbsec ,
it_t_rbseg  TYPE STANDARD TABLE OF RBSEG,"TABLES PARAM
wa_t_rbseg  LIKE LINE OF it_t_rbseg ,
it_t_rbset  TYPE STANDARD TABLE OF RBSET,"TABLES PARAM
wa_t_rbset  LIKE LINE OF it_t_rbset .


SELECT single STBLG
FROM BKPF
INTO @DATA(ld_i_stblg).


SELECT single STJAH
FROM BKPF
INTO @DATA(ld_i_stjah).


SELECT single GROUPID
FROM APQI
INTO @DATA(ld_i_groupid).


SELECT single XUSVR
FROM BKPF
INTO @DATA(ld_i_xusvr).


"populate fields of struture and append to itab
append wa_t_bbkpf to it_t_bbkpf.

"populate fields of struture and append to itab
append wa_t_mesg to it_t_mesg.

"populate fields of struture and append to itab
append wa_t_rbsec to it_t_rbsec.

"populate fields of struture and append to itab
append wa_t_rbseg to it_t_rbseg.

"populate fields of struture and append to itab
append wa_t_rbset to it_t_rbset. . CALL FUNCTION 'MR_CREATE_INVOICE' * EXPORTING * i_stblg = ld_i_stblg * i_stjah = ld_i_stjah * i_groupid = ld_i_groupid * i_xusvr = ld_i_xusvr IMPORTING e_belnr = ld_e_belnr e_gjahr = ld_e_gjahr TABLES t_bbkpf = it_t_bbkpf t_mesg = it_t_mesg t_rbsec = it_t_rbsec t_rbseg = it_t_rbseg t_rbset = it_t_rbset EXCEPTIONS DOCUMENT_NOT_BOOKED = 1 HEADER_NOT_VALID = 2 POSITIONS_NOT_VALID = 3 . " MR_CREATE_INVOICE
IF SY-SUBRC EQ 0. "All OK ELSEIF SY-SUBRC EQ 1. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 2. "Exception "Add code for exception here ELSEIF SY-SUBRC EQ 3. "Exception "Add code for exception here ENDIF.







ABAP code to compare 7.40 inline data declaration with original syntax

The below ABAP code uses the older none in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. It may also be useful if you are using an older version of SAP as some of the newer syntax above, such as the @DATA is not available until 4.70 EHP 8.

DATA:
ld_e_belnr  TYPE BKPF-BELNR ,
ld_i_stblg  TYPE BKPF-STBLG ,
it_t_bbkpf  TYPE STANDARD TABLE OF BBKPF ,
wa_t_bbkpf  LIKE LINE OF it_t_bbkpf,
ld_e_gjahr  TYPE BKPF-GJAHR ,
ld_i_stjah  TYPE BKPF-STJAH ,
it_t_mesg  TYPE STANDARD TABLE OF MESG ,
wa_t_mesg  LIKE LINE OF it_t_mesg,
ld_i_groupid  TYPE APQI-GROUPID ,
it_t_rbsec  TYPE STANDARD TABLE OF RBSEC ,
wa_t_rbsec  LIKE LINE OF it_t_rbsec,
ld_i_xusvr  TYPE BKPF-XUSVR ,
it_t_rbseg  TYPE STANDARD TABLE OF RBSEG ,
wa_t_rbseg  LIKE LINE OF it_t_rbseg,
it_t_rbset  TYPE STANDARD TABLE OF RBSET ,
wa_t_rbset  LIKE LINE OF it_t_rbset.


SELECT single STBLG
FROM BKPF
INTO ld_i_stblg.


"populate fields of struture and append to itab
append wa_t_bbkpf to it_t_bbkpf.

SELECT single STJAH
FROM BKPF
INTO ld_i_stjah.


"populate fields of struture and append to itab
append wa_t_mesg to it_t_mesg.

SELECT single GROUPID
FROM APQI
INTO ld_i_groupid.


"populate fields of struture and append to itab
append wa_t_rbsec to it_t_rbsec.

SELECT single XUSVR
FROM BKPF
INTO ld_i_xusvr.


"populate fields of struture and append to itab
append wa_t_rbseg to it_t_rbseg.

"populate fields of struture and append to itab
append wa_t_rbset to it_t_rbset.

Contribute (Add Comments)

Please help keep this info upto date and use the comments section below to add useful hints, tips and information specific to this SAP function. This will then be available for you and other users to easily find by simply searching on the object name MR_CREATE_INVOICE or its description.