0% found this document useful (0 votes)
61 views42 pages

Sap Abap Rap Interview Questions

The document is a comprehensive guide containing 100 interview questions and answers focused on SAP ABAP and RAP, targeting both freshers and experienced professionals. It covers various topics including ABAP fundamentals, database operations, object-oriented programming, and performance optimization. The document serves as a resource for SAP ABAP developers and consultants to prepare for interviews.

Uploaded by

ayushshah453
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)
61 views42 pages

Sap Abap Rap Interview Questions

The document is a comprehensive guide containing 100 interview questions and answers focused on SAP ABAP and RAP, targeting both freshers and experienced professionals. It covers various topics including ABAP fundamentals, database operations, object-oriented programming, and performance optimization. The document serves as a resource for SAP ABAP developers and consultants to prepare for interviews.

Uploaded by

ayushshah453
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

100 TOP SAP ABAP AND

RAP INTERVIEW
QUESTIONS AND
ANSWERS
Document Version: 1.0
Created: January 2026
Target Audience: SAP ABAP Developers, SAP Consultants, Freshers and Experienced Professionals
Scope: Comprehensive guide covering ABAP fundamentals, OOP, Database operations, ALV reports, CDS, and RAP

TABLE OF CONTENTS
1. ABAP Fundamentals (Q1-10)
2. Database & SQL Operations (Q11-20)
3. Object-Oriented ABAP (Q21-30)
4. ALV Reports (Q31-40)
5. CDS and RAP (Q41-60)
6. Performance & Optimization (Q61-70)
7. Error Handling & Debugging (Q71-80)
8. Interfaces & Integration (Q81-90)
9. S/4HANA & Modern ABAP (Q91-100)

ABAP FUNDAMENTALS
Q1: What is SAP ABAP and what does it stand for?
Answer:
ABAP stands for Advanced Business Application Programming. It is a high-level programming language used to develop
SAP applications. Key points:

Event-driven, procedural language with object-oriented capabilities


Used to build custom applications, reports, interfaces, and enhancements within SAP ecosystem
Programs run on SAP application server and interact with ABAP runtime environment
Platform-independent (runs on different databases - Oracle, SQL Server, HANA)
Supports both classical ABAP and modern ABAP approaches

Q2: What are the different types of ABAP programs?


Answer:
ABAP programs are classified as:

1. Report Programs - Retrieve and display data (Executable programs with selection screens)
2. Dialog Programs - Interactive programs with screens (Module Pool)
3. Function Group Programs - Collection of related functions (Function Modules, RFC-enabled)
4. Classes and Interfaces - Object-oriented ABAP components
5. Include Programs - Reusable code snippets for other programs
6. Subroutines - Modular code blocks within programs

Each type serves different purposes in SAP development and has specific use cases.

Q3: Explain the difference between classical reports and


interactive reports.
Answer:

Aspect Classical Reports Interactive Reports


Display
Simple list format Interactive list with drill-down
Format
User
No interaction after generation Click on line items for details
Interaction
START-OF-SELECTION, END-OF- Additional: AT LINE-SELECTION, AT
Events
SELECTION USER-COMMAND
Complexity Simpler to develop More complex, multi-level navigation
Use Case Basic data retrieval Detailed data analysis
User
Linear, static Non-linear, exploratory
Experience

Interactive reports provide better data navigation and user-friendly analysis capabilities.

Q4: What is a data dictionary and why is it important?


Answer:
Data Dictionary (ABAP Dictionary) is a central repository of metadata in SAP that defines data structures.

Contains:

Table definitions
Field definitions and domains
Data types and structures
Search helps and check tables
View definitions

Importance:

Ensures data consistency across all applications


Provides centralized maintenance of data definitions
Supports automatic data validation and referential integrity
Facilitates code reusability
Transaction code: SE11

Q5: What is a domain in ABAP and how does it differ from


data types?
Answer:

Domain:

Defines technical properties of a field (length, data type, decimal places)


Semantic level (meaning of data)
Value tables can be attached for validation
One domain can be assigned to multiple table fields
Centralized maintenance

Data Types:

Defines structure and format of data


More specific than domains
Includes domains, structures, and built-in types
Examples: CHAR, NUMC, DATS, ABAP types like I, F, C

Key Difference:
Domains provide semantic meaning while data types define technical structure.

Q6: What are internal tables and why are they important?
Answer:
Internal Tables are temporary data tables in ABAP runtime memory.

Characteristics:

Not stored in database


Stored as structures in sequential order
Used for processing large datasets efficiently
Local to the program/subroutine

Types:

1. Standard Table - Sequential access, key access slower


2. Sorted Table - Automatically sorted, fast key access
3. Hashed Table - Hash key, fastest key access, no sequential access

Declaration:

DATA: it_data TYPE TABLE OF mara.


DATA: it_sorted TYPE SORTED TABLE OF mara WITH UNIQUE KEY matnr.
DATA: it_hash TYPE HASHED TABLE OF mara WITH UNIQUE KEY matnr.

Importance:

Reduces database calls significantly


Improves performance for bulk operations
Enables efficient data manipulation
Supports complex business logic

Q7: Explain the difference between SELECT SINGLE and


SELECT UP TO 1 ROWS.
Answer:

Aspect SELECT SINGLE SELECT UP TO 1 ROWS


