inetphantom
inetphantom

Reputation: 2617

How to loop at Table only having ref to data

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:

Both did not work.

Upvotes: 2

Views: 13482

Answers (2)

inetphantom
inetphantom

Reputation: 2617

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.

Upvotes: 4

Leelaprasad Kolapalli
Leelaprasad Kolapalli

Reputation: 27

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.

Upvotes: 0

Related Questions