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.

2
  • Which code did you try, what were the issues / error messages?
    – vwegert
    Sep 5, 2016 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 Sep 5, 2016 at 13:08

2 Answers 2

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.
1
  • 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 5, 2016 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.