Skip to Content

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

problem using collect statement in loop

Hello Friends,

Can some one please help me with this.

I am trying to use collect statement on table it_bsis2

it_bsis2.

300101 20090227 604000036 10

300101 20090227 604000036 10

300302 20090227 604000036 10

300302 20090227 604000036 10

300304 20090227 604000036 10

300101 20090227 604000037 10

300101 20090227 604000038 10

300302 20090227 604000039 10

Expected output is

it_bsis2

300101 20090227 604000036 20

300302 20090227 604000036 20

300304 20090227 604000036 10

300101 20090227 604000037 10

300101 20090227 604000038 10

300302 20090227 604000039 10

can some one correct me to change my code,

LOOP AT IT_BSIS INTO IT_BSIS.

COLLECT IT_BSIS INTO IT_BSIS2 .

ENDLOOP.

Former Member
replied

Hello Jitesh,

COLLECT stmt is working the way it should work.

COLLECT adds the values of the numeric components of the work area to the existing rows of the internal table with the same key.

E.g.,

> 1000 0000300000 20071010 TO00001 200000.00

> 1000 0000300000 20071010 SI0001 10000.00

In this case TO00001 & SI0001 are not identical so it adds a new line to the int. table.

I cannot comment on how to proceed as i donot know the complete functionality. But if the values TO00001 & SI0001 are not required you can delete the field from your int. table & try.

BR,

Suhas

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