SAP ABAP Basic Syntax Programming for Beginners
SAP ABAP Basic Syntax Programming for Beginners
1. Program Structure
• Explanation: Every ABAP program starts with a declaration (e.g., REPORT) and
includes sections for data declaration, logic, and output. It’s event-driven, with
blocks like START-OF-SELECTION for main processing.
• Syntax Rules:
o Case-insensitive (e.g., write = WRITE).
o Statements end with a period (.).
• Example:
REPORT z_basic_program.
2. Data Declaration
• Explanation: Variables are declared using DATA to store values. Types can be
predefined or linked to DDIC objects.
• Syntax Rules:
o Use TYPE for data type, VALUE for initial values.
• Example:
3. Data Types
• Explanation: ABAP supports various data types for different kinds of data (e.g.,
numbers, text, dates). Common types include I (integer), C (character), N (numeric
text), D (date), STRING (variable-length string).
• Syntax Rules:
o Specify length for C (e.g., CHAR10) or use dynamic types like STRING.
• Example:
o Declares and displays an integer (100), character ("SAP"), and date (2025-03-
25).
4. Arithmetic Operations
• Explanation: ABAP supports basic arithmetic operations using operators.
• Syntax Rules:
o Operators: +, -, *, /, MOD, **.
• Example:
lv_result = lv_a * 2.
6. Loops
• Explanation: DO and WHILE repeat code execution.
• Syntax Rules:
o End with ENDDO or ENDWHILE.
• Example:
DO 3 TIMES.
lv_count = lv_count + 1.
WRITE: / lv_count.
ENDDO.
7. Concatenate
• Explanation: The CONCATENATE statement combines multiple strings into one, with
an optional separator.
• Syntax Rules:
o Use SEPARATED BY for delimiters (e.g., space, comma).
• Example:
8. Split
• Explanation: SPLIT divides a string into parts based on a delimiter, storing results in
variables or a table.
• Syntax Rules:
o Use AT to specify the separator.
• Example:
9. Internal Tables
• Explanation: Internal tables store multiple records in memory, like a temporary
database table.
• Syntax Rules:
o Declare with TYPE TABLE OF, use APPEND to add data.
• Example:
wa_student-id = 2.
wa_student-name = 'Avi'.
o Fetches and displays flight data from table SPFLI for carrier "Rudra Airways".
• Example:
13. Comments
• Explanation: Comments improve code readability.
• Syntax Rules:
o * for full-line, " for inline.
• Example:
*Program start
DATA: lv_flag TYPE c VALUE 'Y'. " Yes flag
WRITE: lv_flag.