Mastering SAP ABAP: Exploring Selection Screens and Classical Reports

 Welcome back everyone, So we have started the concept of Selection Screen in our previous blog, So let’s Continue it.


How To create a Selection Screen block ?

Requirement :- We have to create a selection screen block which consists of two select options and one parameter as given below.



  • Step 1 :- Create a executable program in ABAP Editor.
  • Step 2 :- Follow the below code.

Code :-

*****************************Start Of Selection Screen
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
********************************
*Declaring Parameters
PARAMETERS : p_ono TYPE zar_ono OBLIGATORY.
*Creating Radiobuttons
PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1,
             p_r2 TYPE c RADIOBUTTON GROUP r1 DEFAULT 'X',
             p_r3 TYPE c RADIOBUTTON GROUP r1.
*************
*Creating Checkboxes
PARAMETERS : p_chk1 AS CHECKBOX,
             p_chk2 AS CHECKBOX.
*Creating a select option
DATA : lv_ono TYPE zar_ono.
SELECT-OPTIONS : s_ono FOR lv_ono.
******************************

SELECTION-SCREEN : END OF BLOCK b1.

*End of Selection Screen.
*********************************************


  • Now when you execute this program, you will see all your input fields in a block.



  • You can also give a name to the above block.

    • Activate the program.

    • Click on GOTO → text elements → Text symbols.



    • Use the same name of block which you have given in the above program and activate the program.



    • Now, if you will execute the program, you will see the above given name on the selection screen block.




Parts Of Select Options :-

  • A select-option has 4 parts :-

    • Sign - I/E(Include/Exclude)
    • Option - Relational Operator ( EQ, BT, LT, etc. ).
      • Options has always length of 2.
    • Low :- Low value
    • High :- High Value
  • Select Option is an internal table with header line.

  • You can see it clearly.



    • In the above diagram , we can clearly see all the above parts of select options.

Classical Reports :-

  • Reports are programs that read data from the database, processes the data and displays the data in the required format.
  • It consists of 2 screens - selection screen and output screen.
  • The selection screen is optional.
  • SAP ABAP classical reports are the most basic ABAP reports in which we display the output using WRITE statement.

Let’s Create a Simple Program to understand it more clearly.

Code :-

****************************************************
*Output Parameters
DATA : lv_output type numc3.
*********
*Input Parameters
PARAMETERS : p_input1 type numc2,
             p_input2 type numc2.
*It is very imortant that you should go to text elements
*and give some meaningful name to parameters.

*Performing Operation
lv_output = p_input1 + p_input2.

*Displaying the output
Write : 'The sum is', lv_output.
*******************************************************


Output :-

  • When you will press the execute button, a input screen will appear where you need to enter the input values.



  • Now , press the execute button → A output screen will appear.



  • Since, we have taken the length as 3 of our output variable, therefore it is showing the output in 3 digits.


Open SQL :-

  • SQL stands for Structured Query Language.
  • It is of 2 types :-
    1. Open SQL :- Open SQL is database independent.
    2. Native SQL :- Native SQL is database dependent, Syntax of query will vary for every database.

Let’s develop a requirement using a classical requirement.

Requirement :- Suppose, Our user wants us to develop a report which takes order number as input and shows the details of the order number as output.

  • Suppose, this is our custom table, and we will be taking order number as input and will be displaying the details of that order number as output.


  • Step1 :- Create a executable program in ABAP Editor.
  • Step 2 :- Give a parameter which takes order number as input.
  • Step 3: create a type structure for the above table and create internal table and work area for it.
  • Step 4 :- Perform a select query and load the data into the internal table.
  • Step 5 :- Loop the internal table into work area and display the output on the output screen using write statement.

Code :-

****************************************************
*Start of Program
**Declaring the type structure
TYPES: BEGIN OF ty_header,
         order_no     TYPE  zar_ono,
         order_date   TYPE zar_odate,
         payment_mode TYPE zar_pm,
         total_amount TYPE zar_tc,
         currency     TYPE zar_cur,
       END OF ty_header.

***Declaring the internal table and work area
DATA : lt_header type table of ty_header,
       ls_header type ty_header.

*Declaring the Parameter
PARAMETERS : p_ono type zar_ono.

****Perform the Select Query.
Select ORDER_NO
       ORDER_DATE
       PAYMENT_MODE
       TOTAL_AMOUNT
       CURRENCY
     from ZAR_ORDER_HEADER into table
     lt_header where ORDER_NO = p_ono.
  if lt_header is not INITIAL.
*Displaying the output
    loop at lt_header into ls_header.
    Write : 'The details are : ',
            ls_header-ORDER_NO,
            ls_header-ORDER_DATE,
            ls_header-PAYMENT_MODE,
            ls_header-TOTAL_AMOUNT,
            ls_header-CURRENCY.
    endloop.
  endif.
*End of Program
**********************************************************
  • Execute the Program


  • Execute the input screen.

Output :-




So, that’s enough for today.

We will create some complex reports in our next blog.

Thanx alot for being a part of this wonderful journey.

Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming