2015 Apr 12 2:37 AM
I am dealing with variables internal table. There are 4 entries in it. I want to transfer those 4 entries into another internal table. one way is to write 4 loop statements but i want to know if there is a better way of looping through the same records 4 times. can some body please give me the syntax please?
Thanks.
I am dealing with variables internal table. There are 4 entries in it. I want to transfer those 4 entries into another internal table. one way is to write 4 loop statements but i want to know if there is a better way of looping through the same records 4 times. can some body please give me the syntax please?
Thanks.
2015 Apr 12 5:25 AM
HI,
can you try the below syntax.
IT_FINAL[ ]= IT_FINAL2[]
we are moving all objects form IT_FINAL to IT_FINAL2.
-Phani.
2015 Apr 12 5:39 AM
2015 Apr 12 10:29 AM
Hi,
If the other internal table already contains records, then you should use:
APPEND LINES OF itab1 TO itab2.
Otherwise you can use (as suggested by the others):
itab2 = itab1[].
Best regards,
Sander
2015 Apr 12 5:33 PM
Firstly, thank you every one for their answers. Every one got the points.
See what i want to do is this:
Currently i have my data in Internal table 1 and look like this:
Internal Table 1:
field1 field2 OPTION
12 ZXX EQ
13 ZNN EQ
Now, what i want to do is to take these 2 values in another internal table but i also want to manipulate the values. one way is to do this:
Loop at internal table1 into internal table 2
IF INTERNAL TABLE 1 - Field2 = 'ZXX'
INTERNAL TABLE 1 - Field2 = 'ZYY'
ENDIF.
APPEND to another table.
ENDLOOP.
Loop at internal table1 into internal table 2
IF INTERNAL TABLE 1 - Field2 = 'ZXX'
INTERNAL TABLE 1 - Field2 = 'ZGG'
ENDIF.
APPEND to another table.
ENDLOOP.
Because in my second internal table, I want to insert ZYY, ZGG and ZNN (total of three records). This way will work but i think there must be a better way to do this and not call 2 loop statements. so i am trying to find out the best practice.
Thanks.
2015 Apr 13 5:09 AM
Do you know ABAP? Please learn the ABAP basics or take help from an ABAPper. Looping at one itab into another itab isn't possible.
Here's the code that could help you - there's no need to have two loops.
LOOP AT itab1 into wa1. "wa1 is a work area of the same struct as itab1
IF wa1-field2 = 'ZXX'.
wa1-field2 = 'ZYY'. append wa1 to another_itab.
wa1-field2 = 'ZGG'. append wa1 to another_itab.
wa1-field2 = 'ZNN'. append wa1 to another_itab.
ENDIF.
ENDLOOP.
2015 Apr 18 4:56 PM
Hi,
If both table is having same structure then you need not to put loop for filling records.
Please make two internal tables with similar structure like this as an example.
TYPES : Begin of ty_matnr,
matnr TYPE matnr,
END of ty_matnr.
DATA it_matnr TYPE TABLE of ty_matnr.
DATA it_matnr1 TYPE TABLE of ty_matnr.
SELECT matnr
FROM mara
INTO TABLE it_matnr
UPTO 4 ROWS.
IF sy-subrc EQ 0.
it_matnr1[] = it_matnr[].
ENDIF.
I hope this clarifies your query.
BR,
Praveen
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |