"In ABAP it is very convenient to run a report using a Variant. Basically a report can have several Variants linked to it. If you use a variant then the data entry time is reduced considerably and this also reduces data entry errors. The load on the ABAP processing is also reduced. To create a Variant you may need the necessary authorizations. Most of the times while testing programs you will need to run a report using a variant and hence having the authorization to create a Variant is necessary. To create a Variant go to the main reporting screen, enter the name of the report for which you want to create the variant and select goto Variants option from the menu. The system displays the initial screen for the Variants. For creating a Variant you need to enter all the mandatory fields. Also you need to give a unique name for the Variant. Follow the naming convention rules. You may have to create several Variants for a particular report. Once a Variant is created you ca also schedule to run the report in the background using this Variant. For each variant that you create you need to give a brief description which will help to explain the purpose of the variant and help to distinguish the various Variants that you have created. You may want to protect your Variant by selecting the Protect Variant option. This option enables only the person who has created the Variant to change or delete it. While Running a report directly from the menu you can use the Run with Variant option and then select the desired variant from the dropdown list. Remember that Variants are report dependant. So to create a Variant you need to first create an ABAP report (Executable Program with selection screen). Once you successfully create all the variants for an ABAP report, you will save considerable amount of time which would otherwise have been spent in entering the same data again and again."
"The flow of a program is determined by a sequence of screens in a dialog transaction. The screens that are called within a transaction, must belong to a single ABAP program, usually a module pool (Type M). You have to use the transaction maintenance transaction (SE93) to create a dialog transaction. Once you have entered a transaction code and a short description, chose transaction type program and screen. Then enter data on the next screen as required. The transaction code in a dialog program must be linked to the number of its initial screen. Finally enter this number in the screen number field."
For any ABAP Report or an executable giving the selection criterion is important. Presenting the user with selection screen is very easy using Select-Options and Parameters in SAP ABAP.
The basic for of Select-Options in SAP ABAP is as follows.
Select-options: s_vbeln for vbak-vbeln.
In the above statement s_vbeln is defined as an internal table. And it has the following fields.
SIGN: I OPTION: EQ LOW: 4969 HIGH: _________________________________________
In case the user enters a range from 4969 to 4977 then the output of the above code is
SIGN: I OPTION: BT LOW: 4969 HIGH: 4977 _______________________________________________
In case the user enters only selected values as 4969, 4970, 4971, 4972 the the output will be as follows.
SIGN: I OPTION: EQ LOW: 4969 HIGH: SIGN: I OPTION: EQ LOW: 4970 HIGH: SIGN: I OPTION: EQ LOW: 4971 HIGH: SIGN: I OPTION: EQ LOW: 4972 HIGH: SIGN: I OPTION: EQ LOW: 4973 HIGH: ______________________________________________
Note: The output shown above is for the internal table of select options. The result of the selected Sales Order will be different. You can run the code given above and see the output.
Many a times it is required to extract data from several tables this can be a time consuming process. To simplify the process and to increase the efficiency of the code, you can define a VIEW. Data is not stored in a VIEW physically. Here data is combined from several tables, but the data is stored in their respective tables. As the name goes a VIEW is just a VIEW of the selected/desired fields from a number of tables. Fields that are not required are hidden. For example if data needs to be extracted from 5 tables with desired fields, then you can create a VIEW of the required fields.
In SAP ABAP a VIEW can be defined in the following ways.
1) By masking one or more fields from a Table. 2) By Linking tables with a Rational Join Operation 3) By defining join condition from a foreign key defined between the tables
In part 1 SAP ABAP Creating a Material using a BAPI Part 1we have seen how to get the next Material Number. In this Part we will see the parameters that need to be passed for creating the actual Material. For simplicity let us keep the number of parameters to minimum. We will just pass the mandatory fields as per the system that I am using. Please note that you need to pass the Material Number Obtained in the previous Part. Also make sure that you run the following BAPIs in the Order shown below.
To create a Material in SAP using a BAPI you need to use the following 2 BAPIs
BAPI_MATERIAL_GETINTNUMBER _______________________________________________ Pass the Material Number obtained from the above BAPI to the following BAPI _______________________________________________
In SAP ABAP you can create a Material using a BAPI. To do so you first need to get the Next Material Number. This can be obtained by using the following BAPI.
To create a Material in SAP using a BAPI you need to use the following 2 BAPIs
BAPI_MATERIAL_GETINTNUMBER
BAPI_MATERIAL_SAVEDATA
If you are suing the transaction MM01 to create a Material, you can see the Material Number being assigned automatically. If you have not noticed this please run the transaction MM01 and enter the values in the initial screen. After hitting enter you will see the Material Number appear in the next screen automatically.
Let us now see the parameters that need to be passed to the BAPI BAPI_MATERIAL_GETINTNUMBER.
The Mandatory Parameters that need to be passed to the BAPI are as follows.
Material Type Industry Sector Required Numbers
Enter the desired values and generate the Next Material Number. Once you obtain the Material Number, you then need to pass this number to the following BAPI.
BAPI to create Material in SAP
BAPI_MATERIAL_SAVEDATA
The following program demonstrates the BAPI BAPI_MATERIAL_GETINTNUMBER
REPORT ZEX_GETMATNUM .
Parameters: p_matype like BAPIMATDOA-MATL_TYPE, p_indsr like BAPIMATDOA-IND_SECTOR, p_reqnum like BAPIMATALL-REQ_NUMBERS.
Material Type HAWA Industry Sector C Required Numbers 1
See Also: SAP ABAP Creating a Material using a BAPI Part 2 ____________________________________________________________________________________________________________________________________________________________________
Always specify your conditions in the Where-clause instead of checking
them yourself with check statements. The database system can then use an index
(if possible) and the network load is considerably less.
Always use Pretty Printer and Extended Program Check before releasing the code.
Do not leave unused code in the program. Comment the code thoroughly. Align the comments and the Code. Follow the SAP Standards and SAP Best Practices guidelines. It’s a good practice to take a dump of the code on your local drive.