Skip to Content

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

AT / ENDAT

Hi,

I have an internal table with 5 columns

Field1 Field2

AAA BB ......

AAA CC

BBB CC

DDD CC

Now I am using

LOOP AT itab.

AT NEW Field2.

ADD 1 TO COUNTER.

ENDAT.

ENDLOOP.

Now consider first row, since BB is new

COUNTER = 1.

Then consider second record, since CC is new

COUNTER = COUNTER +1 = 2

Then consider third record, since CC is not new, I do not want 1 to be added to counter, however in DEBUG i noticed that since Field1 = AAA for second record <> Field1 = BBB for third record (Field CC is same in second and third record),

COUNTER = COUNTER +1 = 3.

But I do not want this to happen.

FOR the following internal table , counter should be 2, however in debug, I noticed that counter = 4, i want to change counter only on change of field 2, how can I do this, please note that my table is an internal table and is not a data set.

AAA BB ......

AAA CC

BBB CC

DDD CC

Tags:
replied

Hi MN,

Do like this,

LOOP AT itab.

on change of Field2.

ADD 1 TO COUNTER.

endon.

ENDLOOP.

Kiran

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