Register Login

How we can dynamically assign fields in a structure

Updated May 18, 2018

In this program we reads info type 0022 which contains the fields KST01, KST02…..KST25

We want to write the contents of  KST01, KST02…..KST25 to the screen


REPORT zznfl_test2
       NO STANDARD PAGE HEADING LINE-SIZE 255.

DATA:
    it_p0022 TYPE STANDARD TABLE OF p0022,
    wa_p0022 TYPE p0022.


DATA: l_kst TYPE string, l_count(2) TYPE n.

FIELD-SYMBOLS <fs>TYPE any.

START-OF-SELECTION.


  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr           = '995'
      infty           = '0022'
      begda           = '20070131'
      endda           = '20070131'
    TABLES
      infty_tab       = it_p0022
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.
 
LOOP at it_p0022 into wa_p0022.
    DO 25 TIMES.
      CLEAR l_kst.
      l_count = l_count + 1. ”Counter 01-25
      CONCATENATE 'KST' l_count INTO l_kst. ”KST<counter>

      assign component l_kst of structure wa_p0022 to <fs>.
     write: / <fs>.
    ENDDO.
  ENDLOOP.
 


×