Welcome to Sets & SetIDs in SAP

Dear SAP consultants,

Through this blog, I wish to share with you all, a very useful SAP concept called Sets and SetIds.
A set is a group of data objects in SAP, that can either be included or excluded in a selection.  The set is identified by a SetId, which is a unique name that is assigned by the SAP user.
For a example, if you always want to exclude a group of vendors from being printed in a report, this could be achieved by including those vendor codes in a set. Or if you want certain validations in a particular transaction to work only for a group of users, the same could be achieved by including those vendors in a set.
The number and type of such applications are endless.
Create Set Ids:  

SetIds are created in SAP using the transaction GS01.
In the initial screen, specify a name for SetId; for example, for a list of vendors who are to be included in Automatic Purchase order creation, you can give a name “AUTO-PO-VENDORS”;
Then, specify the table and field name that will form the basis for inclusion/exclusion.
For example, for a setid of vendor codes, enter the value LFA1 for table LIFNR for field.
In the details screen, enter single values or ranges.
For example, you could either enter individual vendor codes like
A74512
B14324
F76581
or enter multiple ranges for vendor codes like
1AAAAA to 1ZZZZZ
5AAAAA to 5ZZZZZ
 as shown below and then save the set details.
Maintain set ids:
You can further add to / modify / delete information from an existing set using SAP transaction GS02.
For example, you could add individual vendor codes like 777111 & 777222 as shown below.
Display Set ids:
You can display a setid using SAP transaction GS03.
Implementation of a Set Id:
Set Ids are usually implemented using ABAP coding, typically with user exits.
For example, for implementing a logic for “Automatic creation of Purchase Order from Purchase Requisitions”,  where only vendors who belong to the set id “AUTO-PO-VENDORS” are to be considered, the select statement that fetches the list of PRs for PO creation needs to be modified to allow only those PRs who have a vendor (source) assigned to them that belongs to the set id “AUTO-PO-VENDORS”.
For example, you could have implement an user exit with an include that has code as below:
select single valfrom
into corresponding fields of wa_setleaf
from setleaf
where setclass = ‘0000’
and setname = ‘AUTO-PO-VENDORS’
and valfrom = i_cekko_lifnr.
 
if sy_subrc = 0.
  po_auto_create = ‘yes’
endif
 
This would mean only those vendors included in the setid mentioned will be considered for automatic PO creation.
 
Relevance of Set Id for functional and technical SAP consultants:
Set Ids in SAP are relevant for both functional and technical consultants alike.
In many cases, the functional consultant may create Set Ids to satisfy specific business requirements. They then tell the technical consultant to implement the business logic using the particular set id.
In other cases, technical consultants/ABAP resources may also create Set Ids in order to avoid unnecessary hard-coding of values for specific program variables.

Leave a comment