Wednesday, April 9, 2008

Creating a Variant for ABAP Program

Creating a Variant for SAP ABAP Programs/Reports

Variants can be used when you need to run a Report (Any ABAP Executable program) with different selection criterion. For example if you have a report that needs to be run for Western Region/Easter Region or for different company codes/ Sales Areas. It becomes tedious to enter the selection criterion again and again. Also some reports need to be run in the background. You can schedule to run the report in the back ground with a variant.

To create a variant please follow the steps given below.

Run Transaction SE38
Enter the Report Name
Run the Report once the selection screen is displayed click on save.




Click on Save



Enter the Variant name and a short description.

You can create multiple variants for a single report. Once the variants are created you can then choose the variant that you wish to run and then run the report.

Please see the figure below.

Click on the Variant button


Choose the Variant

SAP ABAP Converting from Upper Case to Lower Case

SAP ABAP Converting from Upper Case to Lower Case

SAP ABAP Translate Statement

In ABAP we can use TRANSLATE statement to change the case of characters. This means that if you want to  programatically convert any characters to upper case or to lower case then it can be done using the TRANSLATE statement.

There is another variation of  TRANSLATE statement in which you can translate characters in STRING1 as per the rules given in STRING2.

Please see the examples given below.

DATA: d_PH(17) VALUE 'PeAcEaNdHaRmOny',
d_Translate LIKE d_PH,
RULE(30) VALUE 'PHeEAAcLETaHNYdLHIaVRImNOGn y '.

d_Translate = d_PH.
WRITE d_Translate.

TRANSLATE d_Translate TO UPPER CASE.
WRITE / d_Translate.

d_Translate = d_PH.
TRANSLATE d_Translate TO LOWER CASE.
WRITE / d_Translate.

d_Translate = d_PH.
TRANSLATE d_Translate USING RULE.
WRITE / d_Translate.

Output of the above code will be as follows.

Translate examples   
                     
PeAcEaNdHaRmOny      
PEACEANDHARMONY      
peaceandharmony      
HEALTHYLIHING