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

Collect Statement

Former Member
0 Likes
562

Is it possible to replace a Collect statement by using a Hash Table and Insert

statements? If so, how?

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
536

Hi

Yes u can try to do it, but u need to use READ and MODIFY statament in order to update a record just loaded in the table:

READ TABLE ITAB WITH KEY FIELD = .....
IF SY-SUBRC = 0.
  ITAB-FIELD2 = ITAB-FIELD2 + .......
  MODIFY ITAB INDEX SY-TABIX.
ELSE.
  INSERT ITAB INTO TABLE ITAB.
ENDIF.

Max

3 REPLIES 3
Read only

JozsefSzikszai
Active Contributor
0 Likes
536

yes it is possible (and by big internal tables it is advised to do so):

read the internal table for the line:

-if found: summarize numeric values and modify the line in the internal table

-if not found: insert the new line

Read only

Former Member
0 Likes
536

HI,

You need do the Sum on the integer and Num Fields and insert the data to Hash table.

As Collect Statement add the NUM and INT fields where all Other Char fields has the same value.

Read only

Former Member
0 Likes
537

Hi

Yes u can try to do it, but u need to use READ and MODIFY statament in order to update a record just loaded in the table:

READ TABLE ITAB WITH KEY FIELD = .....
IF SY-SUBRC = 0.
  ITAB-FIELD2 = ITAB-FIELD2 + .......
  MODIFY ITAB INDEX SY-TABIX.
ELSE.
  INSERT ITAB INTO TABLE ITAB.
ENDIF.

Max