2

I am using the function Module RSAQ_QUERY_CALL, getting back a table:

DATA: gr_data TYPE REF TO data.

CALL FUNCTION 'RSAQ_QUERY_CALL'
     EXPORTING
       query          = 'ZXXXXXXXX'
       usergroup      = 'XXX'
       VARIANT        = 'TEST'
       SKIP_SELSCREEN = 'X'
       DATA_TO_MEMORY = 'X'
     IMPORTING
       ref_to_ldata   = gr_data
     EXCEPTIONS
       OTHERS         = 11.

Now how can I loop at that table?

What I tried:

  • assign to a field symbol
  • passing a field symbol instead of dref

Both did not work.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
inetphantom
  • 2,498
  • 4
  • 38
  • 61
  • Which code did you try, what were the issues / error messages? – vwegert Sep 05 '16 at 13:04
  • My tries were very nooby, I got syntax errors and messages of type-incompatibility. I deleted those tries, searching for other possibilities and found none, since the structure of the Table is not fix – inetphantom Sep 05 '16 at 13:08

2 Answers2

4

I found the solution (after asking the senior dev..)

FIELD-SYMBOLS: <gt_data> type table,
               <row>     type any.

ASSIGN gr_data->* to <gt_data>.

LOOP AT <gt_data> ASSIGNING <row>.

  DO.
    ASSIGN COMPONENT sy-index OF STRUCTURE <row> TO <field>.
    IF sy-subrc <> 0.
      EXIT. " last field of row
    ENDIF.

    WRITE : / 'Field', sy-index, ':', <field>.

  ENDDO.
    
ENDLOOP.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
inetphantom
  • 2,498
  • 4
  • 38
  • 61
  • 1
    If You want to do it typesafe, You can use ABAP RTTS class-methods, which work like a factory. The table can be inspected. Then You could receive the type of the table, and in the next step You could create a structure or fieldsymbol based on the structure-type of the table. Nice generic stuff can be done by that. – icbytes Sep 05 '16 at 15:08
0

Refer this code:

    FIELD-SYMBOLS: <gt_data> type table,
                   <fs_value> type any.
    ASSIGN gref_data->* to <gt_data>.
    LOOP AT <gt_data> ASSIGNING <fs_value>.
         write:<fs_value>.                 "Here you will get row by row
    ENDLOOP.