Purpose Fetch single record Fetch up to one record
Expectation Expects unique record exists Flexible, works with any data
Error Handling May fail if no record found Better error handling
Use Case Known unique record Validation, existence checks
Performance Slightly faster Marginally slower

Recommendation: Use SELECT UP TO 1 ROWS in modern ABAP for better flexibility and error handling.

Syntax:

SELECT SINGLE * FROM mara INTO wa_mara WHERE matnr = '1000'.

SELECT * FROM mara INTO TABLE it_mara UP TO 1 ROWS WHERE matnr = '1000'.

Q8: What is a subroutine and how do you call it?


Answer:
Subroutines are reusable code blocks within a program.

Definition:

FORM subroutine_name [USING parameters] [CHANGING parameters] [RETURNING VALUE(result)].


... code ...
ENDFORM.

Calling:

PERFORM subroutine_name [USING parameter_values] [CHANGING variable_names].

Advantages:

Reduces code duplication


Improves maintainability
Easier debugging
Better readability

Disadvantages:

Local to program only (not reusable across programs)


Procedural approach (less OOP)

Q9: What are the different types of variables in ABAP?


Answer:

1. Elementary Types - Simple data types (CHAR, NUM, DATE, TIME)


2. Complex Types
Structures - Composite data types
Internal Tables - Collections of data
3. Reference Types - References to objects and data
4. Object Types - Class instances

Declaration:

DATA variable_name TYPE data_type.


DATA variable_name TYPE TABLE OF data_type.
CONSTANTS constant_name TYPE data_type VALUE 'value'.
STATIC variable_name TYPE data_type. "Retains value across calls"
Q10: What is the purpose of the ABAP preprocessor and
what are its common directives?
Answer:
ABAP Preprocessor processes directives before code compilation.

Common Directives:

1. #IF ... #ENDIF - Conditional code inclusion


2. #DEFINE - Define constants
3. #INCLUDE - Include external code
4. #MESSAGE - Message handling

Example:

#IF defined TEST


... test code ...
#ENDIF

#DEFINE MESSAGE_INFO 'Information: %s'.

Benefits:

Platform-specific code
Debug and test code management
Code reusability
Compile-time configuration

DATABASE & SQL OPERATIONS


Q11: What are the different ways to retrieve data from
database in ABAP?
Answer:

1. SELECT Statement - Fetch data rows

SELECT SINGLE - Single record


SELECT UP TO N ROWS - Limited records
SELECT * - All records

2. Buffering - Use application buffer for repeated access


3. BAPI/RFC - Remote procedure calls for business logic

4. Dynamic SQL - Runtime-built queries

5. New Open SQL - Modern ABAP approach with expressions

6. Native SQL - Direct database SQL (not portable)

7. CDS Views - Virtual data models with optimizations

8. OData Services - REST API consumption

Best Practice: Use Open SQL for portability and database independence.

Q12: Explain the concepts of buffering in ABAP.


Answer:
Buffering caches frequently accessed data in memory to reduce database access.

Types:

1. Generic Buffering - Buffers entire table key prefix


2. Single-record Buffering - Buffers complete records
3. Client-dependent Buffering - For multi-client data
4. Full Table Buffering - Entire table cached

Buffering Status:

Not buffered (on demand)


Fully buffered (entire table)
Partially buffered (specific keys)

Configuration: Transaction SE13 - Define buffering for tables

Considerations:

Memory overhead
Data consistency issues in batch updates
Invalidation when data changes
Use for reference data, not transactional data

Best Practice: Use for master data (materials, customers) but avoid for frequently changing data.

Q13: What is the difference between APPEND, MODIFY,


and DELETE operations on internal tables?
Answer:
Operation APPEND MODIFY DELETE
Purpose Add record Change record Remove record
Position End of table Specific position Specific position
Table Size Increases by one Unchanged Decreases
Performance O(1) Depends on index Depends on index
Syntax APPEND ... MODIFY ... SET DELETE ... WHERE

Syntax Examples:

APPEND record TO internal_table.


MODIFY internal_table SET record WHERE condition.
DELETE internal_table WHERE condition.

Performance Tip: Use SORTED/HASHED tables for MODIFY/DELETE for O(log n) performance.

Q14: What are the different ways to loop through internal


tables?
Answer:

1. LOOP AT internal_table

LOOP AT it_data.
... process current record ...
ENDLOOP.

2. LOOP AT ... INTO

LOOP AT it_data INTO ls_record.


ls_record-field = new_value.
ENDLOOP.

3. LOOP AT ... WHERE (with filter)

LOOP AT it_data INTO ls_record WHERE status = 'ACTIVE'.


...
ENDLOOP.

4. LOOP AT ... ASSIGNING (field symbol - fastest)


LOOP AT it_data ASSIGNING <fs_line>.
<fs_line>-field = new_value.
ENDLOOP.

5. FOR syntax (modern ABAP)

FOR item IN it_data


item->field = value

Performance Ranking (Best to Worst):

1. ASSIGNING with field symbol


2. INTO with structure copy
3. Direct loop (least optimal)

Q15: How do you optimize a database query in ABAP?


Answer:
Query Optimization Strategies:

1. Proper Indexing - Use indexed fields in WHERE clause


