Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

AT END OF

Hi guys,

How does AT END OF works? Thanks a lot!

Rgds,

mark

Tags:
Former Member
Former Member replied

Hi mark...

first c the following code..

SORT IMARD1 BY MATNR.

LOOP AT IMARD1 INTO WMARD1.

LW_LABST = LW_LABST + WMARD1-LABST.

AT END OF MATNR.

MOVE:LW_LABST TO WMARD1-LABST.

MODIFY IMARD1 FROM WMARD1 TRANSPORTING LABST.

CLEAR:LW_LABST.

ENDAT.

CLEAR:WMARD1.

ENDLOOP.

IMARD1 is declared as follows..

TYPES:BEGIN OF ITAB_MARD1 , "Storage Location Data for Material

MATNR TYPE MARD-MATNR , "Material Number

WERKS TYPE MARD-WERKS , "Plant

LGORT TYPE MARD-LGORT , "Storage location

LABST TYPE MARD-LABST , "Valuated stock with unrestricted use

INSME TYPE MARD-INSME , "Stock in quality inspection

SPEME TYPE MARD-SPEME , "Blocked stock

END OF ITAB_MARD1 .

Note taht here MATNR is the first field of the internal table.

So whenevr it changes you AT END OF event will get triggered.

Hence it is important for you to sort it by MATNR.

Now consider that MATNR is not the first of u r internal table but u still want to use AT END OF MATNR..

eg

Data for Material

LGORT TYPE MARD-LGORT , "Storage location

MATNR TYPE MARD-MATNR , "Material Number

WERKS TYPE MARD-WERKS , "Plant

LABST TYPE MARD-LABST , "Valuated stock with unrestricted use

INSME TYPE MARD-INSME , "Stock in quality inspection

SPEME TYPE MARD-SPEME , "Blocked stock

END OF ITAB_MARD1 .

Then here your AT END OF event will get triggered even if LGORT changes even though MATNR has not changed..

So in this case u might have to sort it storage location wise

or both storage location and material wise...

I hope u got what u require..

Do reward if this helps you.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question