Professional Documents
Culture Documents
3 Modularisation and BDC PDF
3 Modularisation and BDC PDF
3 Modularisation and BDC PDF
Modularisation Technique
&
BDCs
Modularization techniques
• Macros
• Include program
• Subroutines
• Function Module
Macros
Example
Defining Macros
DEFINE arithmetic.
result = &1 &2 &3.
Write: / ‘The result is ‘, result.
ENDDEFINE.
Calling Macros
arithmetic 4 + 5.
Output
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
Using Include programs
Syntax
INCLUDE <name_of_the_include>.
Example
REPORT zrssales10.
INCLUDE zrsdecla10.
….
Write: / ‘Date:’, sy-datum.
Subroutines
• Types of subroutine
– internal subroutines
– external subroutines
Defining and calling subroutine
Definition - Syntax
FORM <subr_name>.
<statement block>.
ENDFORM.
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.
Defining and calling subroutine…
Example
Defining the subroutine
PROGRAM formpool.
FORM show.
WRITE: / ‘Program started by’, sy-uname.
ENDFORM.
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>].…
Methods of passing parameters
1. Calling by Reference
2. Calling by value
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
2. Call by value
FORM..... USING...VALUE(<fii>)..
PERFORM... USING.......<aii>..
Tables
Specifies the tables that are to be passed to a function
module. Table parameters are always passed by
reference.
Exceptions
Shows how the function module reacts to exceptions.
The function definition is written in the editor (Source code)
Adding the function module to the program
[MESSAGE <mess>]
[FILTER <filt>].
• <dsn> can be a logical or physical file names
File Handling – READ DATASET
• Reads a file
• Syntax:
READ DATASET <dsn> INTO <f> [LENGTH <len>].
• Syntax:
- Writing to a dataset
TRANSFER <f> TO <dsn> [LENGTH <len>].
- Closing a dataset
CLOSE DATASET <dsn>.
BDC - Batch Data Communication
SAP Database
SAP Database
BDC Methods
• Classical Method
• Call Transaction
• Call Dialog
BDC Methods
• Creating a session on the batch input queue
Standard method.
• Call dialog
1) Outdated and more complex (Not Recommended)
Preparing a BDC Table
1) Program name
2) Screen number
3) Screen begin
4) Field name
5) Field value
Preparing a BDC Table
Example