How to read SET values in SAP ABAP
June 08, 2026SET is created in SAP using GS01.
Below code section there two function module have used.
G_SET_GET_ID_FROM_NAME use to fetch the internal set id number.
G_SET_GET_ALL_VALUES use to get the actual set values by passing the internal set id number
Code :
DATA: lv_new_setid TYPE sethier-setid,
it_set_values TYPE STANDARD TABLE OF rgsb4.
CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
EXPORTING
shortname = 'ZCUSTOMER'
IMPORTING
new_setid = lv_new_setid
EXCEPTIONS
no_set_found = 1
no_set_picked_from_popup = 2
wrong_class = 3
wrong_subclass = 4
table_field_not_found = 5
fields_dont_match = 6
set_is_empty = 7
formula_in_set = 8
set_is_dynamic = 9
OTHERS = 10.
IF sy-subrc = 0.
CALL FUNCTION 'G_SET_GET_ALL_VALUES'
EXPORTING
setnr = lv_new_setid
TABLES
set_values = it_set_values
EXCEPTIONS
set_not_found = 1
OTHERS = 2.
ENDIF.
LOOP AT it_set_values INTO DATA(wa_set_value).
WRITE:/ wa_set_value-from.
ENDLOOP.
IDE Used To Test This Code : SAP ABAP Editor.
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.
Post a Comment