Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

loop at internal table

Former Member
0 Likes
1,166

hi,

in genral we loop by row like

loop at itab

-


end loop

my requirement is to loop itab by column

can any one give me idea

its urgent...............

8 REPLIES 8
Read only

Former Member
0 Likes
1,037

There is nothing like looping by column. Once you have read a record of the table into work area, you have access to all the fields of that internal table.

What do you want to do?

Read only

Former Member
0 Likes
1,037

Hi,

It is NOT Possible. You need to LOOP by Rows only and then you can do your processing for each column.

Regards,

Atish

Read only

Former Member
0 Likes
1,037

Turn the internal table "on it's side"... and then loop thru it as needed.

Read only

ferry_lianto
Active Contributor
0 Likes
1,037

Hi,

You can not loop by column.

But you can sort the internal table by column (ascending or descending order) prior to loop.

Regards,

Ferry Lianto

Read only

0 Likes
1,037

You could loop at the columns by using Field-symbols.

Basically DESCRIBE the structure and loop thru its components.

You would then loop thru column using the currently, assigned Field-symbola nd then address each row as neede (using a LOOP or READ TABLE with wan INDEX).

Read only

marcelo_ramos1
SAP Mentor
SAP Mentor
0 Likes
1,037

Hi,

Doesn't exists columns loop, but you can do as follow.


DATA: ttable TYPE TABLE OF mara WITH HEADER LINE.

FIELD-SYMBOLS <field> TYPE ANY.

LOOP AT ttable.

" Each column of ttable is moved to <field>
  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE ttable TO <field>.

    IF sy-subrc IS INITIAL.
      WRITE <field>. "Here is a column value
    ELSE. 
      EXIT." Exit when all collumn is processed
    ENDIF.
  ENDDO.

ENDLOOP.

<b>Don't forget to close this Thread and reward points for useful answers when your question be answered.</b>

Regards.

Marcelo Ramos

Read only

Former Member
0 Likes
1,037

i want to loop by column but as all replied that there is no such process i have to see some other way

Read only

0 Likes
1,037

Not really true.... there is no pre-built option for this.

You could use FIELD-SYMBOLS as mentioned above and take a snapshot of the internal table's struecture (meaning the columns) and then LOOP thru the columns first then read the rows.

But it is true that ABAP does not "naturally" support your needs.