Skip to Content
avatar image
Former Member

Looping field symbol

Hello

LOOP AT <datatable> ASSIGNING/Into <wa_datatable>.

Endloop.

<datatable> having multiple records of matnr.

I want to get each value of matnr(<wa_datatable>-matnr and used for futher processing.

I am trying to access using <wa_datatable>-matnr but showing error.

error.png (8.9 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 22, 2016 at 07:43 PM

    Hi Mohan,

    Use Assign statement like below

    TYPES : BEGIN OF ty_makt,
    matnr TYPE makt-matnr,
    spras TYPE makt-spras,
    maktx TYPE makt-maktx,
    maktg TYPE makt-maktg,
    END OF ty_makt.

    DATA : lt_makt TYPE TABLE OF ty_makt.

    FIELD-SYMBOLS : <fs_makt> TYPE any,
    <fs_matnr> TYPE any.

    SELECT matnr
    spras
    maktx
    maktg
    FROM makt
    INTO TABLE lt_makt
    UP TO 10 ROWS.

    LOOP AT lt_makt ASSIGNING <fs_makt>.
    IF <fs_makt> IS ASSIGNED.

    ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_makt> TO <fs_matnr>.
    IF <fs_matnr> IS ASSIGNED.
    IF <fs_matnr> = '10000010013'.

    ENDIF.
    ENDIF.
    ENDIF.
    ENDLOOP.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 22, 2016 at 05:19 PM

    Hi Mohan,

    I believe the field-symbol <wa_datatable> shall be declared as follows:

    FIELD-SYMBOLS: <wa_datatable> LIKE LINE OF <datatable>.

    Please try it out and let us known.

    Thanks and bye,

    Flavio

    Add comment
    10|10000 characters needed characters exceeded