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: 

internal tables

Former Member
0 Kudos

Hello Experts,

Can anybody please tell me how can I transfer the data in 2 internal tables to a 3rd internal table.

I'm using the 3rd internal table to output.

The 3 internal tables are like this:

1st:

data: begin of i_data occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

end of i_Data.

2nd:

data: begin of i_data2 occurs 0,

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data2.

3rd:

data: begin of i_data3 occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data3.

thnx for the help.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Lope,

Do like this:

1st:

data: begin of i_data occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

end of i_Data.

2nd:

data: begin of i_data2 occurs 0,

<b>vbeln like vbrk-vbeln</b>

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data2.

3rd:

data: begin of i_data3 occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data3.

loop at i_data2.

read table i_data1 with key vbeln = i_data2-vbeln.

if sy-subrc eq 0.

move i_data1-bstnk to i_data3-bstnk.

move i_data1-vbeln to i_data3-vbeln.

move i_data2-fkdat to i_data3-fkdat.

move i_data1-fkimg to i_data3-fkimg.

append i_data3.

clear i_data3.

endif.

endloop.

Hope this helps.

Regards,

Vivek

7 REPLIES 7

sunilachyut
Contributor
0 Kudos

loop at i_data into work_area1.

read table i_data2 into work_area2 index sy-tabix.

Move: work_area1-bstnk to work_area3-bstnk,

work_area1-vbeln to work_area3-vbeln.

  • Similarly do a move for all the fields.

append work_area3 to i_data3.

endloop.

hith

Sunil Achyut

Former Member
0 Kudos

Hi Lope,

Do like this:

1st:

data: begin of i_data occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

end of i_Data.

2nd:

data: begin of i_data2 occurs 0,

<b>vbeln like vbrk-vbeln</b>

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data2.

3rd:

data: begin of i_data3 occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data3.

loop at i_data2.

read table i_data1 with key vbeln = i_data2-vbeln.

if sy-subrc eq 0.

move i_data1-bstnk to i_data3-bstnk.

move i_data1-vbeln to i_data3-vbeln.

move i_data2-fkdat to i_data3-fkdat.

move i_data1-fkimg to i_data3-fkimg.

append i_data3.

clear i_data3.

endif.

endloop.

Hope this helps.

Regards,

Vivek

0 Kudos

Thnx all of you.

Vivek, it helped me a lot.

Could you please let me know how can I do if i have one more internal table, meaning if i have to move 3 internal tables data to a 4th internal table.

the internal tables are:

1st:

data: begin of i_data occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

end of i_Data.

2nd:

data: begin of i_data2 occurs 0,

vbeln like vbrk-vbeln

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

end of i_data2.

3rd:

data: begin of i_data4 occurs 0,

vbeln like vbpa-vbeln,

kunnr like vbpa-kunnr,

end of i_data4.

data: begin of i_data4 occurs 0,

bstnk like vbak-bstnk,

vbeln like vbak-vbeln,

fkdat like vbrk-fkdat,

fkimg like vbrp-fkimg,

kunnr like vbpa-kunnr,

end of i_data4.

thnx very much.

0 Kudos

Try this Lope,

loop at i_data2.

read table i_data1 with key vbeln = i_data2-vbeln.

if sy-subrc eq 0.

move i_data1-bstnk to i_data4-bstnk.

move i_data1-vbeln to i_data4-vbeln.

move i_data2-fkdat to i_data4-fkdat.

move i_data2-fkimg to i_data4-fkimg.

endif.

read table i_data3 with key vbeln = i_data2-vbeln.

if sy-subrc eq 0.

move i_data3-kunnr to i_data4-kunnr.

endif.

if i_data4 is not initial.

append i_data4.

clear i_data4.

endif.

endloop.

Regards,

Vivek

PS: Award points if helpful and close the thread once it is answered.

0 Kudos

thnx everybody.

Former Member
0 Kudos

Without a common field in each table, it'll be pretty difficult to come up with something meaningful. I think the first step will be to include VBELN in i_data2.

Rob

0 Kudos

Hmmm never thought about common field, if you have same number of rows in both the tables and your purpose is just to copy the values then what I said works otherwise ignore it.

Sunil Achyut