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: 

3 itabs to 4th.

Former Member
0 Kudos
138

well i have three itabs with the same structure. i want to embed them in a 4th itab.

the keys are pernr year month.

thanx.

1 ACCEPTED SOLUTION

0 Kudos
83

Hi,

Then you need to use like this.

DATA: WA LIKE LINE OF ITAB1,

WA2 LIKE WA,

WA3 LIKE WA.

LOOP AT ITAB1.

CLEAR: WA, WA2, WA3.

READ TABLE <b>ITAB2</b> INTO <b>WA2</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

READ TABLE <b>ITAB3</b> INTO <b>WA3</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

MOVE YOUR DATA FROM WA2 and WA3 to WA.

and APPEND WA TO ITAB3.

ENDLOOP.

Regards,

Sesh

7 REPLIES 7

0 Kudos
83

Hi,

USe the following syntax.

APPEND LINES OF ITAB1 to ITAB4.

APPEND LINES OF ITAB2 to ITAB4.

APPEND LINES OF ITAB3 to ITAB4.

Regards,

Sesh

Former Member
0 Kudos
83

Hi.

For the first time.use itab4[] = itab[].R move itab1[] to itab4[].

For the second ,third internal tables

append lines of itab2 to itab4..

append lines of itab3 to itab4.

Thanks,

CSR.

****Reward if helpful.

Message was edited by:

CSR

Former Member
0 Kudos
83

thanx but i wasnt clear.

for example the itab_1 : pernr year moth amou1 amou2 amou3

10 2007 5 3 0 0

itab_2 : pernr year moth amou1 amou2 amou3

10 2007 5 0 5 0

itab_3 : pernr year moth amou1 amou2 amou3

10 2007 5 0 0 9

so itab 4 must be : pernr year moth amou1 amou2 amou3

10 2007 5 3 5 9

Former Member
0 Kudos
83

Hi Antonis,

Use COLLECT statment for your requirement.

LOOP AT ITAB1.

COLLECT ITAB1 INTO ITAB4.

ENDLOOP.

LOOP AT ITAB2.

COLLECT ITAB2 INTO ITAB4.

ENDLOOP.

LOOP AT ITAB3.

COLLECT ITAB3 INTO ITAB4.

ENDLOOP.

Thanks,

Vinay

0 Kudos
84

Hi,

Then you need to use like this.

DATA: WA LIKE LINE OF ITAB1,

WA2 LIKE WA,

WA3 LIKE WA.

LOOP AT ITAB1.

CLEAR: WA, WA2, WA3.

READ TABLE <b>ITAB2</b> INTO <b>WA2</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

READ TABLE <b>ITAB3</b> INTO <b>WA3</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

MOVE YOUR DATA FROM WA2 and WA3 to WA.

and APPEND WA TO ITAB3.

ENDLOOP.

Regards,

Sesh

0 Kudos
83

Hi,

Then you need to use like this.

DATA: WA LIKE LINE OF ITAB1,

WA2 LIKE WA,

WA3 LIKE WA.

LOOP AT ITAB1.

CLEAR: WA, WA2, WA3.

READ TABLE <b>ITAB2</b> INTO <b>WA2</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

READ TABLE <b>ITAB3</b> INTO <b>WA3</b> WITH KEY PERNR = ITAB1-PERNR1 YEAR = ITAB1-YEAR MONTH = ITAB1-MONTH.

MOVE YOUR DATA FROM WA2 and WA3 to WA.

and APPEND WA TO ITAB3.

ENDLOOP.

Regards,

Sesh

Former Member
0 Kudos
83

Do like this:

REPORT ytest1 line-count 20(10).

data: begin of itab1 occurs 10,

pernr,

year,

moth,

amou1,

amou2,

amou3,

end of itab1.

data: begin of itab2 occurs 10,

pernr,

year,

moth,

amou1,

amou2,

amou3,

end of itab2.

data: begin of itab3 occurs 10,

pernr,

year,

moth,

amou1,

amou2,

amou3,

end of itab3.

data: begin of itab4 occurs 10,

pernr,

year,

moth,

amou1,

amou2,

amou3,

end of itab4.

data: itab5 like itab2.

itab1-pernr = '10' .

itab1-year = '2007' .

itab1-moth = '5' .

itab1-amou1 = '3' .

itab1-amou2 = '0' .

itab1-amou3 = '0' .

append itab1.

itab2-pernr = '10' .

itab2-year = '2007' .

itab2-moth = '5' .

itab2-amou1 = '0' .

itab2-amou2 = '5' .

itab2-amou3 = '0' .

append itab2.

itab3-pernr = '10' .

itab3-year = '2007' .

itab3-moth = '5' .

itab3-amou1 = '0' .

itab3-amou2 = '0' .

itab3-amou3 = '9' .

append itab3.

LOOP AT ITAB1.

append ITAB1 TO ITAB4.

ENDLOOP.

loop at itab2.

read table itab4 index 1.

itab4-amou2 = itab2-amou2.

modify itab4 index 1.

endloop.

loop at itab3.

read table itab4 index 1.

itab4-amou3 = itab3-amou3.

modify itab4 index 1.

endloop.

loop at itab4.

write: / itab4-pernr,

itab4-year,

itab4-moth,

itab4-amou1,

itab4-amou2,

itab4-amou3.

endloop.