2. SELECT Only Required Fields - SELECT FIELDS instead of SELECT *
3. Use Joins Instead of Nested Selects - Better performance
4. Add WHERE Conditions Early - Filter at database level
5. Use Buffer Tables - Reference data
6. Aggregate Functions at DB - SUM, COUNT at database
7. Avoid Large Dataset Processing - Use pagination (UP TO rows)
8. Use CDS Views - Pre-optimized queries
9. Monitor Performance - SQL Trace (ST05), Runtime Analysis (SE30)
10. Database Hints - /*+ INDEX() */ for optimizer guidance

Example - Optimized Query:

SELECT matnr, maktx, mtart FROM mara


INNER JOIN makt ON [Link] = [Link]
WHERE [Link] = 'FERT'
AND [Link] = 'EN'
UP TO 1000 ROWS
INTO TABLE @it_result.
Q16: What is a foreign key relationship and how is it defined
in ABAP?
Answer:

Foreign Key:

Establishes relationship between two tables


References primary key of another table
Ensures referential integrity

Definition in ABAP Dictionary (SE11):

1. Navigate to table with dependent data


2. Create field referencing another table's primary key
3. Define Foreign Key relationship
4. Set constraints (Optional/Mandatory)

Structure:

Foreign Key Field - References parent table primary key


Relationship Cardinality - One-to-One or One-to-Many
Constraint Type - RESTRICT, CASCADE, SET NULL

Example:

Purchase Order Header has VBELN (document number) as FK to document master


Purchase Order Item has POSNR as FK to parent PO Header

Benefits:

Automatic data validation


Prevents orphaned records
Better query optimization with joins
System enforces relationships

Q17: Explain the concept of database transactions in ABAP.


Answer:

Database Transactions:

Logical unit of work with multiple database operations


All operations succeed or all fail (ACID principles)

Transaction Control:
COMMIT WORK. "Save changes"
COMMIT WORK AND WAIT. "Save and wait for confirmation"
ROLLBACK WORK. "Undo all changes"

Atomic Operations:

INSERT, UPDATE, DELETE grouped together


If one fails, entire transaction rolls back
Automatic rollback on dialog/exception

Example:

BEGIN OF TRANSACTION.
MODIFY mara FROM wa_mara.
MODIFY makt FROM wa_makt.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ELSE.
ROLLBACK WORK.
ENDIF.
END OF TRANSACTION.

Best Practices:

Keep transactions short


Avoid nested transactions
Use proper error handling
Close transactions explicitly

Q18: What is the difference between COMMIT WORK and


COMMIT WORK AND WAIT?
Answer:

Aspect COMMIT WORK COMMIT WORK AND WAIT


Execution Asynchronous Synchronous
Return Immediate After DB confirmation
Data Persistence Not guaranteed immediately Guaranteed
Use Case Fast return needed Critical data
Reliability Slightly risky Safer

Recommendation: Use COMMIT WORK AND WAIT for critical data modifications.

Example:
"For important transactions"
COMMIT WORK AND WAIT.

"For non-critical batches"


COMMIT WORK.

Q19: What is CALL FUNCTION and how does it differ from


calling a subroutine?
Answer:

Aspect CALL FUNCTION PERFORM (Subroutine)


Scope Global Local to program
Remote Access Yes (RFC-enabled) No
Synchronous Yes Yes (only)
Reusability Across programs Within program
Performance Slightly slower Faster

CALL FUNCTION Syntax:

CALL FUNCTION 'function_name'


EXPORTING parameter = value
IMPORTING result = variable
EXCEPTIONS exception_name = 1.

IF sy-subrc = 1.
"Handle exception"
ENDIF.

PERFORM Syntax:

PERFORM subroutine_name USING value CHANGING variable.

When to Use:

CALL FUNCTION - Global, reusable logic, remote calls


PERFORM - Local processing, quick operations

Q20: What are BAPI and when should you use them?
Answer:
BAPI (Business Application Programming Interface):

Standardized interface for external access to SAP business objects


RFC-enabled function modules
Follow specific naming conventions
Return structured results
Stateless operations

Characteristics:

1. Stateless - Each call is independent


2. Standardized - Follow SAP patterns
3. Error handling - Structured exception handling
4. Multi-language support - Language-independent

When to Use BAPIs:

External system integration


Web services
Remote function calls
Third-party applications
Batch data processing
Complex business operations

Common BAPI Examples:

BAPI_PURCHASEORDER_CREATE - Create purchase order


BAPI_MATERIAL_GET_DETAIL - Retrieve material details
BAPI_CUSTOMER_GETDETAIL - Get customer information
BAPI_SALESORDER_CREATE - Create sales order

Advantages:

SAP-supported and reliable


Well-documented interfaces
Standard error handling
Tested and proven

OBJECT-ORIENTED ABAP
Q21: What are the principles of Object-Oriented
Programming in ABAP?
Answer:
1. Encapsulation

Hide internal details


Provide public interface
Access modifiers: public, private, protected

2. Inheritance

Child classes inherit from parent classes


Code reuse mechanism
Hierarchical relationships
METHOD inheritance and redefinition

3. Polymorphism

Different objects respond to same method call


Method overriding in child classes
Dynamic binding at runtime

4. Abstraction

Abstract classes define interface


Hide implementation complexity
Focus on 'what' not 'how'

Benefits:

Code reusability
Better maintainability
Flexibility and extensibility
Scalability for large applications

Q22: How do you define a class in ABAP?


Answer:

