SAP Function Modules

BAPI_GOODSMVT_CANCEL SAP Function module - Reverse Goods Movements with MB_CANCEL_GOODS_MOVEMENT







BAPI_GOODSMVT_CANCEL 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 BAPI_GOODSMVT_CANCEL into the relevant SAP transaction such as SE37 or SE80.

Associated Function Group: MB_BUS2017
Released Date: 23.07.1998
Processing type: Remote-Enabled
remote enabled module settings


Pattern for FM BAPI_GOODSMVT_CANCEL - BAPI GOODSMVT CANCEL





CALL FUNCTION 'BAPI_GOODSMVT_CANCEL' "Reverse Goods Movements with MB_CANCEL_GOODS_MOVEMENT
  EXPORTING
    materialdocument =          " bapi2017_gm_head_02-mat_doc  Number of a Material Document
    matdocumentyear =           " bapi2017_gm_head_02-doc_year  Material Document Year
*   goodsmvt_pstng_date =       " bapi2017_gm_head_02-pstng_date  Posting Date
*   goodsmvt_pr_uname =         " bapi2017_gm_head_01-pr_uname  User Name for Printing Goods Receipt/Issue Slip
  IMPORTING
    goodsmvt_headret =          " bapi2017_gm_head_ret  Material Document Number/Material Document Year
  TABLES
    return =                    " bapiret2      Return Messages
*   goodsmvt_matdocitem =       " bapi2017_gm_item_04  Items That Are To be Reversed
    .  "  BAPI_GOODSMVT_CANCEL

ABAP code example for Function Module BAPI_GOODSMVT_CANCEL





The ABAP code below is a full code listing to execute function module BAPI_GOODSMVT_CANCEL 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_goodsmvt_headret  TYPE BAPI2017_GM_HEAD_RET ,
it_return  TYPE STANDARD TABLE OF BAPIRET2,"TABLES PARAM
wa_return  LIKE LINE OF it_return ,
it_goodsmvt_matdocitem  TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_04,"TABLES PARAM
wa_goodsmvt_matdocitem  LIKE LINE OF it_goodsmvt_matdocitem .


DATA(ld_materialdocument) = some text here

DATA(ld_matdocumentyear) = Check type of data required

DATA(ld_goodsmvt_pstng_date) = 20210129

DATA(ld_goodsmvt_pr_uname) = some text here

"populate fields of struture and append to itab
append wa_return to it_return.

"populate fields of struture and append to itab
append wa_goodsmvt_matdocitem to it_goodsmvt_matdocitem. . CALL FUNCTION 'BAPI_GOODSMVT_CANCEL' EXPORTING materialdocument = ld_materialdocument matdocumentyear = ld_matdocumentyear * goodsmvt_pstng_date = ld_goodsmvt_pstng_date * goodsmvt_pr_uname = ld_goodsmvt_pr_uname IMPORTING goodsmvt_headret = ld_goodsmvt_headret TABLES return = it_return * goodsmvt_matdocitem = it_goodsmvt_matdocitem . " BAPI_GOODSMVT_CANCEL
IF SY-SUBRC EQ 0. "All OK 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_goodsmvt_headret  TYPE BAPI2017_GM_HEAD_RET ,
ld_materialdocument  TYPE BAPI2017_GM_HEAD_02-MAT_DOC ,
it_return  TYPE STANDARD TABLE OF BAPIRET2 ,
wa_return  LIKE LINE OF it_return,
ld_matdocumentyear  TYPE BAPI2017_GM_HEAD_02-DOC_YEAR ,
it_goodsmvt_matdocitem  TYPE STANDARD TABLE OF BAPI2017_GM_ITEM_04 ,
wa_goodsmvt_matdocitem  LIKE LINE OF it_goodsmvt_matdocitem,
ld_goodsmvt_pstng_date  TYPE BAPI2017_GM_HEAD_02-PSTNG_DATE ,
ld_goodsmvt_pr_uname  TYPE BAPI2017_GM_HEAD_01-PR_UNAME .


ld_materialdocument = some text here

"populate fields of struture and append to itab
append wa_return to it_return.

ld_matdocumentyear = Check type of data required

"populate fields of struture and append to itab
append wa_goodsmvt_matdocitem to it_goodsmvt_matdocitem.

ld_goodsmvt_pstng_date = 20210129

ld_goodsmvt_pr_uname = some text here

SAP Documentation for FM BAPI_GOODSMVT_CANCEL


Using the Cancel method, material documents can be cancelled by calling up the function module MB_CANCEL_GOODS_MOVEMENT. You can only cancel ...See here for full SAP fm documentation

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 BAPI_GOODSMVT_CANCEL or its description.