‎2007 May 05 4:40 AM
consider i m having two internal tables. my first internal table has 10 records and my second internal table having 20 records. i want to append 11-20 records in second internal table to first internal table. whats the syntax
‎2007 May 05 4:47 AM
Hi Geetha,
Consider Itab1, Itab2 are the two internal tables having
Both are having one field like Emp name.
So now we are going to Move the records from Itab2 to Itab1.
Syntax is,
loop at Itab2 into wa2.
if sy-tabix > 9.
itab1 = wa2.
append itab1.
endif.
endloop.
Thanks.
Reward If Helpful.
‎2007 May 05 4:47 AM
Hi Geetha,
Consider Itab1, Itab2 are the two internal tables having
Both are having one field like Emp name.
So now we are going to Move the records from Itab2 to Itab1.
Syntax is,
loop at Itab2 into wa2.
if sy-tabix > 9.
itab1 = wa2.
append itab1.
endif.
endloop.
Thanks.
Reward If Helpful.
‎2007 May 05 4:57 AM
CHECK OUT THIS SAMPLE CODE.
DATA : BEGIN OF WA,
CH1(3),
NAME(5),
END OF WA,
IT1 LIKE STANDARD TABLE OF WA WITH HEADER LINE,
IT2 LIKE STANDARD TABLE OF WA WITH HEADER LINE.
IT2-CH1 = 'AB'.
IT2-NAME = 'VIJAY'.
APPEND IT2.
IT2-CH1 = 'CD'.
IT2-NAME = 'MANI'.
APPEND IT2.
IT2-CH1 = 'EF'.
IT2-NAME = 'REGIS'.
APPEND IT2.
IT2-CH1 = 'GH'.
IT2-NAME = 'VINOTH'.
APPEND IT2.
LOOP AT IT2 INTO WA.
WRITE: / WA-CH1, WA-NAME.
ENDLOOP.
IT1-CH1 = 'W1'.
IT1-NAME = 'REGIS'.
APPEND IT1.
IT1-CH1 = 'W2'.
IT1-NAME = 'VINOTH'.
APPEND IT1.
ULINE.
LOOP AT IT1.
WRITE: / IT1-CH1, IT1-NAME.
ENDLOOP.
ULINE.
LOOP AT IT2.
IF SY-TABIX > 2.
IT1 = IT2.
APPEND IT1.
ENDIF.
ENDLOOP.
LOOP AT IT1.
WRITE: / IT1-CH1, IT1-NAME.
ENDLOOP.
ULINE.
THANKS,
VIJI.
‎2007 May 05 5:22 AM
loop at itab2.
check sy-tabix GE 10.
append lines of itab2 to itab1.
endloop.
or try this..not sure about syntax..
loop at itab2 from 11 to 20.
append lines of itab2 to itab1.
endloop.
‎2007 May 05 5:46 AM
Hi,
Use the below syntax if your second table is an index table....
INSERT LINES of <itab2> FROM n1 TO n2 INTO TABLE <itab1>.
Cheers,
Hakim
‎2007 May 05 7:24 AM
Hi Geetha,
TRY THIS CODE,
&----
*& Report ZSG_TWOINTTABLE *
*& *
&----
*& *
*& *
&----
REPORT ZSG_TWOINTTABLE .
TABLES : MARA.
DATA : ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.
DATA : JTAB LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA UP TO 10 ROWS INTO CORRESPONDING FIELDS OF TABLE ITAB
.
SELECT * FROM MARA UP TO 20 ROWS INTO CORRESPONDING FIELDS OF TABLE JTAB
.
WRITE : /'****LOOP AT ITAB******'.
LOOP AT ITAB.
WRITE:/ ITAB-MATNR , ITAB-PSTAT.
ENDLOOP.
SKIP 5.
WRITE : /'****LOOP AT JTAB******'.
LOOP AT JTAB.
WRITE:/ JTAB-MATNR , JTAB-PSTAT.
ENDLOOP.
INSERT LINES of JTAB FROM 11 TO 20 INTO TABLE ITAB.
APPEND ITAB.
SKIP 5.
WRITE : /'****LOOP AT ITAB AFTER INSERT******'.
LOOP AT ITAB.
WRITE:/ ITAB-MATNR , ITAB-PSTAT.
ENDLOOP.
‎2007 May 07 4:57 AM
let you ve two internal tables itab1 and itab2 . but both the internal table should be same fields.at those time you want to move the some part of records from iternal table 1 to internal table 2.
the syntax as follows.
<b>append lines of itab from 5 to 10 to itab1.</b>
description.
itab " internal table 1
itab1 " internal table 2
here in my itab ve 10 records. but i want to move from the fifth record to tenth record.
the above syntax will works.
‎2007 May 07 8:14 AM
Hi,
Before that you have to check both internal tables have same fields of same data type.
loop at itab2 from 11 to 20.
append lines of itab2 to itab1.
endloop.
Reward points if it is helpful.
Regards,
Sangeetha.A