10-20-2016 6:01 PM
Hello guys
I'm starting to learn abap and have some doubts about internal tables access.
I have the following code:
TYPES:
t_column TYPE STANDARD TABLE OF string WITH EMPTY KEY,
t_row TYPE STANDARD TABLE OF t_column WITH EMPTY KEY.
DATA: columns TYPE i VALUE 3,
rows TYPE i VALUE 3.
DATA: it_column TYPE t_column,
it_row TYPE t_row.
DO rows TIMES.
CLEAR it_column.
DO columns TIMES.
APPEND sy-index TO it_column.
ENDDO.
APPEND it_column TO it_row.
ENDDO.
Basically I'm trying to simulate a matrix, using tables inside tables.
What I wanna do is to access specific data from it_column which is inside it_row. For example: I wanna set a value for Row 2, Column 2 (according to the code above it currently contains the value 2). Line 2 of it_row contains a table it_column containing 3 lines. This is the values I wanna access.
Is there anyway to loop into it_column from the second line of it_row?
Thanks in advance
10-20-2016 6:59 PM
Hi
Yes, every record of table IT_ROW is a table too, so you can read the record of the first table and loop the records of the second one
READ TABLE IT_ROW INTO IT_COLUMN INDEX 2.
LOOP AT IT_COLUNM INTO .....
ENDLOOP.
Max
10-20-2016 6:59 PM
Hi
Yes, every record of table IT_ROW is a table too, so you can read the record of the first table and loop the records of the second one
READ TABLE IT_ROW INTO IT_COLUMN INDEX 2.
LOOP AT IT_COLUNM INTO .....
ENDLOOP.
Max
10-20-2016 7:30 PM
Cool. I used modify table later in order to send it_column back to it_row. That worked, thanks!
10-20-2016 7:05 PM
If you want to just loop at 2nd line, you can try.....
loop at it_row into work_area from 2 to 2.
endloop.
If you want to loop from 2nd line till end of the table then
loop at it_row into work_area from 2.
endloop.
-Chandra