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: 

Regarding internal table

Former Member
0 Kudos

Hi,

I m working in internal tables.

I want to hav records like

data : begin of itab occurs 0,

name1(10) type c

id type i,

amount type i,

end of itab.

so i m inserting few records like

<code>

name1 id amount

p1 10 100

p1 10 200

p1 10 300

p2 20 400

p2 20 250

</code>

so i want to use collect and add the numeric fields.

I want to know how to do it.

Regrads,

Kavita

5 REPLIES 5

Former Member
0 Kudos

Hi,

Try this,

data : begin of itab occurs 0 with key name1 id,

name1(10) type c

id type i,

amount type i,

end of itab.

loop at itab.

collect itab.

endloop.

Regards,

Padmam.

Former Member
0 Kudos

DATA: BEGIN OF seats,

carrid TYPE sflight-carrid,

connid TYPE sflight-connid,

seatsocc TYPE sflight-seatsocc,

END OF seats.

DATA seats_tab LIKE HASHED TABLE OF seats

WITH UNIQUE KEY carrid connid.

SELECT carrid connid seatsocc

FROM sflight

INTO seats.

COLLECT seats INTO seats_tab.

ENDSELECT.

Check the above example...

Regards,

Pavan

Former Member
0 Kudos

after the end of itab give

Collect itab.

Former Member
0 Kudos

Hi,

First of all I feel that ID should not be a numeric field i.e. it should be a character field instead of I because when we use Collect then ID will also get summed up which is not correct.

Hence declare ID as ID(2) type c.

Then use the following code:

ITAB-NAME = 'P1'.

ITAB-ID = '10'.

ITAB-AMOUNT = 100.

COLLECT ITAB.

This will sum up the numeric fields.

Regards,

Himanshu

Former Member
0 Kudos

Hello,

Try as follows and <b>reward if found helpfull</b>.


LOOP AT itab INTO wrk_area.
    COLLECT wrk_area INTO itab2.
  ENDLOOP.

<b>

itab, itab2 and wrk_area must be of same line type.

</b>

regards,

Rakesh.