03-04-2010 10:42 AM
Hi all ,
I want that BAPI BAPI_GOODSMVT_CREATE should be called at end of werks
the data :
000000000000000100|1001 |0002 |
000000000065857101|1001 |0002 |
structure of i_stocks
BEGIN OF t_stocks,
matnr TYPE mchb-matnr,
werks TYPE mchb-werks,
lgort TYPE mchb-lgort,
END OF t_stocks,
this is my code -->
sort i_stocks by matnr, werks.
LOOP AT I_STOCKS ASSIGNING <FS_STOCKS>.
IF <FS_STOCKS> IS ASSIGNED .
LW_GOODSMVT_ITEM-MATERIAL = <FS_STOCKS>-MATNR.
LW_GOODSMVT_ITEM-PLANT = <FS_STOCKS>-WERKS.
LW_GOODSMVT_ITEM-STGE_LOC = <FS_STOCKS>-LGORT.
APPEND LW_GOODSMVT_ITEM TO LI_GOODSMVT_ITEM.
AT END OF werks.
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
GOODSMVT_HEADER = LS_GOODSMVT_HEADER
GOODSMVT_CODE = LS_GOODSMVT_CODE
IMPORTING
GOODSMVT_HEADRET = LS_GOODSMVT_HEADRET
TABLES
GOODSMVT_ITEM = LI_GOODSMVT_ITEM
RETURN = LI_RETURN.
ENDAT.
ENDIF.
ENDLOOP.
I really dont know what is the problem here ??? after the first record the control should break and come to the second record
but it doesnt
Any inputs?
Regards
Bhanu
Edited by: Julius Bussche on Mar 4, 2010 1:08 PM
Please use code tags...
03-04-2010 10:46 AM
Hello,
Make WERKS the leftmost column of your internal table.
BEGIN OF t_stocks,
werks TYPE mchb-werks,
matnr TYPE mchb-matnr,
" werks TYPE mchb-werks,
lgort TYPE mchb-lgort,
END OF t_stocks,
Try this & check.
BR,
Suhas
PS: Make sure you REFRESH the Internal Table used in the BAPI after the call has been made
Edited by: Suhas Saha on Mar 4, 2010 4:17 PM
03-04-2010 10:50 AM
Yes suhas this worked
Just wanted to know the appropiate reason ?
Thnkx
03-04-2010 10:47 AM
Hi,
werks should be the first field of the internal table as shown below. now it should work
BEGIN OF t_stocks,
werks TYPE mchb-werks,
matnr TYPE mchb-matnr,
lgort TYPE mchb-lgort,
END OF t_stocks,
Thanks,
Narayan