Advertisement
Guest User

BAPI_MATERIAL_SAVEDATA

a guest
Nov 26th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 2.91 KB | None | 0 0
  1.     data(plantData) = value bapi_marc_ga( ) .
  2.     data(plantDataX) = value bapi_marcx( plant = struc-werks ) .
  3.     data(storageLocationData) = value bapi_mard_ga( ) .
  4.     data(storageLocationDataX) = value bapi_mardx( plant = struc-werks stge_loc = struc-lgort ) .
  5.     data(bapiRet) = value fmfg_t_bapiReturn( ) .
  6.     call function 'BAPI_MATERIAL_GETALL'
  7.       EXPORTING
  8.         material            = struc-matnr     " Material Number
  9.         plant               = struc-werks     " Plant
  10.         storageLocation     = struc-lgort     " Storage Location
  11.       IMPORTING
  12.         plantData           = plantData           " Material Data at Plant Level
  13.         storageLocationData = storageLocationData " Material Data at Storage Location Level
  14.       TABLES
  15.         return              = bapiRet.             " Return Parameters
  16.  
  17.     if plantData-availCheck is initial .
  18.       plantData-availCheck = '01' .
  19.       plantDataX-availCheck = abap_true .
  20.     endif .
  21.  
  22.     if plantData-mrp_type is initial .
  23.       plantData-mrp_type = 'NA' .
  24.       plantDataX-mrp_type = abap_true .
  25.     endif .
  26.  
  27.     storageLocationData-reorder_pt = struc-minbe .
  28.     storageLocationDataX-reorder_pt = abap_true .
  29.  
  30.     storageLocationData-repl_qty = struc-lbstf .
  31.     storageLocationDataX-repl_qty = abap_true .
  32.  
  33.     storageLocationData-stge_bin = struc-lgpbe .
  34.     storageLocationDataX-stge_bin = abap_true .
  35.  
  36.     data(materialHeader) = value bapiMatHead(
  37.                                    material = struc-matnr
  38.                                    storage_view = abap_true
  39.                                    mrp_view = abap_true
  40.                                  ) .
  41.     free __postBapiResult .
  42.     data(bapiReturn) = value bapiRet2( ) .
  43.     call function 'BAPI_MATERIAL_SAVEDATA'
  44.       EXPORTING
  45.         headData             = materialHeader       " Header segment with control information
  46.         plantData            = value bapi_marc(     " Plant-specific material data
  47.                                  plant = struc-werks
  48.                                  mrp_type = plantData-mrp_type
  49.                                  availCheck = plantData-availCheck
  50.                                )
  51.         plantDataX           = plantDataX           " Information on update for PLANTDATA
  52.         storageLocationData  = value bapi_mard(     " Storage-location-specific material data
  53.                                  plant      = struc-werks
  54.                                  stge_loc   = struc-lgort
  55.                                  reorder_pt = storageLocationData-reorder_pt
  56.                                  repl_qty   = storageLocationData-repl_qty
  57.                                  stge_bin   = storageLocationData-stge_bin
  58.                                )
  59.         storageLocationDataX = storageLocationDataX " Information on update for STORAGELOCATIONDATA
  60.       importing
  61.         return               = bapiReturn.
  62.  
  63.     call function 'BAPI_TRANSACTION_COMMIT' .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement