+ -

Pages

Saturday, July 26, 2014

Dynamic assignment of fields in a structure

In this example we reads info type 0027 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_p0027 TYPE STANDARD TABLE OF p0027,
    wa_p0027 TYPE p0027.


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           = '0027'
      begda           = '20070131'
      endda           = '20070131'
    TABLES
      infty_tab       = it_p0027
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.
  
LOOP at it_p0027 into wa_p0027.
    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_p0027 to <fs>.
     write: / <fs>.
    ENDDO.
  ENDLOOP.


5 ABAP Tips: Dynamic assignment of fields in a structure In this example we reads info type 0027 which contains the fields KST01, KST02…..KST25 We want to write the contents of KST01, KST02…..KST...

No comments:

Post a Comment

< >