0% found this document useful (0 votes)
12 views3 pages

Introduction to ABAP Programming Basics

ABAP (Advanced Business Application Programming) is the primary programming language for SAP systems, used for creating custom reports, forms, and enhancing standard applications. Key concepts include parameters and select-options for user input, various types of internal tables for data storage, and string operations for manipulating text. The document also covers control structures such as IF and CASE statements, as well as essential system variables and internal table operations.

Uploaded by

rachna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Introduction to ABAP Programming Basics

ABAP (Advanced Business Application Programming) is the primary programming language for SAP systems, used for creating custom reports, forms, and enhancing standard applications. Key concepts include parameters and select-options for user input, various types of internal tables for data storage, and string operations for manipulating text. The document also covers control structures such as IF and CASE statements, as well as essential system variables and internal table operations.

Uploaded by

rachna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ABAP PROGRAMMING - PART 1

------------------------------------------------------

INTRODUCTION TO ABAP
------------------------------------------------------
ABAP stands for Advanced Business Application Programming
It is the main programming language used in SAP systems for developing
applications in both frontend (reports, forms, etc.) and backend (database
logic).

ABAP is used to:


- Create custom reports and programs.
- Develop forms and smartforms.
- Enhance standard SAP applications.
- Handle business logic using tables and data dictionary objects.

Transaction Code: **SE38** – Used to create, execute, and manage ABAP programs.

------------------------------------------------------
USEFUL SHORTCUTS
------------------------------------------------------
CTRL + D - Duplicate a line.
CTRL + < , * - Comment a line.
CTRL + > - Uncomment a line.
: (Colon) - Chain operator.
. (Period) - End of statement.

Pretty Printer – Used for automatic code alignment and proper indentation.

------------------------------------------------------
PARAMETERS AND SELECT-OPTIONS
-----------------------------------------------------
Parameters – Used to accept single input from the user.
Select-options – Used to accept a range or multiple values.

Examples:
PARAMETERS p_matnr TYPE matnr. " Single value input
SELECT-OPTIONS s_matnr FOR mara-matnr. " Multiple / range input

Select-options create a range table internally with LOW, HIGH, SIGN, OPTION.

OPTIONS:
- Obligatory– Makes a field mandatory.
- No-Intervals – Removes the HIGH value field.
- No Extension – Removes multiple selection option.

Usage in WHERE condition:


- For Parameters → use - =
- For Select-options → use -IN

Q1: What are the 4 parts of a Select-option?


A1: SIGN (Include/Exclude), OPTION (EQ, BT, etc.), LOW, HIGH

Q2: If only LOW is passed → Operator = EQ


Q3: If LOW & HIGH are passed → Operator = BT

------------------------------------------------------
TYPE VS LIKE
------------------------------------------------------
TYPE → Assigns a data type directly.
LIKE → Copies data type of an existing variable or field.

Example:
DATA: lv_name TYPE char10. "TYPE assigns data type
DATA: lv_new LIKE lv_name. "LIKE copies data type

------------------------------------------------------
IF AND CASE STATEMENTS
------------------------------------------------------
IF – Used to check multiple conditions. Executes based on TRUE/FALSE.
CASE – Used to compare one variable against multiple fixed values.

Example (IF):
IF lv_age > 18.
WRITE 'Adult'.
ELSEIF lv_age = 18.
WRITE 'Just turned adult'.
ELSE.
WRITE 'Minor'.
ENDIF.

Example (CASE):
CASE lv_grade.
WHEN 'A'. WRITE 'Excellent'.
WHEN 'B'. WRITE 'Good'.
WHEN OTHERS. WRITE 'Needs Improvement'.
ENDCASE.

Performance Tip:
CASE is faster than multiple ELSEIF conditions.

------------------------------------------------------
STRING OPERATIONS
------------------------------------------------------
1 CONCATENATE – Joins multiple strings.
CONCATENATE lv_a lv_b INTO lv_result SEPARATED BY '-'.

2 SPLIT – Splits a string using a separator.


SPLIT lv_result AT '-' INTO lv_a lv_b.

3 CONDENSE – Removes leading and trailing spaces.


4 CONDENSE NO-GAPS – Removes all spaces (even between words).
5 FIND – Searches for a substring in a string.
6 STRLEN – Returns the string length.
7 TRANSLATE – Converts case (UPPER/LOWER).
8 SHIFT – Moves string content left, right, or circularly.

------------------------------------------------------
LOOPING STATEMENTS
------------------------------------------------------
DO – Unconditional loop.
WHILE – Conditional loop.
LOOP – Used for internal tables.

EXIT – Immediately leaves the loop.


CONTINUE – Skips current iteration.
CHECK – Skips current loop pass if condition fails.

------------------------------------------------------
SYSTEM VARIABLES (SY- FIELDS)
------------------------------------------------------
SY-SUBRC – Return code (0 = Success, <>0 = Failure)
SY-TABIX – Current index in a loop
SY-DATUM – Current date (YYYYMMDD)
SY-UZEIT – Current time (HHMMSS)
SY-UNAME – Logged user name
SY-UCOMM – User command (button or menu action)
------------------------------------------------------
INTERNAL TABLES & WORK AREAS
------------------------------------------------------
Internal Table → Temporary storage that holds multiple records.
Work Area → Holds only one record.

Example:
DATA: lt_data TYPE TABLE OF mara,
wa_data LIKE LINE OF lt_data.

------------------------------------------------------
TYPES OF INTERNAL TABLES
------------------------------------------------------
1 STANDARD TABLE
- Default type, sequential access (Linear or Binary Search)
- Slower for large data

2 SORTED TABLE
- Data automatically sorted by key
- Faster (uses Binary Search)

3 HASHED TABLE
- Uses hash algorithm (direct access by key)
- Fastest for unique key access

Example:
DATA: lt_std TYPE STANDARD TABLE OF mara,
lt_sort TYPE SORTED TABLE OF mara WITH UNIQUE KEY matnr,
lt_hash TYPE HASHED TABLE OF mara WITH UNIQUE KEY matnr.

------------------------------------------------------
INTERNAL TABLE WITH / WITHOUT HEADER LINE
------------------------------------------------------
Old: Internal table with header line (obsolete now)
- Implicit work area created automatically.

Modern: Without header line (explicit work area needed)


- We define a separate work area manually.

Example:
DATA: lt_data TYPE TABLE OF mara.
DATA: wa_data LIKE LINE OF lt_data.

------------------------------------------------------
INTERNAL TABLE OPERATIONS
------------------------------------------------------
APPEND – Adds record at end.
INSERT – Adds record at specific position.
DELETE – Removes record.
MODIFY – Updates record.
SORT – Sorts table (Ascending by default).
READ TABLE – Reads specific record.
DESCRIBE TABLE – Returns number of lines.
CLEAR / REFRESH – Clears internal table data.
COLLECT – Summarizes numeric fields with same key values.

You might also like