- 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
24MPP2408 – Database Operations in MPP
In Module Pool Programming (MPP) in SAP ABAP, database operations are typically handled within the Process After Input (PAI) module. The PAI module is responsible for processing user inputs and executing the necessary actions, such as database operations, based on those inputs.
Key Points about PAI Module:
- PAI (Process After Input): This module is triggered after the user interacts with the screen (e.g., clicking a button, entering data). It processes the user commands and performs the required actions, including database operations like SELECT, INSERT, UPDATE, and DELETE.
SELECT Operation Example:
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘FETCH’.
” Fetch data from the database
SELECT SINGLE * FROM ztable INTO wa_ztable WHERE key_field = p_key.
IF sy-subrc = 0.
” Data found
MOVE-CORRESPONDING wa_ztable TO screen_fields.
MESSAGE ‘Data fetched successfully’ TYPE ‘S’.
ELSE.
” Data not found
MESSAGE ‘No data found’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
INSERT Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘SAVE’.
” Insert data into the database
MOVE-CORRESPONDING screen_fields TO wa_ztable.
INSERT INTO ztable VALUES wa_ztable.
IF sy-subrc = 0.
MESSAGE ‘Data saved successfully’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error saving data’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
UPDATE Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘UPDATE’.
” Update data in the database
MOVE-CORRESPONDING screen_fields TO wa_ztable.
UPDATE ztable SET field1 = wa_ztable-field1, field2 = wa_ztable-field2
WHERE key_field = wa_ztable-key_field.
IF sy-subrc = 0.
MESSAGE ‘Data updated successfully’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error updating data’ TYPE ‘E’.
ENDIF.
ENDCASE.
DELETE Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘DELETE’.
” Delete data from the database
DELETE FROM ztable WHERE key_field = p_key.
IF sy-subrc = 0.
MESSAGE ‘Data deleted successfully‘ TYPE ‘S’.
ELSE.
MESSAGE ‘Error deleting data’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
- PAI Module: Handles user inputs and performs database operations.
- Database Operations: Include SELECT, INSERT, UPDATE, and DELETE.
- sy-ucomm: System field that holds the function code of the user action.
- sy-subrc: System field that holds the return code of the last ABAP statement executed.
Author : Aniket Pawar, 9373518385
24MPP2408 – Database Operations in MPP
In Module Pool Programming (MPP) in SAP ABAP, database operations are typically handled within the Process After Input (PAI) module. The PAI module is responsible for processing user inputs and executing the necessary actions, such as database operations, based on those inputs.
Key Points about PAI Module:
- PAI (Process After Input): This module is triggered after the user interacts with the screen (e.g., clicking a button, entering data). It processes the user commands and performs the required actions, including database operations like SELECT, INSERT, UPDATE, and DELETE.
SELECT Operation Example:
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘FETCH’.
” Fetch data from the database
SELECT SINGLE * FROM ztable INTO wa_ztable WHERE key_field = p_key.
IF sy-subrc = 0.
” Data found
MOVE-CORRESPONDING wa_ztable TO screen_fields.
MESSAGE ‘Data fetched successfully’ TYPE ‘S’.
ELSE.
” Data not found
MESSAGE ‘No data found’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
INSERT Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘SAVE’.
” Insert data into the database
MOVE-CORRESPONDING screen_fields TO wa_ztable.
INSERT INTO ztable VALUES wa_ztable.
IF sy-subrc = 0.
MESSAGE ‘Data saved successfully’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error saving data’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
UPDATE Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘UPDATE’.
” Update data in the database
MOVE-CORRESPONDING screen_fields TO wa_ztable.
UPDATE ztable SET field1 = wa_ztable-field1, field2 = wa_ztable-field2
WHERE key_field = wa_ztable-key_field.
IF sy-subrc = 0.
MESSAGE ‘Data updated successfully’ TYPE ‘S’.
ELSE.
MESSAGE ‘Error updating data’ TYPE ‘E’.
ENDIF.
ENDCASE.
DELETE Operation Example.
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN ‘DELETE’.
” Delete data from the database
DELETE FROM ztable WHERE key_field = p_key.
IF sy-subrc = 0.
MESSAGE ‘Data deleted successfully‘ TYPE ‘S’.
ELSE.
MESSAGE ‘Error deleting data’ TYPE ‘E’.
ENDIF.
ENDCASE.
ENDMODULE.
- PAI Module: Handles user inputs and performs database operations.
- Database Operations: Include SELECT, INSERT, UPDATE, and DELETE.
- sy-ucomm: System field that holds the function code of the user action.
- sy-subrc: System field that holds the return code of the last ABAP statement executed.
Author : Aniket Pawar, 9373518385