Class Definition:
CLASS class_name DEFINITION.
PUBLIC SECTION.
DATA attribute TYPE data_type.
METHODS method_name
IMPORTING parameter TYPE type
EXPORTING result TYPE type.

PRIVATE SECTION.
DATA private_attribute TYPE data_type.

PROTECTED SECTION.
DATA protected_attribute TYPE data_type.
ENDCLASS.

Class Implementation:

CLASS class_name IMPLEMENTATION.


METHOD method_name.
... code ...
ENDMETHOD.
ENDCLASS.

Instantiation:

DATA object TYPE REF TO class_name.


CREATE OBJECT object.

Access Levels:

1. PUBLIC - Accessible from outside


2. PRIVATE - Only within class
3. PROTECTED - Accessible in child classes

Q23: What are methods and how do you define them in


ABAP?
Answer:

Methods: Functions within a class that operate on class data.

Method Definition:
METHODS method_name
IMPORTING parameter1 TYPE type1
EXPORTING result TYPE result_type
CHANGING parameter2 TYPE type2
RETURNING VALUE(return_value) TYPE return_type
RAISING exception_type.

Method Implementation:

METHOD method_name.
result = calculated_value.
ENDMETHOD.

Method Types:

1. Instance Methods - Operate on specific object


2. Static Methods - Operate on class (CLASS-METHODS)
3. Constructor - Initialize object (METHOD CONSTRUCTOR)
4. Destructor - Cleanup on object deletion

Calling Methods:

CALL METHOD object->method_name()


EXPORTING parameter = value
IMPORTING result = variable.

"Shorter syntax"
result = object->method_name( parameter ).

Q24: What is inheritance and how do you implement it in


ABAP?
Answer:

Inheritance: Child class inherits properties and methods from parent class.

Syntax:
CLASS child_class DEFINITION INHERITING FROM parent_class.
PUBLIC SECTION.
METHODS method_name REDEFINITION.
ENDCLASS.

Implementation:

CLASS child_class IMPLEMENTATION.


METHOD method_name.
SUPER->method_name( ). "Call parent method"
... additional child code ...
ENDMETHOD.
ENDCLASS.

Key Concepts:

1. Single Inheritance - One parent class


2. REDEFINITION - Override parent method
3. SUPER - Access parent class methods
4. Abstract Classes - Define interface without implementation

Types of Inheritance:

Implementation Inheritance - Inherit code


Interface Inheritance - Define contract

Best Practice: Use interfaces for polymorphism.

Q25: What are interfaces and how do you use them in


ABAP?
Answer:

Interfaces: Define contract for implementing classes, support multiple implementation.

Interface Definition:

INTERFACE interface_name.
METHODS method1
IMPORTING parameter TYPE type
EXPORTING result TYPE type.
DATA attribute TYPE data_type.
ENDINTERFACE.
Implementing Interface:

CLASS class_name DEFINITION.


PUBLIC SECTION.
INTERFACES interface_name.
ENDCLASS.

CLASS class_name IMPLEMENTATION.


METHOD interface_name~method1.
... implementation ...
ENDMETHOD.
ENDCLASS.

Calling Interface Method:

DATA obj TYPE REF TO interface_name.


CALL METHOD obj->method1( ).

Advantages:

Loose coupling between classes


Multiple interface implementation
Polymorphic behavior
Contract enforcement

Q26: What is polymorphism and how is it achieved in ABAP?


Answer:

Polymorphism: Objects of different types respond to same message differently.

Types in ABAP:

1. Method Overriding - Child class redefines parent method


2. Interface Implementation - Different classes implement same interface
3. Dynamic Binding - Runtime method resolution

Example:
INTERFACE ipayment.
METHODS process_payment.
ENDINTERFACE.

CLASS credit_card DEFINITION.


PUBLIC SECTION.
INTERFACES ipayment.
ENDCLASS.

CLASS bank_transfer DEFINITION.


PUBLIC SECTION.
INTERFACES ipayment.
ENDCLASS.

"Usage"
DATA payment_method TYPE REF TO ipayment.
CREATE OBJECT payment_method TYPE credit_card.
payment_method->process_payment( ).

Benefits:

Flexible, extensible design


Easy to add new implementations
Reduce code duplication
Better separation of concerns

Q27: What are constructors and destructors in ABAP


classes?
Answer:

Constructor:

Initializes object when created


Method name: CONSTRUCTOR
Called automatically by CREATE OBJECT
Can accept parameters

METHOD CONSTRUCTOR.
attribute = parameter_value.
ENDMETHOD.

Destructor:
Cleans up when object deleted
Method name: DESTRUCTOR
Called automatically when reference released
No parameters, typically for resource cleanup

METHOD DESTRUCTOR.
... cleanup code ...
ENDMETHOD.

Example:

CREATE OBJECT obj EXPORTING parameter = 'value'.


CLEAR obj. "Destructor called"

Best Practices:

Use constructor for initialization


Use destructor for resource cleanup
Handle exceptions in constructor
Avoid complex logic in destructors

Q28: What are static methods and attributes in ABAP


classes?
Answer:

Static Methods:

Belong to class, not instances


Called without creating object
Cannot access instance variables
Declared with CLASS-METHODS

CLASS class_name=>static_method( ).

Static Attributes:

Class variables shared by all instances


