cancel
Showing results for 
Search instead for 
Did you mean: 

Abap Dynamic Variable

Former Member
0 Kudos

Hallo!

I would be grateful for any advice.

I need to check 80 columns and I want to turn it into 80 lines.

Can this be done dynamically?

Thank you in advance

LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>.

      IF <source_fields>-zzabrsn001 <> ''.

        RESULT_FIELDS-/bic/zrvk_mita = <source_fields>-objid.

        RESULT_FIELDS-/bic/zrvk_abre = <source_fields>-zzabrsn001.

        APPEND RESULT_FIELDS TO RESULT_PACKAGE.

        CLEAR RESULT_FIELDS.

      ENDIF.

      IF <source_fields>-zzabrsn002 <> ''.

        RESULT_FIELDS-/bic/zrvk_mita = <source_fields>-objid.

        RESULT_FIELDS-/bic/zrvk_abre = <source_fields>-zzabrsn002.

        APPEND RESULT_FIELDS TO RESULT_PACKAGE.

        CLEAR RESULT_FIELDS.

      ENDIF.

      IF <source_fields>-zzabrsn003 <> ''.

        RESULT_FIELDS-/bic/zrvk_mita = <source_fields>-objid.

        RESULT_FIELDS-/bic/zrvk_abre = <source_fields>-zzabrsn003.

        APPEND RESULT_FIELDS TO RESULT_PACKAGE.

        CLEAR RESULT_FIELDS.

      ENDIF.

      IF <source_fields>-zzabrsn004 <> ''.

        RESULT_FIELDS-/bic/zrvk_mita = <source_fields>-objid.

        RESULT_FIELDS-/bic/zrvk_abre = <source_fields>-zzabrsn004.

        APPEND RESULT_FIELDS TO RESULT_PACKAGE.

        CLEAR RESULT_FIELDS.

      ENDIF.

     ...

     ...

     IF <source_fields>-zzabrsn080 <> ''.

        RESULT_FIELDS-/bic/zrvk_mita = <source_fields>-objid.

        RESULT_FIELDS-/bic/zrvk_abre = <source_fields>-zzabrsn080.

        APPEND RESULT_FIELDS TO RESULT_PACKAGE.

        CLEAR RESULT_FIELDS.

      ENDIF.

    ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

egenoves
Participant
0 Kudos

Hi Alexey,

Use the statement ASSING COMPONENT of STRUCTURE To ....

Show an example:

   LOOP AT table into wa_table.

     DO 80 TIMES.

         ASSIGN COMPONENT sy-index of STRUCTURE wa_table to <fs>.

         if sy-subrc eq 0.

           "do the stuff <fs> contains the n-index field

         endif.

      Enddo.

   endloop.


Hope it helps,

regards

Answers (1)

Answers (1)

raymond_giuseppi
Active Contributor
0 Kudos

Use some ASSIGN COMPONENT to field symbols in a DO 80 TIMES.

(There was also the DO VARYING statement but this syntax is now "obsolete")

Regards,

Raymond