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: 

Collect using OO

Former Member
0 Kudos

Does anyone know how to use the instruction collect using OO programming?

Cheers,

Nuno A.

2 REPLIES 2

Former Member
0 Kudos

The collect statement is used to sum the values of fields of type n and p. I would be suprised if you can use this same statement for collecting objects into an internal table.

jaideeps
Advisor
Advisor
0 Kudos

hi,

the collect function is same as in normal abap..

chk out this sample for collect,..

DATA: BEGIN OF line,

col1(3) TYPE c,

col2(2) TYPE n,

col3 TYPE i,

END OF line.

DATA itab LIKE SORTED TABLE OF line

WITH NON-UNIQUE KEY col1 col2.

line-col1 = 'abc'. line-col2 = '12'. line-col3 = 3.

COLLECT line INTO itab.

WRITE / sy-tabix.

line-col1 = 'def'. line-col2 = '34'. line-col3 = 5.

COLLECT line INTO itab.

WRITE / sy-tabix.

line-col1 = 'abc'. line-col2 = '12'. line-col3 = 7.

COLLECT line INTO itab.

WRITE / sy-tabix.

LOOP AT itab INTO line.

WRITE: / line-col1, line-col2, line-col3.

ENDLOOP.

or paste ur code regarding collect..we will solve it..

thanks

jaideep

*reward points if useful...