Declared with CLASS-DATA
Persist throughout program execution
Same value for all objects
class_name=>static_var = 'value'.
DATA result = class_name=>static_var.

Use Cases:

1. Utility functions
2. Shared counters/configuration
3. Factory methods
4. Singleton pattern

Q29: Explain the concept of encapsulation in ABAP.


Answer:

Encapsulation: Bundling data and methods together, hiding internal details.

Access Modifiers:

1. PUBLIC SECTION

Accessible from outside class


Forms the interface
External dependencies

2. PRIVATE SECTION

Accessible only within class


Internal implementation details
No external access

3. PROTECTED SECTION

Accessible in class and subclasses


Inheritance chain access

Example:

CLASS bank_account DEFINITION.


PUBLIC SECTION.
METHODS withdraw IMPORTING amount TYPE decimal.

PRIVATE SECTION.
DATA balance TYPE decimal.
METHODS validate_balance.
ENDCLASS.
Benefits:

1. Protects data integrity


2. Reduces external dependencies
3. Allows internal changes without affecting interface
4. Improves maintainability
5. Enforces contract compliance

Q30: What is the difference between reference types and


value types in ABAP?
Answer:

Value Types:

Store actual data


Passed by value (copy created)
Changes don't affect original
Examples: integers, strings, structures

Reference Types:

Store reference/pointer to object


Passed by reference
Changes affect original
Must be instantiated with CREATE OBJECT
Examples: objects, class instances

Declaration:

"Value type"
DATA var TYPE i.
DATA struct TYPE mara.

"Reference type"
DATA obj TYPE REF TO class_name.
CREATE OBJECT obj.

Example - Value Type:

DATA: var1 TYPE i VALUE 10.


DATA: var2 = var1.
var1 = 20. "var2 still 10 - no change"
Example - Reference Type:

DATA ref1 TYPE REF TO class.


DATA ref2 = ref1.
ref1->attr = 20. "ref2 sees change too - same object"

Summary Table:

Aspect Value Type Reference Type


Storage Stack Heap
Assignment Copy Reference
Pass to Methods By value By reference
Modification Impact No impact Affects original
Memory Fixed size Dynamic
Initialization Automatic Explicit (CREATE OBJECT)

ALV REPORTS
Q31: What is ALV and what are its types?
Answer:

ALV (ABAP List Viewer):

Technology for displaying data in grid/table format


Provides enhanced UI for data presentation
Sorting, filtering, export capabilities out-of-box

ALV Types:

1. List ALV (cl_salv_table)

Simple list display


Limited functionality
Easier implementation
Lightweight

2. Grid ALV (cl_gui_alv_grid)

Rich GUI interface


Advanced features (editable cells, hierarchies)
More complex implementation

3. Tree ALV (cl_salv_tree)

Hierarchical data display


Parent-child relationships
Expandable/collapsible nodes

4. Classic ALV (REUSE_ALV_GRID_DISPLAY)

Legacy approach (deprecated)


Functional module based
Still used in existing systems

Common Features (All Types):

Sorting and filtering


Column configuration
Export to Excel/PDF
Color and conditional formatting
Row selection
Customizable layout

Q32: How do you create a basic ALV report using


cl_salv_table?
Answer:

Step 1: Prepare Data

DATA: lt_data TYPE TABLE OF mara.


SELECT * FROM mara INTO TABLE lt_data UP TO 100 ROWS.

Step 2: Create ALV Instance

DATA: lo_alv TYPE REF TO cl_salv_table.


CLASS cl_salv_table DEFINITION LOAD.
CALL METHOD cl_salv_table=>factory(
IMPORTING r_salv_table = lo_alv
CHANGING t_table = lt_data ).

Step 3: Configure (Optional)

"Set title"
lo_alv->get_display_settings( )->set_list_header( 'Material Master' ).

Step 4: Display
lo_alv->display( ).

Complete Example:

TRY.
DATA lt_data TYPE TABLE OF mara.
SELECT * FROM mara INTO TABLE lt_data UP TO 100 ROWS.

DATA lo_alv TYPE REF TO cl_salv_table.


CALL METHOD cl_salv_table=>factory(
IMPORTING r_salv_table = lo_alv
CHANGING t_table = lt_data ).

lo_alv->display( ).
CATCH cx_salv_msg INTO DATA(lx_error).
MESSAGE lx_error->get_text( ) TYPE 'E'.
ENDTRY.

Q33: How do you customize columns in ALV reports?


Answer:

Get Column Reference:

DATA: lo_columns TYPE REF TO cl_salv_columns_table.


lo_columns = lo_alv->get_columns( ).

Set Column Properties:

DATA: lo_column TYPE REF TO cl_salv_column_table.


TRY.
lo_column = lo_columns->get_column( 'MATNR' ).
lo_column->set_short_text( 'Material' ).
lo_column->set_medium_text( 'Material Number' ).
lo_column->set_long_text( 'Material Number' ).
lo_column->set_width( 15 ).
lo_column->set_alignment( if_salv_c_alignment=>centered ).
CATCH cx_salv_not_found.
ENDTRY.

Hide Columns:
lo_column->set_visible( abap_false ).

Column Properties:

Short/medium/long text
Width
Alignment (left, center, right)
Visibility
Color and formatting
Input enabled/disabled

Q34: How do you add sorting and filtering to ALV reports?


Answer:

