- SAP ABAP Reports
- Report Types and Events
- Message Class
- Example of Classical Report
- Example of Interactive Report
- Example of ALV Report
- Example of Blocked ALV Report
- Example of Hierarchical Report
- Module Pool Programming
- Screen Painter Components
- Events in Flow Logic Editor
- Screen Elements and Creation Steps
- Working with Validations
- Database Operations
- OO Programming in ABAP
- Types of Programming Structure
- Key Features of OO Programming
- Classes and Objects
- Types of Visibility Section
- Class Defination and Implementation
- Object Creation for Class
- Method Declaration and Implementation
- Types of Component Class
- Global Class and implement GLOBAL methods
- OOP's ALV
- OOP's BDC
24OOP0509 – OOP’s BDC
OOPS BDC in SAP: A Simple Guide
What is OOPS BDC?
OOPS BDC refers to using Object-Oriented Programming for performing BDC. In the procedural method, BDC is managed using transaction codes like `SM35`, or by writing standard BDC programs with function modules like `CALL TRANSACTION` or `SESSION METHOD`.
In OOPS BDC, we encapsulate the entire BDC logic in objects, making the code more modular, reusable and maintainable. OOPS BDC allows developers to manage the uploading process with more flexibility and scalability.
Key Components of OOPS BDC
The main class used for OOPS BDC is CL_BDC_SESSION. This class helps manage BDC sessions and transactions in an object-oriented way. Below are the steps involved in OOPS BDC:
- CL_BDC_SESSION: This is the core class that handles the creation and execution of BDC sessions.
- BDCDATA Structure: This standard structure is still used for storing the transactional data that will be processed during the BDC session.
- Methods of CL_BDC_SESSION: Methods like `CREATE_SESSION` and `PROCESS_SESSION` are used to create and execute sessions.
Steps to Create a Simple OOPS BDC Program
Let’s walk through the steps to create a basic OOPS BDC program for updating data in an SAP table using the session method.
- Data Declaration
First, declare the necessary variables and the internal table for the BDC data.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_bdcdata TYPE bdcdata,
bdc_session TYPE REF TO cl_bdc_session.
- Populate BDCDATA Structure
The `BDCDATA` structure holds the screen and field values for the BDC transaction. You need to fill this structure with the relevant data for each screen and field in the transaction.
CLEAR wa_bdcdata.
wa_bdcdata-program = ‘SAPLMM03’. “Program name
wa_bdcdata-dynpro = ‘0101’. “Screen number
wa_bdcdata-dynbegin = ‘X’. “Start of the screen
APPEND wa_bdcdata TO it_bdcdata.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = ‘MATNR’. “Field name
wa_bdcdata-fval = ‘123456’. “Field value (Material Number)
APPEND wa_bdcdata TO it_bdcdata.
- Create a BDC Session Using OOP
Now, create an instance of the `CL_BDC_SESSION` class and pass the BDCDATA internal table to create a new session.
bdc_session = NEW cl_bdc_session( ).
bdc_session->create_session(
EXPORTING
session_name = ‘MY_SESSION’ ” Name of the BDC session
TABLES
t_bdcdata = it_bdcdata ” BDC data table
).
- Process the BDC Session
Once the session is created, you can process it by calling the method to execute the session.
bdc_session->process_session( ‘MY_SESSION’ ).
- Handle Errors and Messages
You can handle errors and retrieve messages after processing the session to monitor the success or failure of the BDC process.
IF sy-subrc = 0.
WRITE: ‘BDC Session processed successfully’.
ELSE.
WRITE: ‘Error occurred in BDC processing’.
ENDIF.
Advantages of OOPS BDC
- Modular and Reusable Code: By using object-oriented programming, you can encapsulate BDC logic in reusable classes and methods.
- Improved Error Handling: OOP allows for better error handling using exception classes and messages.
- Cleaner and More Readable Code: OOP structures the code into meaningful classes and methods, improving readability and maintainability.
- Scalability: As the complexity of the program grows, OOPS BDC makes it easier to manage and extend the code.
- Enhanced Flexibility: OOPS BDC provides more control over the session and transaction processing.
Author : Aniket Pawar, 9373518385
24OOP0509 – OOP’s BDC
OOPS BDC in SAP: A Simple Guide
What is OOPS BDC?
OOPS BDC refers to using Object-Oriented Programming for performing BDC. In the procedural method, BDC is managed using transaction codes like `SM35`, or by writing standard BDC programs with function modules like `CALL TRANSACTION` or `SESSION METHOD`.
In OOPS BDC, we encapsulate the entire BDC logic in objects, making the code more modular, reusable and maintainable. OOPS BDC allows developers to manage the uploading process with more flexibility and scalability.
Key Components of OOPS BDC
The main class used for OOPS BDC is CL_BDC_SESSION. This class helps manage BDC sessions and transactions in an object-oriented way. Below are the steps involved in OOPS BDC:
- CL_BDC_SESSION: This is the core class that handles the creation and execution of BDC sessions.
- BDCDATA Structure: This standard structure is still used for storing the transactional data that will be processed during the BDC session.
- Methods of CL_BDC_SESSION: Methods like `CREATE_SESSION` and `PROCESS_SESSION` are used to create and execute sessions.
Steps to Create a Simple OOPS BDC Program
Let’s walk through the steps to create a basic OOPS BDC program for updating data in an SAP table using the session method.
- Data Declaration
First, declare the necessary variables and the internal table for the BDC data.
DATA: it_bdcdata TYPE TABLE OF bdcdata,
wa_bdcdata TYPE bdcdata,
bdc_session TYPE REF TO cl_bdc_session.
- Populate BDCDATA Structure
The `BDCDATA` structure holds the screen and field values for the BDC transaction. You need to fill this structure with the relevant data for each screen and field in the transaction.
CLEAR wa_bdcdata.
wa_bdcdata-program = ‘SAPLMM03’. “Program name
wa_bdcdata-dynpro = ‘0101’. “Screen number
wa_bdcdata-dynbegin = ‘X’. “Start of the screen
APPEND wa_bdcdata TO it_bdcdata.
CLEAR wa_bdcdata.
wa_bdcdata-fnam = ‘MATNR’. “Field name
wa_bdcdata-fval = ‘123456’. “Field value (Material Number)
APPEND wa_bdcdata TO it_bdcdata.
- Create a BDC Session Using OOP
Now, create an instance of the `CL_BDC_SESSION` class and pass the BDCDATA internal table to create a new session.
bdc_session = NEW cl_bdc_session( ).
bdc_session->create_session(
EXPORTING
session_name = ‘MY_SESSION’ ” Name of the BDC session
TABLES
t_bdcdata = it_bdcdata ” BDC data table
).
- Process the BDC Session
Once the session is created, you can process it by calling the method to execute the session.
bdc_session->process_session( ‘MY_SESSION’ ).
- Handle Errors and Messages
You can handle errors and retrieve messages after processing the session to monitor the success or failure of the BDC process.
IF sy-subrc = 0.
WRITE: ‘BDC Session processed successfully’.
ELSE.
WRITE: ‘Error occurred in BDC processing’.
ENDIF.
Advantages of OOPS BDC
- Modular and Reusable Code: By using object-oriented programming, you can encapsulate BDC logic in reusable classes and methods.
- Improved Error Handling: OOP allows for better error handling using exception classes and messages.
- Cleaner and More Readable Code: OOP structures the code into meaningful classes and methods, improving readability and maintainability.
- Scalability: As the complexity of the program grows, OOPS BDC makes it easier to manage and extend the code.
- Enhanced Flexibility: OOPS BDC provides more control over the session and transaction processing.
Author : Aniket Pawar, 9373518385