‎2007 Sep 03 7:19 AM
HI experts,
here in my scenario what i want that whenever i pass two material number it will give one document number ..ok ...but after writing this code it is giving two document number these two documnet number containing two material ...no doubt ....
what i want that after executing this bapi will give only one document number containing these two material number ..here the codes is..
BAPI header data.
GM_HEADER-PSTNG_DATE = SY-DATUM.
GM_HEADER-DOC_DATE = SY-DATUM.
*Goods receipt for production order
GM_CODE-GM_CODE = '03'. " MB1A
Write '261' movement to table
CLEAR GM_ITEM.
MOVE '700000000226' TO GM_ITEM-ORDERID.
MOVE '261' TO GM_ITEM-MOVE_TYPE .
MOVE '000000003000000172' TO GM_ITEM-MATERIAL.
MOVE '.1' TO GM_ITEM-ENTRY_QNT.
MOVE '6000' TO GM_ITEM-PLANT.
MOVE 'WFC1' TO GM_ITEM-STGE_LOC.
MOVE '1000006662' TO GM_ITEM-BATCH.
APPEND GM_ITEM.
clear GM_ITEM.
MOVE '700000000226' TO GM_ITEM-ORDERID.
MOVE '261' TO GM_ITEM-MOVE_TYPE .
MOVE '000000003000000170' TO GM_ITEM-MATERIAL.
MOVE '.1' TO GM_ITEM-ENTRY_QNT.
MOVE '6000' TO GM_ITEM-PLANT.
MOVE 'WFC1' TO GM_ITEM-STGE_LOC.
MOVE '1000007730' TO GM_ITEM-BATCH.
APPEND GM_ITEM.
clear GM_ITEM.
loop at 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.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
WRITE:/ GM_RETMTD.
endloop.
‎2007 Sep 03 7:55 AM
Hi ,
What i meant is that (here you are hard coding it) you are appending the header data twice. so, two documents will be created.
What you needed to do is append header info only once but with any number of materials!! i.e:
Either
remove the following statement , it will work:
<b>loop at gm_item.</b>
Regards.
‎2007 Sep 03 7:36 AM
Hi,
you are calling the bapi for every line of your table. so, here your table contains 2 entries , it will therefore create two documents.
you need to do the loop,
then read next record of table
if sy-subrc <> 0.
call bapi
else
continue.
Regards.
‎2007 Sep 03 7:40 AM
HI soonese plz explain it clearly.......i vud be grateful to you
‎2007 Sep 03 7:49 AM
‎2007 Sep 03 7:55 AM
Hi ,
What i meant is that (here you are hard coding it) you are appending the header data twice. so, two documents will be created.
What you needed to do is append header info only once but with any number of materials!! i.e:
Either
remove the following statement , it will work:
<b>loop at gm_item.</b>
Regards.