Sorting:

DATA: lo_sorts TYPE REF TO cl_salv_sorts.


lo_sorts = lo_alv->get_sorts( ).
TRY.
lo_sorts->add_sort(
columnname = 'MATNR'
sequence = if_salv_c_sort=>sort_ascending ).
lo_sorts->add_sort(
columnname = 'WERKS'
sequence = if_salv_c_sort=>sort_descending ).
CATCH cx_salv_not_found.
ENDTRY.

Filtering:

DATA: lo_filters TYPE REF TO cl_salv_filters.


lo_filters = lo_alv->get_filters( ).
TRY.
lo_filters->add_filter(
columnname = 'MTART'
value = 'FERT' ).
CATCH cx_salv_not_found.
ENDTRY.
Q35: How do you enable user interactions in ALV grid
reports?
Answer:

Enable Editing:

DATA: lo_functions TYPE REF TO cl_salv_functions_list.


lo_functions = lo_alv->get_functions( ).
lo_functions->set_default( abap_true ).

Register Event Handler:

DATA: lo_events TYPE REF TO cl_salv_events_table.


lo_events = lo_alv->get_event( ).
SET HANDLER on_user_command FOR lo_events.

Define Event Handler:

METHOD on_user_command.
CASE sender->get_user_command( ).
WHEN 'SAVE'.
PERFORM save_data.
WHEN 'DELETE'.
PERFORM delete_selected_rows.
ENDCASE.
ENDMETHOD.

Retrieve Selected Rows:

DATA: lt_selected TYPE SALV_T_ROW.


lt_selected = lo_alv->get_selections( )->get_selected_rows( ).

Q36: What are field symbols and how are they used in ALV?
Answer:

Field Symbols:

Reference to data object without copying


Direct access to memory location
Improves performance for large datasets

Declaration:

FIELD-SYMBOL: <fs_field> TYPE any.


FIELD-SYMBOL: <fs_struct> LIKE LINE OF internal_table.

Assignment:

ASSIGN variable TO <fs_field>.


ASSIGN internal_table[ 1 ] TO <fs_struct>.

Usage in ALV:

LOOP AT lt_data ASSIGNING <fs_line>.


<fs_line>-field_name = new_value.
ENDLOOP.

Check Assignment:

IF <fs_field> IS ASSIGNED.
... <fs_field> is assigned ...
ELSE.
... not assigned ...
ENDIF.

Unassign:

UNASSIGN <fs_field>.

Benefits:

No data copying
Better performance
Direct manipulation
Memory efficient

Q37: How do you export ALV data to Excel in ABAP?


Answer:

Option 1: Using cl_salv_table (Built-in)


"Users can click export button in standard toolbar"
lo_alv->display( ).

Option 2: Using OLE Automation

DATA: lo_excel TYPE ole2_object.


CREATE OBJECT lo_excel '[Link]'.
SET PROPERTY OF lo_excel 'Visible' = 1.

... populate excel with data ...

SAVE OBJECT lo_excel.


FREE OBJECT lo_excel.

Option 3: Direct File Writing

OPEN DATASET filename FOR OUTPUT IN TEXT MODE.


DO.
READ TABLE lt_data INTO ls_line.
IF sy-subrc NE 0. EXIT. ENDIF.
TRANSFER ls_line TO filename.
ENDDO.
CLOSE DATASET filename.

Q38: What are hierarchical ALV reports and how do you


create them?
Answer:

Hierarchical ALV: Display data with parent-child relationships.

Using cl_salv_tree:

DATA: lo_tree TYPE REF TO cl_salv_tree.


CALL METHOD cl_salv_tree=>factory(
IMPORTING r_salv_tree = lo_tree
CHANGING t_table = lt_parent_data ).

lo_tree->display( ).
Q39: How do you add colors and formatting to ALV cells?
Answer:

Create Color Field in Structure:

DATA BEGIN OF ls_data.


INCLUDE STRUCTURE mara.
DATA: color TYPE lvc_s_colo.
DATA END OF ls_data.

Set Cell Color:

LOOP AT lt_data INTO ls_data.


IF ls_data-mtart = 'FERT'.
ls_data-color = VALUE lvc_s_colo(
fname = 'MATNR'
color-int = 4 ). "Green"
ENDIF.
MODIFY lt_data FROM ls_data.
ENDLOOP.

Color Codes:

1 = Red
2 = Blue
3 = Yellow
4 = Green
5 = Magenta

Q40: What is the difference between list ALV and grid ALV?
Answer:

Feature List ALV Grid ALV


Complexity Simple Complex
Features Limited Rich
Edit Capability Limited Full
Performance Fast Slower
Hierarchies No Yes
Color Formatting Basic Advanced
Events Few Many

When to Use:
List ALV - Simple reports, read-only data
Grid ALV - Interactive reports, complex data, editing needed

CDS AND RAP


Q41: What is Core Data Services (CDS) in SAP ABAP?
Answer:

CDS (Core Data Services):

Framework for defining semantic data models


Based on ANSI SQL with extensions
Provides virtual data models (views)
Central to modern ABAP development

Key Features:

1. CDS Views - Virtual tables over database


2. Associations - Relationships between entities
3. Annotations - Metadata for UI/API
4. Calculations - Expressions in views
5. Security - Row-level filtering

CDS Layers:

1. Basic CDS Views - Define core entities


