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 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.