Skip to Content
0

Acessing internal table inside another internal table

Oct 20, 2016 at 05:01 PM

87

avatar image
Former Member

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 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Oct 20, 2016 at 05:59 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Cool. I used modify table later in order to send it_column back to it_row. That worked, thanks!

0
Chandra Indukuri Oct 20, 2016 at 06:05 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded