‎2006 Aug 10 8:34 PM
Can anybody tell me a BAPI or Function Module for storage location to storage location transfer?
Thanks
Drew
‎2006 Aug 10 8:43 PM
‎2006 Aug 10 8:42 PM
‎2006 Aug 10 8:43 PM
‎2006 Aug 10 8:47 PM
Please see the example program. This does a movement from sl to sl for a certain material.
report zrich_0001.
* Structures for BAPI
data: gm_header type bapi2017_gm_head_01.
data: gm_code type bapi2017_gm_code.
data: gm_headret type bapi2017_gm_head_ret.
data: gm_item type table of
bapi2017_gm_item_create with header line.
data: gm_return type bapiret2 occurs 0 with header line.
data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.
clear: gm_return, gm_retmtd. refresh gm_return.
* Setup BAPI header data.
gm_header-pstng_date = sy-datum.
gm_header-doc_date = sy-datum.
gm_code-gm_code = '04'.
* Write 311 movement to table
clear gm_item.
move '311' to gm_item-move_type .
move '000000000040000100' to gm_item-material.
move '1' to gm_item-entry_qnt.
move 'EA' to gm_item-entry_uom.
move '0004' to gm_item-plant.
move '4000' to gm_item-stge_loc.
move '4999' to gm_item-move_stloc.
append gm_item.
* Call goods movement BAPI
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = gm_header
goodsmvt_code = gm_code
importing
goodsmvt_headret = gm_headret
materialdocument = gm_retmtd
tables
goodsmvt_item = gm_item
return = gm_return.
if not gm_retmtd is initial.
commit work and wait.
call function 'DEQUEUE_ALL'.
else.
commit work and wait.
call function 'DEQUEUE_ALL'.
endif.
write:/ gm_retmtd.
loop at gm_return.
write:/ gm_return.
endloop.
Regards,
Rich Heilman
‎2006 Aug 10 9:01 PM
You can use BAPI_GOODSMVT_CREATE.
<b>Sample code:</b>
* BAPI Communication Structure: Material Document Header Data
data xl_bapi2017_gm_head_01 like bapi2017_gm_head_01.
* BAPI Structure-New Key Assignment GM_CODE to Transaction of Inv. Mgmt
data xl_bapi2017_gm_code like bapi2017_gm_code.
* MMIM: Output Structure For General FM To Post Goods Movement
data xl_bapi2017_gm_head_ret like bapi2017_gm_head_ret.
* BAPI Communication Structure: Create Material Document Item
data itl_bapi2017_gm_item_create like bapi2017_gm_item_create
occurs 0 with header line.
* BAPI Communication Structure: Create Mat. Doc., Serial No.
data itl_bapi2017_gm_serialnumber like bapi2017_gm_serialnumber
occurs 0 with header line.
* Populating Material Document Header Data
xl_bapi2017_gm_head_01-pstng_date = sy-datum. "Posting date
xl_bapi2017_gm_head_01-doc_date = sy-datum. "Document date
* Populating New Key Assignment GM_CODE to Transaction of Inv. Mgmt
xl_bapi2017_gm_code-gm_code = "Movement code
* Populating BAPI Communication Structure: Create Material Document Item
itl_bapi2017_gm_item_create-material = "Material
itl_bapi2017_gm_item_create-plant = "Plant
itl_bapi2017_gm_item_create-stge_loc = "Storage Loc.
itl_bapi2017_gm_item_create-batch = "Batch
itl_bapi2017_gm_item_create-move_type = "Movement type
itl_bapi2017_gm_item_create-customer = "Customer
itl_bapi2017_gm_item_create-entry_qnt = "Quantity
itl_bapi2017_gm_item_create-profit_ctr = "Profit Center
append itl_bapi2017_gm_item_create.
* Calling BAPI function module BAPI_GOODSMVT_CREATE
refresh it_bapiret2.
clear it_bapiret2.
call function 'BAPI_GOODSMVT_CREATE'
exporting
goodsmvt_header = xl_bapi2017_gm_head_01
goodsmvt_code = xl_bapi2017_gm_code
* TESTRUN = ' '
importing
goodsmvt_headret = xl_bapi2017_gm_head_ret
* MATERIALDOCUMENT =
* MATDOCUMENTYEAR =
tables
goodsmvt_item = itl_bapi2017_gm_item_create
goodsmvt_serialnumber = itl_bapi2017_gm_serialnumber
return = it_bapiret2.
* In case of Error
if it_bapiret2-type <> 'E'. "If BAPI returned error
call function BAPI_TRANSACTION_COMMIT
endif.
‎2006 Aug 10 9:02 PM
‎2006 Aug 10 9:04 PM