"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."
"SAP has provided two different types of methods for BDC to do its work. Among these the first one is called the classical method. This method is also called as the session method. Through this method the data can be read by the BDC program from a sequential dataset file. This sequential dataset file is stored in batch-input sessions. In order to run the transaction in this session, What you need is to execute the session. For this follow these few steps. YOu an start and subsequently monitor the sessions firstly from System----> Service---->Batch input or have the sessions run in the background."
We have seen how to do version management in SAP ABAP. It is always better to take a backup of all the ABAP development in the form of a txt file. You can take a backup on your local harddisk (Presentation Server) and then store it in a safe place. Once you download the program it can also be uploaded in the system with the same name or with a different name. Please follow the menu path as shown below to download/upload your program.
In ABAP HIDE is an important technique and is used in interactive reporting. The HIDE statement defines the information that needs to be passed to the subsequent lists.
We will see a very simple example of the HIDE statement to understand the concept. In this example we will select the Header data of all the sales order into an internal table. We will then display only the customer numbers. Once the user clicks on the customer number the Following information will be displayed as the Secondary list.
CUSTOMER NUMBER PURCHASE ORDER NUMBER SALES ORDER NUMBER SALES ORGANIZATION DISTRIBUTION CHANNEL DIVISION
To achieve this we will hide the above mentioned fields using the HIDE statement. The Program is given below.
REPORT ZEX_HIDE . *&---------------------------------------------------------------------* *& ABAPLOVERS THE HIDE STATEMENT *&---------------------------------------------------------------------*
* Tables TABLES VBAK. * Internal table DATA int_VBAK LIKE VBAK OCCURS 100 WITH HEADER LINE. * Processing data START-OF-SELECTION.
SELECT * FROM VBAK INTO TABLE INT_VBAK.
LOOP AT int_vbak. WRITE / int_vbak-kunnr HOTSPOT ON. HIDE: int_VBAK-VBELN, int_VBAK-KUNNR, int_VBAK-BSTNK, int_VBAK-VKORG, int_VBAK-VTWEG, int_VBAK-SPART.
ENDLOOP.
* Secondary List AT LINE-SELECTION. WRITE: / 'Sales Order Details', int_VBAK-KUNNR, int_VBAK-BSTNK, int_VBAK-VBELN, int_VBAK-VKORG, int_VBAK-VTWEG,
SAP ABAP Function Module to add Days Months and Years to a Date
Consider a scenario where you want to add days, months and years to the date field. You can either write custom code to achieve the desired result or use a standard function module provided by SAP. It is always a best practice to use a standard function module as it save time and effort. Also the standard function modules have already been tested by SAP and they give you the desired result. The resulting code is easier to maintain.
The following function module can be used to achieve the desired result.
RP_CALC_DATE_IN_INTERVAL
Please see the code given below
REPORT ZEX_ADDDAYSMONTHSYEARS .
Parameters: p_date like P0001-BEGDA, p_days like T5A4A-DLYDY, p_mons like T5A4A-DLYMO, p_yrs like T5A4A-DLYYR, p_date1 like P0001-BEGDA.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL' EXPORTING DATE = p_date DAYS = p_days MONTHS = p_mons SIGNUM = '+' YEARS = p_yrs IMPORTING CALC_DATE = p_date1 .
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.