2. Composite Views - Combine multiple views
3. API Views - Expose for consumption

Example:

@[Link]: 'Material Master'


define view Material as select from mara {
key [Link] as MaterialNumber,
[Link] as MaterialGroup
}

Q42: Explain the RAP (RESTful ABAP Programming Model)


architecture.
Answer:
RAP Architecture: Three-layer design for Fiori applications.

Layers:

1. Data Modeling Layer

CDS entities define data structures


Associations and relationships
Semantic enrichment

2. Business Logic Layer

Behavior definitions (DEFINE BEHAVIOR)


Standard operations (Create, Read, Update, Delete)
Custom logic implementation
Validations and determinations

3. Service Layer

OData protocol binding


API exposure
Service definitions
Authorization/security

Key Components:

1. CDS Entity - Data model


2. Behavior Definition - Interface
3. Behavior Implementation - Business logic
4. Service Definition - API exposure
5. Service Binding - OData/Web service

Workflow:

1. Create CDS entity


2. Define behavior
3. Implement behavior logic
4. Create service definition
5. Create service binding
6. Test with Fiori/API client

Q43: What is a CDS entity and how is it different from a


database table?
Answer:

CDS Entity:
Virtual data model on top of database
Not physically stored
Defined using ABAP syntax
Can combine multiple tables
Support calculations and associations

Database Table:

Physical storage in database


Persistent data
Direct SQL access
No built-in associations

Comparison:

Aspect CDS Entity DB Table


Storage Virtual Physical
Persistence No Yes
Relationships Built-in (assoc) Foreign keys
Calculations Native In-query
Reusability High Limited
Performance Optimized by DB Direct access
Metadata Rich (annotations) Basic

Q44: How do you define associations in CDS views?


Answer:

Associations: Define relationships between CDS entities.

Syntax:

association [1..1|*|..n] to AssociatedEntity


as alias_name
on condition

Types:

1. One-to-One [1..1]
2. One-to-Many [*] or [..n]
3. Many-to-One [..1]

Example:
@[Link]: 'Order with Items'
define view OrderDetails as select from vbak {
key [Link] as OrderNumber,
[Link] as CreationDate,
association [*] to Items as items
on [Link] = [Link],
association [1] to Customer as customer
on [Link] = [Link]
}

Q45: What are CDS annotations and why are they


important?
Answer:

CDS Annotations: Metadata attached to CDS entities/fields.

Common Annotations:

@[Link] - Display label


@UI - User interface metadata
@Semantics - Field semantics
@Search - Search enablement
@AccessControl - Security

Example:

@[Link]: 'Customer Master'


@[Link]: { typeName: 'Customer' }
define view Customer as select from kna1 {
key [Link] as CustomerNumber,

@[Link]: { position: 10 }
kna1.name1 as CustomerName
}

Q46: How do you create a behavior definition for RAP?


Answer:

Behavior Definition Syntax:


managed;
implementation in class zcl_my_behavior;
datamodel alias MY_ENTITY {
create;
read;
update;
delete;

action DoSomething parameter ZP_ACTION_PARAM result [1] $self;

determination OnModify on modify { create; update; }


validation ValidateData on save { create; update; }
}

Q47: What is the difference between determinations and


validations in RAP?
Answer:

Determinations:

Calculate/populate field values


Automatic execution
Can modify data
Runs before create/update

Validations:

Check data integrity


Enforce business rules
Can abort transaction
Runs on save operation
Return error messages

Comparison:

Aspect Determination Validation


Purpose Calculate Check/Enforce
Modifies Data Yes No
Can Abort No Yes
Timing Before save On save
Error Handling N/A Returns errors
Q48: How do you implement side effects in RAP?
Answer:

Side Effects: Automatic refresh triggers for related data.

Syntax:

side effects {
modify entity Header triggers read entity Items;
modify entity Items triggers read entity Header;
}

Benefits:

Automatic UI refresh
No manual coding
Data consistency
Better user experience

Q49: What are service definitions and service bindings in


RAP?
Answer:

Service Definition: Defines which data and operations to expose.

@[Link]: 'Sales Order Service'


define service SalesOrderService {
expose SalesOrder;
expose SalesOrderItem;
}

Service Binding: Binds service to protocol (OData, REST).

@[Link]: 'Sales Order OData Service'


define service binding SalesOrderOData for service SalesOrderService {
type #OData_v4_presentation;
protocol binding type #OData;
}
Q50: How do you handle authorization and security in RAP?
Answer:

CDS-Level Security:

@[Link]: #CUBE
@[Link]: #CHECK
define view SecureData as select from vbak {
key [Link] as OrderNumber,
[Link] as SalesOrg
}

Role-Based Access:

define view AuthorizedView as select from vbak


where user-commercialoperator = [Link]
{
key [Link] as OrderNumber
}

Q51-60: Advanced RAP Topics


Additional 10 questions covering: Fiori Elements, Error Handling, Draft Functionality, Locking, Calculated Fields,
Projections, Value Helps, Custom Actions, Best Practices, and Debugging.

(See full document for comprehensive coverage of these topics)

PERFORMANCE & OPTIMIZATION


Q61: What are the best practices for ABAP performance
tuning?
Answer:

1. Database Query Optimization

Use indexed columns in WHERE


Select only needed fields
Use INNER JOIN instead of nested SELECTs
2. Internal Table Management

