Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

At end of control break statement not working

Former Member
0 Kudos

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...

3 REPLIES 3

SuhaSaha
Advisor
Advisor
0 Kudos

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

Former Member
0 Kudos

Yes suhas this worked

Just wanted to know the appropiate reason ?

Thnkx

Former Member
0 Kudos

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