DATA:
lt_level TYPE STANDARD TABLE OF pt1252,
lt_plant TYPE STANDARD TABLE OF werks, " Final plant itab
lv_plant_low TYPE werks,
lv_plant_high TYPE werks.
FIELD-SYMBOLS:
<fs_level> LIKE LINE OF lt_level,
<fs_plant> LIKE LINE OF lt_plant.
CALL FUNCTION 'PRGN_1252_READ_ORG_LEVELS'
EXPORTING
activity_group = '/Your_Name_Space/Role_name'
TABLES
org_levels = lt_level
EXCEPTIONS
no_data_available = 1.
LOOP AT lt_level ASSIGNING <fs_level> WHERE varbl EQ '$WERKS'.
IF ( <fs_level>-low IS NOT INITIAL ) AND ( <fs_level>-high IS INITIAL ).
APPEND <fs_level>-low TO lt_plant.
ELSEIF ( <fs_level>-low IS NOT INITIAL ) AND ( <fs_level>-high IS NOT INITIAL ).
IF <fs_level>-low < <fs_level>-high.
lv_plant_low = <fs_level>-low.
lv_plant_high = <fs_level>-high.
WHILE lv_plant_low <= lv_plant_high.
APPEND lv_plant_low TO lt_plant.
lv_plant_low = lv_plant_low + 1.
ENDWHILE.
ELSE.
APPEND <fs_level>-low TO lt_plant.
ENDIF.
ENDIF.
ENDLOOP.
lt_level TYPE STANDARD TABLE OF pt1252,
lt_plant TYPE STANDARD TABLE OF werks, " Final plant itab
lv_plant_low TYPE werks,
lv_plant_high TYPE werks.
FIELD-SYMBOLS:
<fs_level> LIKE LINE OF lt_level,
<fs_plant> LIKE LINE OF lt_plant.
CALL FUNCTION 'PRGN_1252_READ_ORG_LEVELS'
EXPORTING
activity_group = '/Your_Name_Space/Role_name'
TABLES
org_levels = lt_level
EXCEPTIONS
no_data_available = 1.
LOOP AT lt_level ASSIGNING <fs_level> WHERE varbl EQ '$WERKS'.
IF ( <fs_level>-low IS NOT INITIAL ) AND ( <fs_level>-high IS INITIAL ).
APPEND <fs_level>-low TO lt_plant.
ELSEIF ( <fs_level>-low IS NOT INITIAL ) AND ( <fs_level>-high IS NOT INITIAL ).
IF <fs_level>-low < <fs_level>-high.
lv_plant_low = <fs_level>-low.
lv_plant_high = <fs_level>-high.
WHILE lv_plant_low <= lv_plant_high.
APPEND lv_plant_low TO lt_plant.
lv_plant_low = lv_plant_low + 1.
ENDWHILE.
ELSE.
APPEND <fs_level>-low TO lt_plant.
ENDIF.
ENDIF.
ENDLOOP.