REPORT z_example_bapi_material_savedata.
* Data Declarations
DATA: clidainp LIKE bapi_mara_ga,
clidaout LIKE bapi_mara,
clidaoutx LIKE bapi_marax,
valuationinp LIKE bapi_mbew_ga,
valuationout LIKE bapi_mbew,
valuationoutx LIKE bapi_mbewx,
headdata LIKE bapimathead,
return LIKE bapiret2,
returnmes LIKE bapi_matreturn2 OCCURS 0 WITH HEADER LINE.
* Get Material Number to be processed
PARAMETERS: material LIKE bapi_mara_ga-material.
* Read Material Data
CALL FUNCTION 'BAPI_MATERIAL_GET_ALL'
EXPORTING
material = material
IMPORTING
"clientdata = clidainp
valuationdata = valuationinp
TABLES
return = returnmes.
* Header Data: Material and View to maintain
headdata-material = material.
"headdata-basic_view = 'X'.
headdata-cost_view = 'X'.
* Detail Data: Field Value, and 'X'-Structure to mark the field for maintenance
*clidaout-net_weight = clidainp-net_weight * 2.
*clidaoutx-net_weight = 'X'.
valuationout-val_area = '6000'. "一定设置评估范围
valuationoutx-val_area = '6000'. "一定设置评估范围
valuationout-std_price = '300.00'.
valuationoutx-std_price = 'X'.
valuationout-price_unit = '1' .
valuationoutx-price_unit = 'X'.
valuationout-plndprice1 = '90.7'.
valuationoutx-plndprice1 = 'X'.
valuationout-plndprdate1 = sy-datum.
valuationoutx-plndprdate1 = 'X'.
* Call the BAPI
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = headdata
* clientdata = clidaout
* clientdatax = clidaoutx
valuationdata = valuationout
valuationdatax = valuationoutx
IMPORTING
return = return
TABLES
returnmessages = returnmes.
* Commit to release the locks
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* RETURN-TYPE is 'E' in case of error, else 'S'.
IF return-type = 'E'.
LOOP AT returnmes.
WRITE: / returnmes-message.
ENDLOOP.
ELSEIF return-type = 'S'..
WRITE: / 'Weight of material ', material, 'Sucessfully doubled'.
ENDIF.
网友评论