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

select different fields into same internal table from two different db tab

Former Member
0 Likes
1,649

Hi,

I'm selecting 3 fields from a DB table to an internal table .

there after i have to select one more field from another DB tables into same internal table.

But the second select is overwriting 1st record.

I want both to sustain as a single record.

How to do it?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,238

hi,

use modify.

loop at <internal table> into <work area>.

select ur fields in work area.

modify <internal table> from <work area> transporting <that fields>

endloop.

I think it can solve ur problem.

Message was edited by:

Dhwani shah

7 REPLIES 7
Read only

Former Member
0 Likes
1,239

hi,

use modify.

loop at <internal table> into <work area>.

select ur fields in work area.

modify <internal table> from <work area> transporting <that fields>

endloop.

I think it can solve ur problem.

Message was edited by:

Dhwani shah

Read only

Former Member
0 Likes
1,238

You need to do a select....appending table.

You cannot modify the single record. You would need to select into another table and then modify the first table based on the data of the second.

Read only

Former Member
0 Likes
1,238

Define itab1with 3 fields.

Define itab2 with 2 fields. <One field for connecting itab1 and itab2>

Get the details from table1 into itab1.

Get the details from table2 into itab2.

Loop at itab1.

l_index = sy-tabix.

read table itab2 with key <Condition>.

if sy-subrc eq 0.

Move the value from itab2 to itab1.

modify itab1 with index l_index.

endif.

endloop.

Read only

Former Member
0 Likes
1,238

Hi,

refer to my code as under:

Loop at itab.

read table itab1 with key mblnr = itab-mblnr

mjahr = itab-mjahr binary search.

if sy-subrc = 0.

move-corresponding itab1 to itab.

endif.

read table itab2 with key mblnr = itab-mblnr

mjahr = itab-mjahr binary search.

if sy-subrc = 0.

move-corresponding itab2 to itab.

endif.

modify itab transporting WERKS LGORT BUDAT OIB_BLTIME.

clear: itab, itab1, itab2.

Endloop.

Hope this helps.

Reward if helpful.

Regards,

Sipra

Read only

Former Member
0 Likes
1,238

hi,

while declaring a final table.

data : begin of itab_mara occurs 0,

matnr like mara-matnr,

ernam like mara-ernam,

end of itab_mara.

data : begin of itab_marc occurs 0,

matnr like marc-matnr,

werks like marc-werks,

end of itab_marc.

data : begin of itab_final occurs 0,

matnr like mara-matnr,

ernam like mara-ernam,

matnr1 like marc-matnr, " declaration of matnr in final table

werks like marc-werks,

end of itab_final.

Reward with points if helpful.

Read only

0 Likes
1,238

data : begin of itab_final occurs 0,

matnr like mara-matnr,

ernam like mara-ernam,

matnr1 like marc-matnr, " declaration of matnr in final table

werks like marc-werks,

end of itab_final.

selection-screen. "using selection -screen is a good way of writing code, even if it is not necessary.

start-of-selection.

select mara~matnr

mara~ernam

marc~werks

marc~matnr

from mara as mara

inner join marc as marc on

maramatnr eq marcmatnr into table itab_final.

loop at itab_final.

write:/ itab_final.

endloop.

reward points, if useful.

Read only

Former Member
0 Likes
1,238

Any reason you can't use a join?