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: 

coping of internaltable

Former Member
0 Kudos

Hi Experts,

Please let me know how can i copy one internal table data into another internal table without deleting the first internaltable data and

how can i insert one column in internal table.

Regards,

Saleem

8 REPLIES 8

Former Member
0 Kudos

Hi ,

U can use

append lines of itab1 to itab2.

This statement will insert itab1 data to itab2 with out deleting the itab2 entries.

Thanks,CSR.

****Please reward if helpful.

Former Member
0 Kudos

Hi,

Use itab1[] = itab2[] to copy the tables if the table is of same structure.

Regards,

Shruthi

amit_khare
Active Contributor
0 Kudos

If both itab1 & itab2 have same structure.

loop at itab2 into wa2.

append wa2 to itab1.

endloop.

If itab1 & itab2 have diff structure.

loop at itab2 into wa2.

wa11-fld1 = wa2-fld1.

..

append wa1 to itab1.

endloop.

For filling a column use MODIFY statement.

Regards,

Amit

Reward all helpful replies.

Former Member
0 Kudos

Hi,

Yes, You can copy one Internal Table Data into another Internal Table without deleting the First Internal Table Data.

Using MOVE Statement.

MOVE <itab1> to <itab2>.

If you are having another field in the second Internal Table then use MOVE-CORRESPONDING.

For Example,

DATA: BEGIN OF ADDRESS,

FIRSTNAME(20) VALUE 'Fred',

SURNAME(20) VALUE 'Flintstone',

INITIALS(4) VALUE 'FF',

STREET(20) VALUE 'Cave Avenue,

NUMBER TYPE I VALUE '11'.

POSTCODE TYPE N VALUE '98765'.

CITY(20) VALUE 'Bedrock',

END OF ADDRESS.

DATA: BEGIN OF NAME,

SURNAME(20),

FIRSTNAME(20),

INITIALS(4),

TITLE(10) VALUE 'Mister',

END OF NAME.

MOVE-CORRESPONDING ADDRESS TO NAME.

Regards,

Padmam.

Former Member
0 Kudos

Hi Saleem,

Lets say you have 2 inernal tables. ITAB1 and ITAB2. Now if you want to insert the rows of ITAB1 into ITAB2 with out deleting the ITAB1 entries you need to use the command.

APPEND LINES OF ITAB2 to ITAB1.

IF you want to add any one column entry from ITAB1 to ITAB2 with out deleting other column entries, you need to modify the entries based on key fields.

LOOP AT ITAB1 into WA_ITAB1.

READ TABLE ITAB2 into WA_ITAB2 WITH KEY (Key Fields = WA_ITAB1-Key Fields)

MODIFY ITAB2 INDEX SY-TABIX TRANSPORTING (Column Name).

ENDLOOP.

<b>Reward points for helpful answers</b>.

Best Regards,

Ram.

Former Member
0 Kudos

Hi,

as u told u need one more column in new internal table,

loop at itab1 into warea1.

move-corresponding warea1 to warea2.

append warea2 to itab2.

endloop.

Reward if helpful.

Regards,

Karthick.

Former Member
0 Kudos

Hi Saleem,

If they are exactly the same structure.

itab2[] = itab1[].

or

Try this instead.

append lines of itab1 to itab_FINAL.

append lines of itab2 to itab_FINAL.

append lines of itab3 to itab_FINAL.

append lines of itab4 to itab_FINAL.

append lines of itab5 to itab_FINAL.

or

Loop at tab1.

move-corresponing tab1 to tabmain.

append tabmain.

ENDLOOP.

Make sure both the table have same fields name.

<b>REward Points If Useful*

Mark if solved*</b>

Former Member
0 Kudos

Hi

Use APPEND LINES OF itab to itab1.

You can refer this code.

REPORT ZSDN.

DATA: int TYPE i,

itab LIKE STANDARD TABLE OF int,

itab1 LIKE STANDARD TABLE OF int.

DO 10 TIMES.

int = sy-index ** 2.

APPEND int TO itab.

ENDDO.

DO 10 TIMES.

int = sy-index ** 2.

APPEND int TO itab.

ENDDO.

APPEND LINES OF itab to itab1.

this will append lines of itab to table itab1.

thanks,

Sarbpreet Multani