2008 May 29 6:08 PM
hi,
i have an internal table 'XX' based on a structure "s1". This contains some data. I have another similar internal table "YY". Now I want all the records from YY to be added to XX (i.e. append at the end ). what is the best code ? can some one give a sample please.
thks
2008 May 29 6:10 PM
If internal tables XX and YY are of asme type S1 then you can use
append lines of yy to XXThe rows of an internal table jtab are appended according to the same rules that apply for appending a workarea, in the sequence in which they exist in jtab. If jtab is an index table, you can restrict the rows to be appended by specifying FROM idx1 and TO idx2. In this case, only the table rows starting at table index idx1 or ending at table index idx2 from jtab are appended. For idx1 and idx2, data objects of type i are expected. If the value idx1 or idx2 is less than 0, an untreatable exception occurs. If idx1 is greater than idx2 or greater than the number of table rows, no rows are appended. If idx2 is greater than the number of table rows, it is set to the number of table rows.
Example
Appending square numbers to a sorted table with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.
DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.Edited by: Naren K Someneni on May 29, 2008 12:13 PM
If internal tables XX and YY are of asme type S1 then you can use
append lines of yy to XXThe rows of an internal table jtab are appended according to the same rules that apply for appending a workarea, in the sequence in which they exist in jtab. If jtab is an index table, you can restrict the rows to be appended by specifying FROM idx1 and TO idx2. In this case, only the table rows starting at table index idx1 or ending at table index idx2 from jtab are appended. For idx1 and idx2, data objects of type i are expected. If the value idx1 or idx2 is less than 0, an untreatable exception occurs. If idx1 is greater than idx2 or greater than the number of table rows, no rows are appended. If idx2 is greater than the number of table rows, it is set to the number of table rows.
Example
Appending square numbers to a sorted table with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.
DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.Edited by: Naren K Someneni on May 29, 2008 12:13 PM
2008 May 29 6:10 PM
If internal tables XX and YY are of asme type S1 then you can use
append lines of yy to XXThe rows of an internal table jtab are appended according to the same rules that apply for appending a workarea, in the sequence in which they exist in jtab. If jtab is an index table, you can restrict the rows to be appended by specifying FROM idx1 and TO idx2. In this case, only the table rows starting at table index idx1 or ending at table index idx2 from jtab are appended. For idx1 and idx2, data objects of type i are expected. If the value idx1 or idx2 is less than 0, an untreatable exception occurs. If idx1 is greater than idx2 or greater than the number of table rows, no rows are appended. If idx2 is greater than the number of table rows, it is set to the number of table rows.
Example
Appending square numbers to a sorted table with elementary row type.
DATA: int TYPE i,
itab LIKE SORTED TABLE OF int
WITH UNIQUE KEY table_line.
DO 10 TIMES.
int = sy-index ** 2.
APPEND int TO itab.
ENDDO.Edited by: Naren K Someneni on May 29, 2008 12:13 PM
2008 May 29 6:11 PM
2008 May 29 6:12 PM
You can do this using simple statement.
if the structure of the two internal tables are same you can simply do like this
it_table1[ ] = it_table2[ ].
if the structures are not same use move corresponding statement like this
move corresponding fields of it_table2 to it_table1
or
it_table1-field = it_table2-field.
append it_table1.
clear it_table1.
if it is useful. please reward me the points
Chinna
Edited by: Chinna on May 29, 2008 7:13 PM
Edited by: Chinna on May 29, 2008 7:13 PM
2008 May 29 6:13 PM
u can use in a LOOP the MOVE-CORRESPONDING FIELDS xx TO yy
the fields have the same name in both tables,
or assign directly, here the name dont's matter
LOOP AT XX.
yy-code = xx-code.
yy-sum = xx-tot.
append yy.
endloop.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |