This is the first post in a 5 part series of SAP ABAP Basics. This article aims to provide an in-depth explanation of SAP ABAP along with its architecture and unique features.
This article will cover the following topics:
R/3 stands for Real-Time 3 Tier Architecture. The three layers provided by SAP are namely:
Below is the in-depth look at Work Process.This article will cover the following topics:
- What is SAP?
- What is client in SAP?
- What is SAP ABAP?
- ABAP Program types
- ABAP Data Types
- ABAP list of icons
- What are the system fields in SAP ABAP?
- SAP ABAP rules
- Parameters in SAP ABAP Report
- Using select-options in SAP ABAP
- How to create a checkbox in SAP ABAP
- How to define radio buttons in SAP ABAP
- List of Tcodes in SAP ABAP
What is SAP?
SAP stands for Systems Applications and Products. SAP aims to integrate all the different modules in a company. It is an ERP (Enterprise Resource Planning) software that maintains the centralization of data.R/3 stands for Real-Time 3 Tier Architecture. The three layers provided by SAP are namely:
- Presentation layer: This layer collects input from the user and creates process requests to be passed to the Application layer.
- Application layer: This layer collects all the requests form the Presentation layer and passes these requests to the 'Dispatcher'. The Dispatcher further passes these requests in the Dispatcher queue. It follows the logic of first-in-first-out. The 'Dispatcher queue' further passes these requests to the respective 'Work Processes'. The Work Process is responsible to process those requests given by the Presentation layer. Every Work Process has 2 special small memory areas namely 'User Context' and 'Program Roll'. The User Context stores the information of the user. Program Roll stores the information of the program execution.
- Database layer: This layer is responsible to store data.
Since SAP is R/3 Architecture, all the layers ( Presentation layer, Application layer, and a Database layer) run on separate computers.
Below is the representation of SAP architecture portraying three layers.
Now, let's dive into SAP Logon.
The image showing below is the first screen when you enter into SAP ABAP logon. It usually has four parameters namely: Client, Username, Password, Language.
What is client in SAP?
A client in SAP is a three-digit number (800, 801, 900,...) with independent information. SAP comes with the option of allocating each customer/user to a client, thereby removing the need to provide separate physical systems to each customer. One SAP system can accommodate almost 100 to 200 clients.
The client provides data security. The user with one client can't see the data of the other user with another client.
*&---------------------------------------------------------------------*
*& Report ZRDS1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZRDS1.
DATA : DATE1(8) TYPE D,
TIME1(6) TYPE T,
USER(12) TYPE C,
SCREEN_NO(4) TYPE C,
PAGE_NO(5) TYPE I.
DATE1 = SY-DATUM.
TIME1 = SY-UZEIT.
USER = SY-UNAME.
SCREEN_NO = SY-DYNNR.
PAGE_NO = SY-PAGNO.
WRITE: 'THE DATE IS' , DATE1.
WRITE: / 'THE TIME IS', TIME1.
WRITE: / 'THE USER IS', USER.
WRITE: / 'THE SCREEN NUMBER IS', SCREEN_NO.
WRITE: / 'THE CURRENT LIST PAGE IS', PAGE_NO.
OUTPUT:
While creating select-options, the system creates an internal table by default having the following 4 fields.
The entire SAP runs on these TCODES.
SAP ABAP stands for Advanced Business Application Programming. ABAP is the programming language that runs on the SAP ABAP environment.
SAP ABAP Program types
Below is the complete list of SAP ABAP program types supported by ABAP workbench.
- Executable programs: They are also called as report programs. Reports are created in transaction SE38. Report programs consist of only two screens namely the selection screen and the output screen. The selection screen is the place where the user will enter the input.
- Include programs: These programs cannot be executed independently. They must be called from an executable program.
- Module pool programs: They are also called dialog programs. We use this type when there are multiple screens to be used.
- The function group encapsulates all the function modules. When we create a function group, automatically two function groups get created namely: 'lfgidtop', 'lfgiduxx'. The function groups cannot be executed independently. SAP supports a large number of standard function groups. Function modules are global modularization.
- Subroutines are the piece of code encoded between FORM and ENDFORM. Subroutines are mainly used for local modularization.
- Class pool contains one global class and any number of local classes. They are created inside the transaction code SE24.
- Type pools are created inside type groups with the help of DDIC (Data Dictionary). All the similar type structures come under one single type pool.
SAP ABAP Data Types
List of icons in SAP ABAP
Below are the most commonly used icons for writing or executing any logic.
SAP ABAP System Fields
Usually, when we have a need to access some important system fields namely date or time, for example, we make use of inbuilt system fields provided by SAP.
NOTE: The structure provided by SAP is 'SYST', which consists of all the above ABAP System Fields.
The below code demonstrates the use of SAP ABAP system fields. Navigate to SE38 transaction to start with the coding.
*&---------------------------------------------------------------------*
*& Report ZRDS1
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZRDS1.
DATA : DATE1(8) TYPE D,
TIME1(6) TYPE T,
USER(12) TYPE C,
SCREEN_NO(4) TYPE C,
PAGE_NO(5) TYPE I.
DATE1 = SY-DATUM.
TIME1 = SY-UZEIT.
USER = SY-UNAME.
SCREEN_NO = SY-DYNNR.
PAGE_NO = SY-PAGNO.
WRITE: 'THE DATE IS' , DATE1.
WRITE: / 'THE TIME IS', TIME1.
WRITE: / 'THE USER IS', USER.
WRITE: / 'THE SCREEN NUMBER IS', SCREEN_NO.
WRITE: / 'THE CURRENT LIST PAGE IS', PAGE_NO.
OUTPUT:
SAP ABAP rules
- To comment on multiple lines in ABAP, hit ( Ctrl + < )
- Each statement ends with a period (.)
- Comments from the middle of the line begin with "
Parameters in SAP ABAP Report
Parameters are used when we want to take the input of the user and display the data accordingly. We use the keyword 'PARAMETER', for fetching the input from the user.
Refer to the code snippet below, to get the idea of using parameters in SAP ABAP.
LOGIC:
*&---------------------------------------------------------------------*
*& Report ZRDS_PARAMETER
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_parameter.
TYPES: BEGIN OF ty_sflight,
carrid TYPE s_carr_id, "Airline Code
connid TYPE s_conn_id, "Flight Connection Number
fldate TYPE s_date, "Flight date
price TYPE s_price, "Airfare
END OF ty_sflight.
DATA : it_sflight TYPE TABLE OF ty_sflight,
wa_sflight TYPE ty_sflight.
PARAMETERS : p_carrid TYPE s_carr_id. "parameter
SELECT carrid
connid
fldate
price
FROM sflight UP TO 10 ROWS
INTO TABLE it_sflight
WHERE carrid = p_carrid.
WRITE : /'carrid', 20 'connid', 30 'fldate', 52 'price'. "the number denotes the position
LOOP AT it_sflight INTO wa_sflight.
WRITE : / wa_sflight-carrid, 20 wa_sflight-connid, 30 wa_sflight-fldate, 40 wa_sflight-price. "the number denotes the position
ENDLOOP.
*& Report ZRDS_PARAMETER
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_parameter.
TYPES: BEGIN OF ty_sflight,
carrid TYPE s_carr_id, "Airline Code
connid TYPE s_conn_id, "Flight Connection Number
fldate TYPE s_date, "Flight date
price TYPE s_price, "Airfare
END OF ty_sflight.
DATA : it_sflight TYPE TABLE OF ty_sflight,
wa_sflight TYPE ty_sflight.
PARAMETERS : p_carrid TYPE s_carr_id. "parameter
SELECT carrid
connid
fldate
price
FROM sflight UP TO 10 ROWS
INTO TABLE it_sflight
WHERE carrid = p_carrid.
WRITE : /'carrid', 20 'connid', 30 'fldate', 52 'price'. "the number denotes the position
LOOP AT it_sflight INTO wa_sflight.
WRITE : / wa_sflight-carrid, 20 wa_sflight-connid, 30 wa_sflight-fldate, 40 wa_sflight-price. "the number denotes the position
ENDLOOP.
Code explanation:
- Here, I have fetched the data from the inbuilt 'SFLIGHT' table from SAP using a parameter. To get a detailed knowledge of the inbuilt SAP Database table, have a look at 'ABAP Data Dictionary'.
- We generally use TYPES: BEGIN OF........END OF in the code. It plays the role of the structure. The reason to use TYPES is, suppose a database table has 100 fields and we want to use only 5 of them, so rather than involving the entire database table, we opt to use TYPES. This makes the performance faster than using the entire database table in the code. Hence all the mandatory fields we enclose inside TYPES: BEGIN OF........END OF.
- DATA is another keyword. IT_SFLIGHT is the internal table and WA_SFLIGHT is the work area. For time being ignore the concept of internal table and work area. To know more about the internal tables, refer to 'Introduction to internal table'.
- Whatever fields we have mentioned in the type structure, the same number and order of fields should be written in the select query.
- WRITE is the keyword use to print the data. The number which I have mentioned inside WRITE statement are its position of displaying.
OUTPUT:
NOTE: You can change the name of the parameter heading by navigating to program > GoTo > Text elements > Selection Texts.
OUTPUT:
Select-options are used when we want the range of inputs from the user. We use the keyword 'SELECT-OPTIONS', for fetching the multiple inputs from the user.
While creating select-options, the system creates an internal table by default having the following 4 fields.
- LOW: Lowest range
- HIGH: Highest range
- SIGN: I (include) or E (exclude)
- OPTION: BT, NB, EQ, NE, GT.
Below is the code snippet for you, to get the idea of using select-options in SAP ABAP.
LOGIC:
*&---------------------------------------------------------------------*
*& Report ZRDS_SELECT_OPTIONS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_select_options.
TYPES: BEGIN OF ty_sflight,
carrid TYPE s_carr_id, "Airline Code
connid TYPE s_conn_id, "Flight Connection Number
fldate TYPE s_date, "Flight date
price TYPE s_price, "Airfare
end OF ty_sflight.
DATA : CARRID TYPE S_CARR_ID.
DATA : it_sflight TYPE TABLE OF ty_sflight,
wa_sflight TYPE ty_sflight.
SELECT-OPTIONS : p_carrid FOR carrid. "SELECT-OPTIONS
SELECT carrid
connid
fldate
price
FROM sflight UP TO 10 ROWS
INTO TABLE it_sflight
WHERE carrid IN p_carrid.
WRITE : /'carrid', 20 'connid', 30 'fldate', 52 'price'. "the number denotes the position
LOOP AT it_sflight INTO wa_sflight.
WRITE : / wa_sflight-carrid, 20 wa_sflight-connid, 30 wa_sflight-fldate, 40 wa_sflight-price. "the number denotes the position
ENDLOOP.
*& Report ZRDS_SELECT_OPTIONS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_select_options.
TYPES: BEGIN OF ty_sflight,
carrid TYPE s_carr_id, "Airline Code
connid TYPE s_conn_id, "Flight Connection Number
fldate TYPE s_date, "Flight date
price TYPE s_price, "Airfare
end OF ty_sflight.
DATA : CARRID TYPE S_CARR_ID.
DATA : it_sflight TYPE TABLE OF ty_sflight,
wa_sflight TYPE ty_sflight.
SELECT-OPTIONS : p_carrid FOR carrid. "SELECT-OPTIONS
SELECT carrid
connid
fldate
price
FROM sflight UP TO 10 ROWS
INTO TABLE it_sflight
WHERE carrid IN p_carrid.
WRITE : /'carrid', 20 'connid', 30 'fldate', 52 'price'. "the number denotes the position
LOOP AT it_sflight INTO wa_sflight.
WRITE : / wa_sflight-carrid, 20 wa_sflight-connid, 30 wa_sflight-fldate, 40 wa_sflight-price. "the number denotes the position
ENDLOOP.
OUTPUT:
How to create a checkbox in SAP ABAP
Multiple checkboxes can be selected at one time. We use the keyword 'AS CHECKBOX', to enable boxes against the fields.
Below is the code snippet for you, to get the idea of using a checkbox in SAP ABAP.
LOGIC:
*&---------------------------------------------------------------------*
*& Report ZRDS_CHECKBOX
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_checkbox.
PARAMETERS : product1 AS CHECKBOX,
product2 AS CHECKBOX,
product3 AS CHECKBOX.
IF product1 = 'X'.
WRITE :/ 'PRODUCT1 IS SELECTED'.
ENDIF.
IF product2 = 'X'.
WRITE : / 'PRODUCT2 IS SELECTED'.
ENDIF.
IF product3 = 'X'.
WRITE : / 'PRODUCT3 IS SELECTED'.
ENDIF.
*& Report ZRDS_CHECKBOX
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_checkbox.
PARAMETERS : product1 AS CHECKBOX,
product2 AS CHECKBOX,
product3 AS CHECKBOX.
IF product1 = 'X'.
WRITE :/ 'PRODUCT1 IS SELECTED'.
ENDIF.
IF product2 = 'X'.
WRITE : / 'PRODUCT2 IS SELECTED'.
ENDIF.
IF product3 = 'X'.
WRITE : / 'PRODUCT3 IS SELECTED'.
ENDIF.
OUTPUT:
Only one radio button can be selected at a time.
Below is the code snippet for you, to get the idea of using radio buttons in SAP ABAP.
LOGIC:
*&---------------------------------------------------------------------*
*& Report ZRDS_RADIO_BUTTON
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_radio_button.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : YES RADIOBUTTON GROUP r1,
NO RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK B1.
DATA : select VALUE 'X'.
CASE select.
WHEN YES.
WRITE: / 'SUPERB GOOD GOING'.
WHEN NO.
WRITE: / 'YOU ARE TOO LAZY'.
ENDCASE.
*& Report ZRDS_RADIO_BUTTON
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zrds_radio_button.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS : YES RADIOBUTTON GROUP r1,
NO RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK B1.
DATA : select VALUE 'X'.
CASE select.
WHEN YES.
WRITE: / 'SUPERB GOOD GOING'.
WHEN NO.
WRITE: / 'YOU ARE TOO LAZY'.
ENDCASE.
OUTPUT:
List of tcodes in SAP ABAP
To process some requests, SAP provides the concept of TCODE. TCODE stands for the 'Transaction Code'. It is the combination of alphabets and numbers.The entire SAP runs on these TCODES.
NOTE: We will see the use of these TCODES in further posts.
The illustrations above will help individuals and professionals learn about the basics of SAP ABAP.
In the upcoming second tutorial, we will understand the fundamentals of DDIC (Data Dictionary), which includes SAP inbuilt database tables, functions, and so on. DDIC is a very crucial part of SAP ABAP.
Next blog: Introduction to SAP ABAP DDIC.
In the upcoming second tutorial, we will understand the fundamentals of DDIC (Data Dictionary), which includes SAP inbuilt database tables, functions, and so on. DDIC is a very crucial part of SAP ABAP.
Next blog: Introduction to SAP ABAP DDIC.
0 Comments