Building ABAP Program sometimes you need store your maintain configuration data for your ABAP Program in the Z Table with maintenance. Definetely that is the best approaching but if you have only some of configuration data, you can use Sets for your configuration data.
What is Sets in SAP
Sets is a list of data which is widely used in report writer, substitution/validation and ABAP Program. So maintaining ABAP Program to be efficiently and effectively.
You don’t need hardcode in ABAP Code only for validation like IF GV_MART = ‘001’, but you only need put syntax IF GV_MART IN ZSET. and you can add or delete your value of Sets later without changing your ABAP Program.
There are 4 Types of Sets in SAP
This is basic set is use to kept value for one dimension in one set. for example you can save value of VBAK-AUART ZIN, ZPP in one set.
This set is used to build hierarchy so you can combining basic set into one set.
This set is used to combine basic set or single set into one set.
4. Key Figure
This set is used for report painter.
How to create Sets in SAP
In this article i will show you how to create Basic Sets for Sales Document Type ( VBAK-AUART ) and use it in ABAP Program. Here the step.
1. Go to GS01 Transaction code.
In this transaction please entered your Set Name and Table name that contain dimension set value, and choose Basic Set as Set Type and press ENTER.
The popup screen will appear, in this popup screen you need to entered name of field for this sample entered AUART and press ENTER.
After you press ENTER. The next screen you can entered your value of set.
You can display, maintain and delete Set SAP via GS02 ( Change ) , GS03 ( Display ) and GS04 ( Delete ).
Using Sets in ABAP
You can read SAP Sets value via G_SET_GET_ALL_VALUES or G_SET_GET_ID_FROM_NAME and G_SET_FETCH.
DATA: gv_setid LIKE sethier-setid,
gt_values TYPE STANDARD TABLE OF rgsbv.
CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
shortname = 'ZAUART'
new_setid = gv_setid
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 EQ 0.
CALL FUNCTION 'G_SET_FETCH'
setnr = gv_setid
set_lines_basic = gt_values
no_authority = 1
set_is_broken = 2
set_not_found = 3
OTHERS = 4.
MESSAGE 'Sets not found' TYPE 'E'.
You can see debug result.