Modularization techniques
Macros
Callable modules of program code Defining Macros - Syntax
DEFINE <macro>. <statements> ENDDEFINE.
Macros
Example
Defining Macros
DEFINE arithmetic. result = &1 &2 &3. Write: / The result is , result. ENDDEFINE.
The result is 9
Include Programs
If we want to use the same sequence of statements in several programs, we can code them once in an include program and call it in the other programs wherever it is required Include programs cannot contain PROGRAM or REPORT Statements Include programs cannot call themselves Include programs must contain complete statements
Subroutines
Program module that can be called by any program. You use subroutines to avoid having to write frequently used program components more than once. Data can be passed explicitly from and to subroutines. Types of subroutine
internal subroutines external subroutines
Calling - syntax
Internal Subroutines
PERFORM <subr_name>.
External Subroutines
PERFORM <subr_name> (<prog>) [IF FOUND]. <Prog> - Program name IF FOUND - If this is specified and there is no subroutine <sub> in the program <prog>, the system ignores the PERFORM statement.
Calling the subroutine from a program PROGRAM sapmztst. PERFORM show(formpool) IF FOUND
Passing parameters
Defining FORM <subr> [TABLES <formal table list>] [USING <formal input list>] [CHANGING <formal output list>]. Calling PERFORM <subr>[(<prog>)] [TABLES <actual table list>] [USING <actual input list>] [CHANGING <actual output list>].
1. Call by reference
FORM..... [USING <fi1>... <fi n>] [CHANGING <fo 1>... <fo n>]... PERFORM... [USING <ai1>... <ai n>] [CHANGING <ao 1>... <ao n>]...
Call by reference
Actual Parameters
PERFORM calculate_tax USING fl1 fl2. .. FORM calculate_tax USING f1 f2. CLEAR itab. MOVE f1 TO itab-fl1. APPEND itab. ENDFORM. Formal
Parameters
In this example, parameters are passed by reference. This is the most common, and most cost effective, method of parameter passing.
Function Builder
An ABAP Workbench Tool ABAP routines that are stored in a central function library Non application-specific, and available system wide
Export
Contains a list of the formal parameters that are used to receive data from a function module.
Changing
Contains a list of the formal parameters that are used both to pass data to and receive data from a function module.
Exceptions
Shows how the function module reacts to exceptions. The function definition is written in the editor (Source code)
Click PATTERN button in the edit program screen of the ABAP Editor
Choose the Call Function Radio button and give the name of the function module and enter it
<dsn> can be a logical or physical file names Logical file names can be created in customizing
- Closing a dataset
CLOSE DATASET <dsn>.
BDC - Methods
Batch Input
Sequential dataset bdc table
BDC Methods
Classical Method Call Transaction Call Dialog
BDC Methods
Creating a session on the batch input queue Standard method. 1) Offers management of sessions 2) Support for playing back 3) Correcting sessions that contain errors 4) Detailed logging
BDC Methods
Call transaction using 1) Offers faster processing than standard method 2) The playback, interactive correction, and logging facilities offered for batch input sessions are not available for CALL TRANSACTION USING. Call dialog 1) Outdated and more complex (Not Recommended)
0080
RM03M-WERKS
target pla
. .
Job Scheduling
Schedule a job SM35
Create a job Add program to be executed Set timing and date to be executed