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

internal table problem

Former Member
0 Likes
1,323

i have fatched data from multiple tables into multiple internal tables.

like kna1-kunnr in itab1, vbak-vbeln in itab2 etc,

now i have to move data from multiple itabs to my final internal table itab-final to show the output list in ALV, how can i do that.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,300

hi.

first create ur final internal table and then use the MOVE command to move the one internal table to the another.

ex: MOVE <itab1> to <itab2>

thanks

Ashu

12 REPLIES 12
Read only

Former Member
0 Likes
1,300

loop into each internal table and do a move corresponding to a work area of your final table type. keep appending to the final table.

Read only

Former Member
0 Likes
1,301

hi.

first create ur final internal table and then use the MOVE command to move the one internal table to the another.

ex: MOVE <itab1> to <itab2>

thanks

Ashu

Read only

Former Member
0 Likes
1,300

Hi,

Create internal table with structure of those Internal Tables.Then Loop those internal Tables.In that Loop Move values to corresponding fields of Final Internal Table.

Regards,

Padmam.

Read only

Former Member
0 Likes
1,300

Hi yogesh,

just loop at one internal table into work area and send it to the work area of a final internal table .... just like the below code.

loop at it_ekpo into x_ekpo.

read table it_ekko into x_ekko with key ebeln = x_ekpo-ebeln.

x_final-ebeln = x_ekpo-ebeln.

x_final-ebelp = x_ekpo-ebelp.

x_final-matnr = x_ekpo-matnr.

append x_final to it_final.

endloop.

reward points if useful.

reena

Read only

Former Member
0 Likes
1,300

hi ,

Loop the base table that u r having in multiple internal table

read the other table with conditins and populte in work area

then use MOVE-CORRESPONDING command

to move those values to final work area

then use APPEND command to add those values in final internal table.

Thanks and regards

JK

Read only

Former Member
0 Likes
1,300

Hi,

Maybe u can do like this:

ex your final itab call ITAB.

Loop at itab1.

move-corresponding itab1 to ITAB.

Read table itab2 with key vbeln = itab1-vbeln. --> ex itab1 and itab2 related using vbeln

move-corresponding itab2 to ITAB.

Append ITAB.

endloop.

Move corresponding only used if u got the same field name between itab1,2 and ITAB.

if not same, u can map it manually as well.

Best Regards,

Victor.

Read only

anversha_s
Active Contributor
0 Likes
1,300

hi,

<u><b>Chk this sample.</b></u>

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_field like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final. 

LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif.
append itab_final.
clear itab_final.
endloop

Regards

Anversha

Read only

former_member404244
Active Contributor
0 Likes
1,300

Hi,

Create a final internal table with all the fields in itab1 and itab2.

Now loop the internal tables and move the respected field values to the final internal table and finally append the records to final internal table.

reward points to all helpful answers.

Regards,

nagaraj

Read only

Former Member
0 Likes
1,300

Hi Yogesh ,

The question you have put forward is too generic to be answered correctly .

First u need to identify what data u are generating , if u are printing the order relevant data ,

then loop at the order_relevant table ( VBAK relevant data ) and

Then Move the desired data from that table to a final table .

The other fields of the final table can be retrieved USING READ statement on the secondary table ( like KNA1 relevant data ) KEY field = order_relevant_table -field ( example kunnr = vbak-kunnr )

Move the read data into the final table

Finally APPEND

Thanks

Read only

Former Member
0 Likes
1,300

hi yogesh,

just loop on final internal table...and read the data of remainining internal tables in that loop...

loop at gt_output into gs_output.

read table kna1 with key....

then,

read table vbak with key...

if sy-subrc = 0.

gs_output-kunnr = itab1-kunnr.

gs_output-vbeln = itab2-vbeln.

endif.

append gs_output into gt_output.

endloop.

thats all..now the read command inside will be based on where clause which u must have used while fetching data from table.....

accordingly use the read statements...

hope this will help u out...

please reward points in case usefull....

regards,

prashant

Read only

Former Member
0 Likes
1,300

Hi,

you can do it like this.

TYPES: begin of itype,

lifnr TYPE rbkp-lifnr,

belnr TYPE rbkp-belnr,

xblnr TYPE rbkp-xblnr,

END OF itype.

TYPES:BEGIN OF itype1,

name1 TYPE lfa1-name1,

END OF itype1.

TYPES: BEGIN OF itype2,

ebeln TYPE ekbe-ebeln,

belnr type ekbe-belnr,

END OF itype2.

DATA: itab TYPE TABLE OF itype, "internal table

wtab TYPE itype. "work area

DATA: itab1 TYPE TABLE OF itype1, "internal table

wtab1 TYPE itype1. "work area

DATA: itab2 TYPE TABLE OF itype2, "internal table

wtab2 TYPE itype2. "work area

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.

iheader-ebeln = wtab2-ebeln.

read table itab into wtab

with key belnr = wtab2-belnr.

iheader-lifnr = wtab-lifnr.

iheader-belnr = wtab-belnr.

iheader-xblnr = wtab-xblnr.

read table itab1 into wtab1

with key lifnr = iheader-lifnr.

iheader-name1 = wtab1-name1.

end loop.

here data of three inernal tables itab1 , itab, itab2 are coming in afinal tbale iheader.

regards,

Ruchika

Read only

S0025444845
Active Participant
0 Likes
1,300

Hi,

declare final table and workarea

loop on one table into workarea the main table and then read all other tables

and move to final work area.

append work area to final table .

and then clear all work areas.

Iam giving example.

looo at itab into wa_itab.

move fields from wa_itab to wa_final.

read table itab1 into wa_itab1 ith key <condition>

if sy-subrc = 0.

move fields from wa_itab1 to wa_final.

endif.

like that read aa table and move.

append wa_final to it_final.

clear: wa_final,wa_itab,wa_itab1.

endloop.

regards,

sudha.