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 and append

Former Member
0 Kudos

hai ....

Can u tell me the difference between collect and append in detail and also if possible with some example????????

Thanks

Pavan

1 ACCEPTED SOLUTION

amit_khare
Active Contributor
0 Kudos

Refer the links -

Regards,

Amit

Reward all helpful replies.

2 REPLIES 2

amit_khare
Active Contributor
0 Kudos

Refer the links -

Regards,

Amit

Reward all helpful replies.

former_member208856
Active Contributor
0 Kudos

Hi,

  • APPEND *******************************************

*This statement appends one or more rows line_spec to

*an internal index table itab.

TYPES: BEGIN OF ts_test,

a type BPREI,

b(10),

c(10),

d(10),

END OF ts_test.

DATA: it_test TYPE TABLE OF ts_test.

DATA: ls_test TYPE ts_test.

DATA: ls_test1 TYPE ts_test.

ls_test-a = 1.

ls_test-b = 'a'.

ls_test-c = 'test'.

ls_test-c = 'try'.

append ls_test to it_test.

clear ls_test.

ls_test-a = 2.

ls_test-b = 'b'.

ls_test-c = 'b_test'.

ls_test-c = 'b_try'.

append ls_test to it_test.

clear ls_test.

ls_test-a = 3.

ls_test-b = 'a'.

ls_test-c = 'test'.

ls_test-c = 'try'.

append ls_test to it_test.

clear ls_test.

ls_test-a = 4.

ls_test-b = 'b'.

ls_test-c = 'b_test'.

ls_test-c = 'b_try'.

append ls_test to it_test.

clear ls_test.

sort it_test.

clear ls_test1.

loop at it_test into ls_test.

write : ls_test-a.

write : ls_test-b.

write : ls_test-c.

write : ls_test-d.

write /.

endloop.

            • Collect ****************************

*This statement inserts the contents of a work area wa either

*as single row into an internal table itab or adds the values

*of its numeric components to the corresponding values of

*existing rows with the same key.

TYPES: BEGIN OF ts_test,

a type BPREI,

b(10),

c(10),

d(10),

END OF ts_test.

DATA: it_test TYPE TABLE OF ts_test.

DATA: ls_test TYPE ts_test.

DATA: ls_test1 TYPE ts_test.

ls_test-a = 1.

ls_test-b = 'a'.

ls_test-c = 'test'.

ls_test-c = 'try'.

collect ls_test into it_test.

clear ls_test.

ls_test-a = 2.

ls_test-b = 'b'.

ls_test-c = 'b_test'.

ls_test-c = 'b_try'.

collect ls_test into it_test.

clear ls_test.

ls_test-a = 3.

ls_test-b = 'a'.

ls_test-c = 'test'.

ls_test-c = 'try'.

collect ls_test into it_test.

clear ls_test.

ls_test-a = 4.

ls_test-b = 'b'.

ls_test-c = 'b_test'.

ls_test-c = 'b_try'.

collect ls_test into it_test.

clear ls_test.

sort it_test.

clear ls_test1.

loop at it_test into ls_test.

write : ls_test-a.

write : ls_test-b.

write : ls_test-c.

write : ls_test-d.

write /.

endloop.

Reward, if helpful,

Sandeep Kaushik