Working with SETs GS01/GS02/GS03

when working on Custom programs we sometimes end up using Hard-coded values in check conditions, select conditions etc … There is a lot of methods to avoid Hardcoded values as using TVARVC table or create a custom table There is also Sets.

In this Tips and tricks blog post I will show you how to create a SET and use it in your Custom program.

 

 

tips9_img06
Transaction GS03

 

In this example i will create a SET containing the list of plants and then I will read the data in a custom program and use them in a CHECK condition.

 

 Create a SET using Transaction GS01

 Go to transaction GS01 and populate the Set Name , the Table Name and click enter .

 

tips9_img01

 

Populate the field name.

 

tips9_img02

 

Populate the set values and save.

 

tips9_img03

 

When you save the Set the system will not ask you to create a Transport Request so you need to do it manually I will show you later how to create a transport request for a SET.

 

Change a Set using Transaction GS02

 

Go to transaction GS02, specify the set name and hit Enter.

 

tips9_img04

 

Here you can change the values of your set and save.

 

tips9_img05

 

 

Display a Set using transaction GS03

 

Go to transaction GS03, specify the Set name and hit enter.

 

tips9_img06

 

 

Call a SET in a program

 

Source Code

 

 REPORT Z_RIM_ABASSI.

TABLES: MARC.

DATA: GT_WERKS LIKE RGSB4 OCCURS 0 WITH HEADER LINE.


*-- Create a range to store the data from the Set
RANGES: R_WERKS FOR MARC-WERKS.

*-- Read the set
CALL FUNCTION 'G_SET_GET_ALL_VALUES'
  EXPORTING
  SETNR = '0000Z_WERKS_SET'
  TABLES
  SET_VALUES = GT_WERKS
  EXCEPTIONS
  SET_NOT_FOUND = 1
  OTHERS = 2.

IF SY-SUBRC <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*-- populate the range
CLEAR R_WERKS[].
R_WERKS-SIGN = 'I'.
R_WERKS-OPTION = 'EQ'.

LOOP AT GT_WERKS.
  R_WERKS-LOW = GT_WERKS-FROM.
  APPEND R_WERKS.
ENDLOOP.

 

How to transport a set

 

Go to transaction GS02 and specify your Set Name

 

tips9_img07

 

Go to utilities -> transport -> Transport Request

 

tips9_img08

 

Select Sets and click on tips9_img10

 

tips9_img09

 

tips9_img11

 

Select the SET and click on execute

tips9_img12

 

Now create your Transport Request

 

tips9_img13

 

 

 

 

 

Leave a comment