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

adding internal table fields

mohan_subramania
Explorer
0 Likes
760

i have one internal table which is having no of records with key document no .for ex

docuno price qty

1 25 23

1 23 22

1 24 34

2 24 22

2 44 45

3 55 23

3 5 34

the result as follows

docuno price qty

1 72 79

2 68 67

3 60 57

how to do this ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
743

Hi,

Store the record

1 25 23

1 23 22

1 24 34

2 24 22

2 44 45

3 55 23

3 5 34

in an internal table say itab.

Now declare one more internal table having same structure of itab say itab1.

data: itab1 like itab occurs 0 with header line.

lopp at itab.

move-corresponding itab to itab1.

collect itab1.

clear itab1.

endloop.

now ur itab1 wil show like

docuno price qty

1 72 79

2 68 67

3 60 57

If it is helpfull pls reward pts.

Regards

Srimanta

6 REPLIES 6
Read only

Former Member
0 Likes
743

Hi,

Check this:

loop at itab.

IF sy-tabix = sy-index.

sum itab-2(field) and 3(field).

endif.

endloop.

Regards,

Shiva Kumar(Reward if helpful).

Read only

Former Member
0 Likes
743

sort itab by docno price qnty.

loop at itab.

collect itab.

endloop.

or

loop at itab.

at end of docno.

SUM.

endat.

endloop.

Read only

Former Member
0 Likes
743
Read only

Former Member
0 Likes
743

data: begin of itab occurs 0,

docno(5) type c,

price type i,

qty type i,

end of itab.

data: begin of itab1 occurs 0,

docno(5) type c,

price type i,

qty type i,

end of itab1.

itab-docno = '1'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

itab-docno = '1'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

itab-docno = '1'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

itab-docno = '2'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

itab-docno = '2'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

itab-docno = '2'.

itab-price = 20.

itab-qty = 10.

append itab.

clear itab.

sort itab by docno.

loop at itab.

at end of docno.

sum.

itab1-docno = itab-docno.

itab1-price = itab-price.

itab1-qty = itab-price.

append itab1.

clear itab1.

endat.

endloop.

loop at itab1.

write:/ itab1-docno, 20 itab1-price, 40 itab1-qty.

clear itab1.

Reward if useful..............

Read only

Former Member
0 Likes
744

Hi,

Store the record

1 25 23

1 23 22

1 24 34

2 24 22

2 44 45

3 55 23

3 5 34

in an internal table say itab.

Now declare one more internal table having same structure of itab say itab1.

data: itab1 like itab occurs 0 with header line.

lopp at itab.

move-corresponding itab to itab1.

collect itab1.

clear itab1.

endloop.

now ur itab1 wil show like

docuno price qty

1 72 79

2 68 67

3 60 57

If it is helpfull pls reward pts.

Regards

Srimanta

Read only

Former Member
0 Likes
743

hai,

types: BEGIN OF tab_type,

dd(5) TYPE c,

END OF tab_type.

types: BEGIN OF tab,

d(1) TYPE c,

dd TYPE i,

END OF tab.

data: itab type standard table of tab_type with header line.

data: itabfinal type standard table of tab with header line.

itab-dd = '12523'.

append itab.

itab-dd = '12322'.

append itab.

itab-dd = '12434'.

append itab.

itab-dd = '22422'.

append itab.

itab-dd = '24445'.

append itab.

itab-dd = '35523'.

append itab.

itab-dd = '3534'.

append itab.

loop at itab.

itabfinal-d = itab-dd(1).

itabfinal-dd = itab-dd+1(4).

collect itabfinal.

endloop.

loop at itabfinal.

write 😕 itabfinal-d , itabfinal-dd.

endloop.

Thanks and Regards

Sarath p