If you want tailor any SAP transaction or report, then you should know how to create variant in SAP. Variants, which are used to customize SAP standard transactions in order to ensure the transaction fits the business needs of your company, are known as transaction variants. You can use variants of that nature to hide screens, menu functions, and fields among other things.
The following naming convention has been conceived for use within the SAP namespace: If you do not observe the naming conventions for object types (classes and interfaces), conflicts will occur when the system creates persistent classes, since it will be unable to generate the necessary co-classes.
On the other hand, variants that are used for saving selection field values in reports are known as report variants. You should learn how to create a variant in SAP regardless of whether you want to utilize report variants or transaction variants. The best approach would be to learn how to do both so that you can use whichever you prefer when the necessity arises. How to Create Variant in SAP Before you start the process of creating a transaction variant, you need to define the selection screen for the program in which the variant will be created. All types except S are allowed for the program you intend to use. You can use the transaction code SHD0 to create the transaction variant.
You need to access the Initial Screen of the ABAP Editor. You can then create the name of program in which the variant is to be created. Once you select the program, select the Variants option, and then select Change.
The Variant Maintenance Initial Screen will then come up. You can then input the name of the variant that you intend to create. There is a convention for naming variants, which you must follow.
First, you can use a name that has up to 14 alphanumeric characters. You should never use% as one of the characters though. The only time you can use & within the characters is when you want to create a system variant.
This variant allows for automatic transportation of the program and the variant. Once you input the variant name, you should select the Create option. If the program in which you want to create a variant has only one selection screen, then that screen will appear.
However, if a program has more than one screen of this kind, a screen assignment dialog box will appear with a list of the available selection screens. You then need to select one or more selection screens in which the variant will be created.
After screen selection, you need to select the Continue option. This option appears on the last selection screen in a program where you have multiple selection screens. After that, you need to input the selection values that you desire. These values can include dynamic and multiple selections.
After inputting the required values, select the Continue option. The ABAP: Save Variant overview screen will then appear. You will be required to save the attributes of your variants before saving them. Variant attributes: what are they? Many variant attributes exist. You need to ensure that you select the right ones when creating variants because they will help define their characteristics. You will need to input a short Description of the variant.
It needs to be meaningful. If you want your variant to be ready to use for background processing but not in a dialog mode, select the Only for Background Processing field. If you do not want other users of the system to change your variant, then select the Protect Variant field. If you want the name of your variant to be displayed on the variant catalog, select the Only Display in Catalog. However, this option will prevent the users from seeing the name displayed if they use the F4 help value, so bear that in mind. On the Type section, you can indicate whether a field is a Selection Option (S) or Parameter (P) type. In order for you to write protect certain fields on the selection screen; you need to select the Protected column for individual selections that you want to make.
After that, no user can make any inputs or changes to your protected variant. If you select the Invisible column, then the selected fields on the selection screen will be hidden by the system. The Selection Variable attribute allows the selection value at runtime to be set in a dynamic way. There are other variant attributes.
However, the above listed are important and may be selected or not during the creation of a variant. After they have been set, the variant can then be saved, and used later on.
Creating Report Variants When learning how to create variant in SAP, bear in mind that report variants can be created even before a report has been created. You can choose to use a transaction code: /nzstm, or follow the right navigation path 1. You need to use the following navigation path: User menuRole ZMITReports 2. When you select Reports, you need to select the type of report for which you are making a variant. Once you select the report, you need to input the values that should go into the various fields of the report.
Select the Save as Variant option. An ABAP window will appear. On the ABAP window that appears input the variant name that you desire. The name must follow all the necessary conventions. You need to input a Description attribute. The description should make it easy for other users to identify the variant that you have created.
Accept the default option in the field: Created for Selection Screens. You can also select the Protect Variant attribute option if you want to prevent unauthorized users from being able to change your report variant. Click on the Save option and the variant will be saved.
Bottom Line The process of creating variants is not very difficult provided you follow all the instruction. You must however, take care to follow the naming conventions. You should also select the right attributes. The attributes that you select for the variants that you create, will affect those variants and any data that comes after the creation process. When you learn how to create variant in SAP, you will be able to tailor some standard reports and transactions to suit your business needs properly.
Creating code inspector Check Variant for client specific naming conventions Many times while developing an object we need to follow client specific naming conventions,development guidelines etc. Here we will check how to create client specific check variant for code inspector. 1.Creating Check Variant 1.a) Run transaction SCI Enter Check Variant name and press C reate button. 1.b) Next screen will display list of checks. For defining naming convention standards go to Programming Conventions → Naming Conventions and click on arrow.
1.c) Enter naming conventions here. 1.d)If required define other checks also(performance checks, Security checks etc ) and save variant. If ‘Performance Checks→ SELECTs in Loops’ is selected, code inspector will search select statements in loops. Creating Inspection. We will check code inspector results for below sample code REPORT zsktest.Structure with correct naming convention TYPES: BEGIN OF tystruct1, matnr TYPE marc-matnr, werks TYPE marc-werks, END OF tystruct1.Structure with wrong naming convention TYPES: BEGIN OF struct2, matnr TYPE marc-matnr, werks TYPE marc-werks, END OF struct2.Internal table declaration DATA: ttab1 TYPE STANDARD TABLE OF tystruct1, ttab2 TYPE STANDARD TABLE OF struct2. CONSTANTS: cconst1 TYPE char1 VALUE 'A', 'Incorrect naming convention coconst2 TYPE char1 VALUE 'B'.' Correct naming convention DATA: var1 TYPE char1.
'Variable with incorrect naming convention SELECTION-SCREEN: BEGIN OF BLOCK b1. SELECT matnr werks FROM marc INTO TABLE ttab1 WHERE matnr IN smatnr AND werks = prwerks.
2.a)Enter Inspection name and click on create button. In Object Selection enter program name. We can run code inspector for multiple objects also. For multiple objects create Object Set first and enter object set name here.
In Check Variant enter variant name. Click on Execute(F8) button. 2.b) Checking inspection Results Click on ‘Results’ button as shown below.