Application Development and Automation 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: 
Read only

Set a Counter.

Former Member
0 Likes
1,400

Hi ,

i want to set a counter

when ever a material change.& clear when

invoice no changes..

for eg i have invoice no with 5 lineitems..

invoice no | Materail

101 Xyz

xyz

zzz

zzz

yyy..

here counter should be 3.

reset when invoice no changes.

Hi ,

i want to set a counter

when ever a material change.& clear when

invoice no changes..

for eg i have invoice no with 5 lineitems..

invoice no | Materail

101 Xyz

xyz

zzz

zzz

yyy..

here counter should be 3.

reset when invoice no changes.

2 REPLIES 2
Read only

Former Member
0 Likes
708

I assume you have an internal table with invoice nos and each invoice has its items. Please sort the internal table by invoice no. and item and use control break statement.

loop at invoices.

at new invoice.

counter = 0.

endat.

loop at items.

AT new item.

counter = counter + 1.

endat.

endloop.

endloop.

Read only

Former Member
0 Likes
708

Hi

U can use Internal Table control events inside LOOP..

AT NEW <FIELD>. " Triggers when found new value of a <FIELD>

ENDAT

AT END OF <FIELD>.

END AT.

<FIELD> ==> Material No (MATNR)

<FIELD> ==> Invoice No (BELNR)

DATA : COUNTER TYPE I.

COUNTER = O.

LOOP AT ITAB INTO WA.

AT NEW BELNR.

COUNTER = O.

ENDAT.


AT NEW MATNR.

COUNTER = COUNTER + 1.

ENDAT.


ENDLOOP.

Also give a try for AT END OF

Hope it will solve your problem..

Thanks & Regards

ilesh 24x7