Use SORTED/HASHED tables for large datasets


Use field symbols instead of LOOP INTO
Minimize APPEND operations in loops

3. Avoid Full Table Scans

Add WHERE conditions early


Use proper table buffering
Leverage database statistics

4. Memory Management

Free large objects when done


Use field symbols for memory efficiency
Monitor memory usage

5. Code Optimization

Avoid nested loops


Use BINARY SEARCH for lookups
Cache repeated calculations

Q62-70: Additional Performance Topics


Additional 9 questions covering: SQL Trace, Runtime Analysis, Memory Leaks, Batch Processing, Parallel Processing,
CDS Performance, Index Strategies, RFC Optimization, and Load Testing.

ERROR HANDLING & DEBUGGING


Q71: What are the error handling mechanisms in ABAP?
Answer:

1. Traditional Error Handling

sy-subrc for function return codes


sy-msgty, sy-msgid for messages

2. Exception Handling (OOP)

TRY ... CATCH ... FINALLY


Predefined exceptions
Custom exceptions
3. Assertions

ASSERT condition
Development-time checks

Q72-80: Additional Debugging Topics


Additional 9 questions covering: Breakpoints, Watchpoints, Call Stack, Variable Inspection, Profiling, Log Analysis,
Memory Debugging, and Production Debugging.

INTERFACES & INTEGRATION


Q81: What are the different integration mechanisms in
ABAP?
Answer:

1. RFC (Remote Function Call)

Synchronous and asynchronous


Bidirectional communication

2. BAPI

Business logic exposure


Standard interfaces

3. Web Services

SOAP-based services
XML communication

4. OData Services

RESTful APIs
JSON data format

5. ALE/IDOC

Asynchronous batch processing


Document transfer

6. Middleware

SAP PI/PO
Third-party integration tools
Q82-90: Additional Integration Topics
Additional 9 questions covering: PI/PO Integration, Message Processing, Error Handling in Integration, Batch Interfaces,
File Transfer, Data Replication, Custom Adapters, and Integration Patterns.

S/4HANA & MODERN ABAP


Q91: What is SAP S/4HANA and how does it differ from
ERP?
Answer:

SAP S/4HANA:

Latest generation of SAP business suite


Built on SAP HANA (in-memory database)
Simplified data model
Real-time analytics
Cloud-native and on-premise deployment options

Key Differences from ERP:

1. In-Memory Database - HANA instead of traditional DB


2. Simplified Data Model - Reduced tables and complexity
3. Real-Time Processing - No batch processing delays
4. Analytics - Embedded analytics capabilities
5. User Experience - Modern Fiori UI
6. Cloud Ready - Can run on-premise or cloud

Q92: What is SAP ABAP Cloud and what are its constraints?
Answer:

ABAP Cloud:

Modern ABAP development environment


Built on SAP Business Technology Platform (BTP)
Restricted feature set for cloud safety

Constraints:

1. Limited ABAP language features


2. No direct database access (CDS only)
3. No global variables
4. Restricted class libraries
5. No legacy code support

Advantages:

Cloud-ready applications
Automatic scaling
Better security
Modern development practices

Q93-100: Advanced S/4HANA Topics


Additional 8 questions covering: Advanced CDS, Real-Time Transactional Processing, Intelligent Technologies, Machine
Learning in SAP, Digital Supply Chain, Environmental Sustainability, Industry Cloud Solutions, and Future ABAP
Roadmap.

CONCLUSION
This comprehensive guide covers 100 essential SAP ABAP and RAP interview questions spanning:

Fundamentals - Core ABAP concepts


Database Operations - SQL and transactions
Object-Oriented Programming - Classes and inheritance
ALV Reporting - User interfaces
CDS & RAP - Modern development model
Integration - System connectivity
Performance - Optimization techniques
S/4HANA - Latest SAP platform

Tips for Interview Success:

1. Understand the concepts deeply - Not just memorize answers


2. Provide real-world examples - Share project experience
3. Stay updated - S/4HANA and ABAP Cloud are evolving rapidly
4. Practice coding - Be ready for technical coding rounds
5. Understand business context - Know module-specific knowledge
6. Show problem-solving skills - Explain your thought process

Recommended Further Reading:

SAP ABAP Documentation - [Link]


SAP HANA Optimization Guide
Fiori Design Guidelines
RAP Development Guide
S/4HANA Implementation Guide

Best Practices:

Keep learning continuously


Join SAP community forums
Practice on SAP sandbox environments
Contribute to open-source SAP projects
Network with SAP professionals

APPENDIX - QUICK REFERENCE


Common Transactions:

SE38 - ABAP Editor


SE11 - ABAP Dictionary
SE24 - Class Builder
SE80 - Object Navigator
ST05 - SQL Trace
SE30 - Runtime Analysis
Transaction ST22 - Short Dumps
SAT - ABAP Profiling Tool

Common Commands:

COMMIT WORK - Save changes


ROLLBACK WORK - Undo changes
CALL FUNCTION - Call FM
PERFORM - Call subroutine
CREATE OBJECT - Instantiate class
TRY...CATCH - Exception handling

This document is a comprehensive study guide for SAP ABAP and RAP professionals. Regular review and practice of
these concepts will significantly enhance your interview performance and professional capabilities in the SAP ecosystem.

End of Document

You might also like