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

tables

Former Member
0 Likes
1,028

hello

how to move 3 internal table fields to one internal table

points for sure

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,009

Hi,

Create three internal tables & then create one internal table refering the fields of that three internal tables with the same name as that of those three internal tables.Then move the internal table values using <b>MOVE-CORRESPONDING <STR1> TO<STR2>.</b>

First move that Interanl Table value to that Fourth Table.Then by using conditions move the Second & Third Internal Table Values to the fourth internal table.

Regards,

Padmam.

9 REPLIES 9
Read only

Former Member
0 Likes
1,010

Hi,

Create three internal tables & then create one internal table refering the fields of that three internal tables with the same name as that of those three internal tables.Then move the internal table values using <b>MOVE-CORRESPONDING <STR1> TO<STR2>.</b>

First move that Interanl Table value to that Fourth Table.Then by using conditions move the Second & Third Internal Table Values to the fourth internal table.

Regards,

Padmam.

Read only

kiran_k8
Active Contributor
0 Likes
1,009

Prashanth,

Create a 4th internal table with all the fields that are in int1,int2,int3 then move corresponding fields to int 4.

K.Kiran.

Read only

Former Member
0 Likes
1,009

Hi, youcan loop at one internal table and read other two table and can append data to one internal table.

see the following code.

select ebeln belnr from ekbe into table itab2 where ebeln in s_ebeln.

SELECT lifnr belnr xblnr FROM rbkp INTO TABLE itab FOR ALL ENTRIES IN

itab2 WHERE

belnr = itab2-belnr.

.

SELECT name1 FROM lfa1 INTO TABLE itab1 FOR ALL ENTRIES IN itab WHERE

lifnr = itab-lifnr.

Loop at itab2 into wtab2.

wheader-ebeln = wtab2-ebeln.

read table itab into wtab

with key belnr = wtab2-belnr.

wheader-lifnr = wtab-lifnr.

wheader-belnr = wtab-belnr.

wheader-xblnr = wtab-xblnr.

read table itab1 into wtab1

with key lifnr = iheader-lifnr.

wheader-name1 = wtab1-name1.

append wheader to iheader.

end loop.

here we are moving data of itab2 , itab, itab1 into iheader.

regards,

Ruchika

rewadrs if useful.........

Read only

Former Member
0 Likes
1,009

Hi,

Please try this.

LOOP AT ITAB1.

LOOP AT ITAB2 WHERE F1 = ITAB1-F1

AND F2 = ITAB1-F2.

MOVE-CORRESPONDING ITAB1 TO ITAB3.

MOVE-CORRESPONDING ITAB2 TO ITAB3.

APPEND ITAB3.

ENDLOOP.

ENDLOOP.

Please check the syntax

Regards

Read only

S0025444845
Active Participant
0 Likes
1,009

Hi,

loop at one table into workarea.

move corresponding fields of that table work area to final table workarea.

read other two tables and content to final table.

append final table work area to final table.

clear all work areas.

wndloop.

regards,

sudha

Read only

Former Member
0 Likes
1,008

hi,

check this.

data : begin of itab1 occurs 0. "itab with work area.

key_field1 like ztable1-key_field1,

field1 like ztable1-field1,

field2 like ztable1-field2,

endof itab1.

data : begin of itab2 occurs 0. "itab with work area.

key_field2 like ztable2-key_field2,

field3 like ztable2-field3,

field4 like ztable2-field4,

endof itab2.

data : begin of itab_final occurs 0.

key_field1 like ztable1-key_field1,

field1 like ztable1-field1,

field2 like ztable1-field2,

field3 like ztable2-field3,

field4 like ztable2-field4,

endof itab_final.

put the date final(merged) internal table

*****************************************

1. loop at itab1.

read table itab2 with key keyfield2 = itab1-keyfield1.

if sy-surc = 0.

itab_final-key_field1 = itab1-keyfield1

itab_final-field1 = itab1-field1.

itab_final-field2 = itab1-keyfield2.

itab_final-field3 = itab2-field2.

itab_final-field4 = itab2-keyfield2.

append itab_final.

clear itab_final.

endif.

endloop.

Read only

Former Member
0 Likes
1,008

Hi Tirunagari Prashanth,

Use READ TABLE WITH KEY syntax.

It should solve the query.

Very useful in Outbound interfaces and also simplifies the code.

Hope this solves your query.

Reward points if useful.

Thanks,

Tej..

Read only

Former Member
0 Likes
1,008

Hi

If you need to Copy internal tables simply you can do like this.

IT1[] = IT2[].

So all the contents of IT2 will move to IT2.

Otherwise if you need to some particular Conditions do like this...

loop at it1 where <cond>.

move-corresponding it1 to it2.

append it2.

endloop.

The same method and loop you can use for next table also...Means

Loop at it3 where <cond>.

move-corresponding it3 to it2.

append it2.

endloop.

Reward All helpfull Answers...........

Read only

Former Member
0 Likes
1,008

Hi again Tirunagari Prashanth,

This code should help you.

*-----Fill field FI_BELNR from table tab_rbkpdis

LOOP AT tab_rbkpdis INTO s_rbkpdis.

READ TABLE tab_accdn INTO s_accdn

WITH KEY awref = s_rbkpdis-belnr

aworg = s_rbkpdis-gjahr.

IF sy-subrc EQ 0.

MOVE s_accdn-belnr TO s_rbkpdis-fi_belnr.

f_index = sy-tabix + 1.

READ TABLE tab_accdn INDEX f_index INTO s_accdn.

IF sy-subrc EQ 0.

IF s_rbkpdis-belnr = s_accdn-awref AND s_rbkpdis-gjahr =

s_accdn-aworg.

s_rbkpdis-fi_belnr = icon_display.

ENDIF.

ENDIF.

ENDIF.

MODIFY tab_rbkpdis FROM s_rbkpdis.

ENDLOOP.

ENDIF.

-


Reward Points.

Thanks,

Tej..