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

SELECTING FROM INTERNAL TABLES

Former Member
0 Likes
769

hi i have an internal table say i_fpla which has two records. from this internal table i want to get the first row( or any one row) and put it into another internal table. can u plss tell me how to do it.

7 REPLIES 7
Read only

Former Member
0 Likes
744

read table itab index 1.

move-corresponding itab to itab2.

append itab2.

Read only

Former Member
0 Likes
744

Hi,

Check this..

  • Get the first row.

READ TABLE I_FPLA INTO WA INDEX 1.

  • Move the row to another internal table.

MOVE-CORRESPONDING WA TO WA_ANOTHER.

  • Add

APPEND WA_ANOTHER TO T_ANOTHER

Thanks,

Naren

Read only

Former Member
0 Likes
744

Hi,

loop at that table into work area.

Now you have one record in work area.

you can move it in another table work area and append that to another table.

for choosing a particular row, you can specify where condition or you can use sy-tabix. which is the index of internal table inside loop.

regards,

Ruchika

reward if useful....................

Read only

Former Member
0 Likes
744

hi

try the code

<b>***** Note</b>: itab1 and itab2 are declared with header line

read table itab1 index 1.

move-corresponding fields of itab1 to itab2.

append itab2.

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Read only

Former Member
0 Likes
744

Hi there

Lets say you have 2 records in tbl_tab1 and you want to put the records into another internal table say tbl_tab2.For this:

1. Define work areas for both the internal tables . lets say they are wa_tab1 which is of the same type as tbl_tab1 and wa_tab2 which is of the same type as tbl_tab2.

DATA: wa_tab1 like line of tbl_tab1,

wa_tab2 like line of tbl_tab2.

2. Now if you have a specific key in tbl_tab1 and you want to read a particular record with some condition then u can simply read table tbl_tab1 into the work area and then whichever fields you want to copy into wa_tab2 you can and simpyl append this to tbl_tab2.

READ TABLE tbl_tab1 into wa_tab1 with key field 1 = 'X'.

wa_tab2-field1 = wa_tab1-field1.

append wa_tab2 to tbl_tab2.

This will append a particular record to tbl_tab2.

X is some value for field1 which you want to read.

3.if you want to move both the records to tbl_tab2 then simply loop through this table.

loop at tbl_tab1 into wa_tab1.

wa_tab2-field1 = wa_tab1-field1.

append wa_tab2 to tbl_tab2.

endloop.

Both your records will get appended to tbl_tab2.

Hope this helps.

Cheers

shivika

Message was edited by:

Shivika Bhorchi

Read only

Former Member
0 Likes
744

hi,

since u want to get the first row...

use...

READ TABLE i_fpla index 1.

or u can use...define a varible of type sy-index...

and increment that variable when ever u want to read a particular row...

hope this will help u out..

please reward points in case usefull...

regards,

prashant

Read only

Former Member
0 Likes
744

hi,

try like this if both tables have header lines also,

if u know the index of 1st record in internal table 1 then

read table itab1 index 'no'.

move-coresponding itab1 to itab2.

or

read table itab1 with key field fldname = ' '.

move-corresponding itab1 to itab2.

loop at itab1 where fld = itab1-fld.

move itab1 to itab2.

append itab2.

endloop.

if useful reward some points.

with regards,

suresh.