SlideShare a Scribd company logo
Modularisation Techniques
• modularization makes ABAP 
programs easier to read and 
maintain, as well as avoiding 
redundancy, increasing the 
reusability of source code, and 
encapsulating data.
Modularization Techniques 
• Macros 
• Include programs 
• Subroutine 
• Functional modules
• If you want to reuse the same set of 
statements more than once in a program, you 
can include them in a macro. 
• You can only use a macro within the program 
in which it is defined, and it can only be called 
in lines of the program following its definition. 
Macros can be useful for long calculations or 
complex WRITE statements.
• Syntax 
DEFINE <macro_name> 'Macro Statements 
END-OF-DEFINITION. 
Macros can use Parameters &N where N = 
1,2,3...
• DATA: number1 TYPE I VALUE 1. 
• DEFINE increment. 
• ADD 1 to &1. 
• WRITE &1. 
• END-OF-DEFINITION. 
• Increment number1. 
• WRITE number1. 
• Output: 2
Include Programs 
If you want to use the same sequence of statements in several 
programs, you can code them once in an include program. 
How to create include programs ? 
If you create an include program yourself, you must assign it the 
type I in its program attributes. You can also create or change an 
include program by double-clicking on the name of the program 
after the INCLUDE statement in your ABAP program. If the program 
exists, the ABAP Workbench navigates to it. If it does not exist, the 
system creates it for you. 
How to use Include programs ? 
An include program cannot run independently, but must be built 
into other programs. Include programs can contain other includes.
Example: 
Include Program 
***INCLUDE STARTTXT. 
WRITE: / 'Program started by', SY-UNAME, 
/ 'on host', SY-HOST, 
'date: ' , SY-DATUM, 
'time: ' , SY-UZEIT. 
ULINE. 
Main Program 
PROGRAM SAPMZTST. 
INCLUDE STARTTXT. 
This could produce the following output: 
Program started by SENTHIVEL 
on host ds0025 date: 09/07/2004 time: 03:15:40
Subroutines 
• Subroutines are principally for local 
modularization, that is, they are generally 
called from the program in which they are 
defined. You can use subroutines to write 
functions that are used repeatedly within a 
program. You can define subroutines in any 
ABAP program. 
• Subroutines: can be used locally and globally 
(external subroutine calls).
• . External Subroutines are subroutines that are 
called from another program. 
• There are two types of subroutines: 
• 
• 1) Internal subroutine: If the source code or body 
of the subroutine will be in the same ABAP/4 
program i.e. in the calling program which is called 
internal subroutine. 
• 
• 2) External subroutine: If the source code or body 
of the subroutine present other than the calling 
program which is called external subroutine. An 
external subroutine is one that resides in a 
different program that the perform statement 
that calls it.
• Report ztn1811 
• Perform (S1) (ztn1811) 
• 
• Report ztn1811 
• FORM s1 
• ----------- 
• ---------- 
• ENDFORM.
• Parameters 
• Parameters can be either local or reference to global 
variables. The memory for local parameters is allocated 
when the subroutine is called & freed when it ends. If 
we define variables on the form statement, the 
perform statement must pass a value to each of these 
variables. 
• 
• Global variables: A global variable is one that is defined 
outside of a subroutine by using the tables or data 
statement. It can be accessed from any point in the 
program be it inside an event or inside a subroutine. 
• 
• Local variables: A local variables is a variable that is 
defined inside a subroutine using local data or static’s 
statement. It is said to be local to subroutine.
• Formal parameters: Parameter names that 
appear on the form statements are called 
formal parameters. 
• Ex: FORM s1, using P1 changing P2, P3 
• Here P1, P2, P3 are called formal parameters. 
• Actual parameters: Parameter names that 
appears on the perform statement are called 
actual parameters. 
• Ex: PERFORM S1 using P1 changing P2, P3. 
• Here P1, P2, P3 are called actual parameters.
• There are three ways of passing parameters to a subroutine. 
• 1) Pass by reference 
• 2) Pass by value 
• 3) Pass by value & result 
• 1) Passing parameters by reference 
• During subroutine call, only the address of the actual 
parameter is transferred to the formal parameters i.e. pointer 
to the original memory or address location is passed. The 
formal parameter has no memory of its own & we work with 
the fields of the calling program with in a subroutine. So 
changes to the variable within the subroutine update the 
original memory location immediately i.e. the field contents in 
the calling program also changes.
• 2. Passing parameters by value : 
• 
• When you pass a parameters by value, new 
memory is allocated for the value i.e. the 
formal parameters are created as copies of the 
actual parameters, thus formal parameters 
have memory of their own i.e. the memory 
allocated when the subroutine is called and 
freed when the subroutine returns. Therefore 
changes to the formal parameters have no 
effect on the actual parameters.
• 3. Passing parameters by value & result: 
• 
• Pass by value & result is similar to pass by 
reference like Pass by value, a new memory 
area is allocated & it frees when the 
subroutine ends. When the end form 
statement executes, it copies the value of the 
local memory area back into the original 
memory area changes to the parameter with 
in the subroutine are reflected in the original 
but not until subroutine returns.
• Leaving subroutine 
• You can exit out of a subroutine at any time using the 
following statements. 
• 1) Stop: Immediately leaves the subroutine & goes 
directly to the end of selection event. 
• 2) Exit: It leaves the loop, subroutine or comes out of the 
program & display the result without any condition. 
• 3. Check: It also comes or immediately leaves the 
subroutine but it depends on logical expression. If it is 
false comes out of the loop or subroutine.
Function group and Function module 
• Function groups are created using transaction 
SE37 (function builder). A 
• Function Group is realized in the SAP Software 
system as a program, containing 
• a logically related set of function modules. 
• Create the function group by selecting the 
menu path Goto -> Function Groups 
• -> Create Group.
Function Module 
• Function modules are created using transaction SE37 
(function builder). The standard SAP system has a number 
of predefined function modules. Function Modules are 
Global ABAP programs created by SAP for reusable 
purpose. 
• Function modules are best used for carrying out database 
updates and communicating with different SAP systems. 
• 
• In contrast to subroutines, function modules do not need to 
be defined in the source of your ABAP program. Function 
modules may have both input and output parameters. The 
input parameters can be mandatory or optional.
• You can also assign default values to 
parameters. Function modules also provide 
the option of exception handling, which 
catches errors when the function 
• module executes. You may also test function 
modules from transaction SE37 before 
including them in your programs. 
• Function Modules must begin with a Z_ or a 
Y_, and can be created as follows:
• The Attributes of the function module should be 
reviewed first, as it controls the behavior of the overall 
function module. 
• The processing type controls the behavior of the 
function module. 
• Normal Function Module 
Used for modularizing code and is not externally visible 
to other systems, but globally visible within the same 
SAP software system. 
Remote Function Module 
Visible to external systems, and thus can be called via 
the RFC gateway.
• Update Function Module 
• Denotes the use of the function module for 
Asynchronous update purposes.
Interface of function module 
Import 
• Data to be received from the calling program 
export 
• Data to be returned to the calling program 
• Changing 
• Data to be received and returned using the 
same reference variable
• Tables 
• Obsolete interface for passing arrays of 
information 
• Exceptions 
• Exceptions , resulting in non zero values of the 
System variable SY-SUBRC 
• Exceptions are raised using the RAISING 
<exception> command in the source code of 
the function module.
• Note the use of the RAISE statement in the 
code above to trigger an exception. 
• When the RAISE statement occurs, the 
program processing jumps to the 
ENDFUNCTION, and the control is passed back 
to the calling application.
• Testing the Function Module 
• The Function Builder has its own test 
workbench, and can be accessed using the 
• TEST icon, the same one used in the ABAP 
Editor.
Ad

More Related Content

What's hot (20)

Dialog programming ABAP
Dialog programming ABAPDialog programming ABAP
Dialog programming ABAP
Jefferson Mutuva
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
Satheesh Kanna
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Sap abap real time questions
Sap abap real time questionsSap abap real time questions
Sap abap real time questions
techie_gautam
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
Kranthi Kumar
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Table
sapdocs. info
 
Dialog Programming Overview
Dialog Programming OverviewDialog Programming Overview
Dialog Programming Overview
sapdocs. info
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
Jugul Crasta
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
Garuda Trainings
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
Akash Bhavsar
 
ABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type GroupABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type Group
sapdocs. info
 
Sap abap-data structures and internal tables
Sap abap-data structures and internal tablesSap abap-data structures and internal tables
Sap abap-data structures and internal tables
Mustafa Nadim
 
Alv theory
Alv theoryAlv theory
Alv theory
Phani Kumar
 
Sap abap material
Sap abap materialSap abap material
Sap abap material
Kranthi Kumar
 
Sap abap interview questions
Sap abap interview questionsSap abap interview questions
Sap abap interview questions
kssr99
 
External View Creation Guide
External View Creation GuideExternal View Creation Guide
External View Creation Guide
Abhishek Agrawal
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
sapdocs. info
 
New features-in-abap-7.4
New features-in-abap-7.4New features-in-abap-7.4
New features-in-abap-7.4
swati chavan
 
Manual oracle forms 6i
Manual oracle forms 6iManual oracle forms 6i
Manual oracle forms 6i
UMSA
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
Satheesh Kanna
 
1000 solved questions
1000 solved questions1000 solved questions
1000 solved questions
Kranthi Kumar
 
Sap abap real time questions
Sap abap real time questionsSap abap real time questions
Sap abap real time questions
techie_gautam
 
Chapter 02 sap script forms
Chapter 02 sap script formsChapter 02 sap script forms
Chapter 02 sap script forms
Kranthi Kumar
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
Noman Mohamed Hanif
 
ABAP Open SQL & Internal Table
ABAP Open SQL & Internal TableABAP Open SQL & Internal Table
ABAP Open SQL & Internal Table
sapdocs. info
 
Dialog Programming Overview
Dialog Programming OverviewDialog Programming Overview
Dialog Programming Overview
sapdocs. info
 
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda TrainingsSAP ABAP Latest Interview Questions with Answers by Garuda Trainings
SAP ABAP Latest Interview Questions with Answers by Garuda Trainings
Garuda Trainings
 
SAP ABAP - Needed Notes
SAP   ABAP - Needed NotesSAP   ABAP - Needed Notes
SAP ABAP - Needed Notes
Akash Bhavsar
 
ABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type GroupABAP Message, Debugging, File Transfer and Type Group
ABAP Message, Debugging, File Transfer and Type Group
sapdocs. info
 
Sap abap-data structures and internal tables
Sap abap-data structures and internal tablesSap abap-data structures and internal tables
Sap abap-data structures and internal tables
Mustafa Nadim
 
Sap abap interview questions
Sap abap interview questionsSap abap interview questions
Sap abap interview questions
kssr99
 
External View Creation Guide
External View Creation GuideExternal View Creation Guide
External View Creation Guide
Abhishek Agrawal
 
List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
sapdocs. info
 
New features-in-abap-7.4
New features-in-abap-7.4New features-in-abap-7.4
New features-in-abap-7.4
swati chavan
 
Manual oracle forms 6i
Manual oracle forms 6iManual oracle forms 6i
Manual oracle forms 6i
UMSA
 

Similar to Modularisation techniques new (20)

Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
AmanuelZewdie4
 
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).pptchapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
harinipradeep15
 
SPCC_Sem6_Chapter 6_Code Optimization part
SPCC_Sem6_Chapter 6_Code Optimization partSPCC_Sem6_Chapter 6_Code Optimization part
SPCC_Sem6_Chapter 6_Code Optimization part
NiramayKolalle
 
Coding
CodingCoding
Coding
Anand Mutyala
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
Sub-programs
Sub-programsSub-programs
Sub-programs
Forrester High School
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
Milind Patil
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprograms
Munawar Ahmed
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki304759
 
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
ceng2404314334535365_hgf66353week_07-08_v0.8.pdfceng2404314334535365_hgf66353week_07-08_v0.8.pdf
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
eagac2004
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural Programming
Deepam Aggarwal
 
Functions
FunctionsFunctions
Functions
Online
 
C programming
C programmingC programming
C programming
Jigarthacker
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
Diwakar Pratap Singh 'Deva'
 
Testing Frameworks
Testing FrameworksTesting Frameworks
Testing Frameworks
Moataz Nabil
 
Plc part 3
Plc  part 3Plc  part 3
Plc part 3
Taymoor Nazmy
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
Using general sub procedures
Using general sub proceduresUsing general sub procedures
Using general sub procedures
Danica Denice Epino
 
Software engineering topics,coding phase in sdlc
Software engineering topics,coding phase in sdlcSoftware engineering topics,coding phase in sdlc
Software engineering topics,coding phase in sdlc
dhandesumit71
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
AmanuelZewdie4
 
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).pptchapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
harinipradeep15
 
SPCC_Sem6_Chapter 6_Code Optimization part
SPCC_Sem6_Chapter 6_Code Optimization partSPCC_Sem6_Chapter 6_Code Optimization part
SPCC_Sem6_Chapter 6_Code Optimization part
NiramayKolalle
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
Lecture11 abap on line
Lecture11 abap on lineLecture11 abap on line
Lecture11 abap on line
Milind Patil
 
10 implementing subprograms
10 implementing subprograms10 implementing subprograms
10 implementing subprograms
Munawar Ahmed
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
miki304759
 
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
ceng2404314334535365_hgf66353week_07-08_v0.8.pdfceng2404314334535365_hgf66353week_07-08_v0.8.pdf
ceng2404314334535365_hgf66353week_07-08_v0.8.pdf
eagac2004
 
Monolithic and Procedural Programming
Monolithic and Procedural ProgrammingMonolithic and Procedural Programming
Monolithic and Procedural Programming
Deepam Aggarwal
 
Functions
FunctionsFunctions
Functions
Online
 
Testing Frameworks
Testing FrameworksTesting Frameworks
Testing Frameworks
Moataz Nabil
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
iamluqman0403
 
Software engineering topics,coding phase in sdlc
Software engineering topics,coding phase in sdlcSoftware engineering topics,coding phase in sdlc
Software engineering topics,coding phase in sdlc
dhandesumit71
 
Ad

Recently uploaded (20)

Chromatography_Detailed_Information.docx
Chromatography_Detailed_Information.docxChromatography_Detailed_Information.docx
Chromatography_Detailed_Information.docx
NohaSalah45
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Induction Program of MTAB online session
Induction Program of MTAB online sessionInduction Program of MTAB online session
Induction Program of MTAB online session
LOHITH886892
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your CompetitorsAI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
Contify
 
AllContacts Vs AllSubscribers - SFMC.pptx
AllContacts Vs AllSubscribers - SFMC.pptxAllContacts Vs AllSubscribers - SFMC.pptx
AllContacts Vs AllSubscribers - SFMC.pptx
bpkr84
 
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
ThanushsaranS
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
Chromatography_Detailed_Information.docx
Chromatography_Detailed_Information.docxChromatography_Detailed_Information.docx
Chromatography_Detailed_Information.docx
NohaSalah45
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Minions Want to eat presentacion muy linda
Minions Want to eat presentacion muy lindaMinions Want to eat presentacion muy linda
Minions Want to eat presentacion muy linda
CarlaAndradesSoler1
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docxMASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
MASAkkjjkttuyrdquesjhjhjfc44dddtions.docx
santosh162
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Developing Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response ApplicationsDeveloping Security Orchestration, Automation, and Response Applications
Developing Security Orchestration, Automation, and Response Applications
VICTOR MAESTRE RAMIREZ
 
Induction Program of MTAB online session
Induction Program of MTAB online sessionInduction Program of MTAB online session
Induction Program of MTAB online session
LOHITH886892
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your CompetitorsAI Competitor Analysis: How to Monitor and Outperform Your Competitors
AI Competitor Analysis: How to Monitor and Outperform Your Competitors
Contify
 
AllContacts Vs AllSubscribers - SFMC.pptx
AllContacts Vs AllSubscribers - SFMC.pptxAllContacts Vs AllSubscribers - SFMC.pptx
AllContacts Vs AllSubscribers - SFMC.pptx
bpkr84
 
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
ThanushsaranS
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
Ad

Modularisation techniques new

  • 2. • modularization makes ABAP programs easier to read and maintain, as well as avoiding redundancy, increasing the reusability of source code, and encapsulating data.
  • 3. Modularization Techniques • Macros • Include programs • Subroutine • Functional modules
  • 4. • If you want to reuse the same set of statements more than once in a program, you can include them in a macro. • You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition. Macros can be useful for long calculations or complex WRITE statements.
  • 5. • Syntax DEFINE <macro_name> 'Macro Statements END-OF-DEFINITION. Macros can use Parameters &N where N = 1,2,3...
  • 6. • DATA: number1 TYPE I VALUE 1. • DEFINE increment. • ADD 1 to &1. • WRITE &1. • END-OF-DEFINITION. • Increment number1. • WRITE number1. • Output: 2
  • 7. Include Programs If you want to use the same sequence of statements in several programs, you can code them once in an include program. How to create include programs ? If you create an include program yourself, you must assign it the type I in its program attributes. You can also create or change an include program by double-clicking on the name of the program after the INCLUDE statement in your ABAP program. If the program exists, the ABAP Workbench navigates to it. If it does not exist, the system creates it for you. How to use Include programs ? An include program cannot run independently, but must be built into other programs. Include programs can contain other includes.
  • 8. Example: Include Program ***INCLUDE STARTTXT. WRITE: / 'Program started by', SY-UNAME, / 'on host', SY-HOST, 'date: ' , SY-DATUM, 'time: ' , SY-UZEIT. ULINE. Main Program PROGRAM SAPMZTST. INCLUDE STARTTXT. This could produce the following output: Program started by SENTHIVEL on host ds0025 date: 09/07/2004 time: 03:15:40
  • 9. Subroutines • Subroutines are principally for local modularization, that is, they are generally called from the program in which they are defined. You can use subroutines to write functions that are used repeatedly within a program. You can define subroutines in any ABAP program. • Subroutines: can be used locally and globally (external subroutine calls).
  • 10. • . External Subroutines are subroutines that are called from another program. • There are two types of subroutines: • • 1) Internal subroutine: If the source code or body of the subroutine will be in the same ABAP/4 program i.e. in the calling program which is called internal subroutine. • • 2) External subroutine: If the source code or body of the subroutine present other than the calling program which is called external subroutine. An external subroutine is one that resides in a different program that the perform statement that calls it.
  • 11. • Report ztn1811 • Perform (S1) (ztn1811) • • Report ztn1811 • FORM s1 • ----------- • ---------- • ENDFORM.
  • 12. • Parameters • Parameters can be either local or reference to global variables. The memory for local parameters is allocated when the subroutine is called & freed when it ends. If we define variables on the form statement, the perform statement must pass a value to each of these variables. • • Global variables: A global variable is one that is defined outside of a subroutine by using the tables or data statement. It can be accessed from any point in the program be it inside an event or inside a subroutine. • • Local variables: A local variables is a variable that is defined inside a subroutine using local data or static’s statement. It is said to be local to subroutine.
  • 13. • Formal parameters: Parameter names that appear on the form statements are called formal parameters. • Ex: FORM s1, using P1 changing P2, P3 • Here P1, P2, P3 are called formal parameters. • Actual parameters: Parameter names that appears on the perform statement are called actual parameters. • Ex: PERFORM S1 using P1 changing P2, P3. • Here P1, P2, P3 are called actual parameters.
  • 14. • There are three ways of passing parameters to a subroutine. • 1) Pass by reference • 2) Pass by value • 3) Pass by value & result • 1) Passing parameters by reference • During subroutine call, only the address of the actual parameter is transferred to the formal parameters i.e. pointer to the original memory or address location is passed. The formal parameter has no memory of its own & we work with the fields of the calling program with in a subroutine. So changes to the variable within the subroutine update the original memory location immediately i.e. the field contents in the calling program also changes.
  • 15. • 2. Passing parameters by value : • • When you pass a parameters by value, new memory is allocated for the value i.e. the formal parameters are created as copies of the actual parameters, thus formal parameters have memory of their own i.e. the memory allocated when the subroutine is called and freed when the subroutine returns. Therefore changes to the formal parameters have no effect on the actual parameters.
  • 16. • 3. Passing parameters by value & result: • • Pass by value & result is similar to pass by reference like Pass by value, a new memory area is allocated & it frees when the subroutine ends. When the end form statement executes, it copies the value of the local memory area back into the original memory area changes to the parameter with in the subroutine are reflected in the original but not until subroutine returns.
  • 17. • Leaving subroutine • You can exit out of a subroutine at any time using the following statements. • 1) Stop: Immediately leaves the subroutine & goes directly to the end of selection event. • 2) Exit: It leaves the loop, subroutine or comes out of the program & display the result without any condition. • 3. Check: It also comes or immediately leaves the subroutine but it depends on logical expression. If it is false comes out of the loop or subroutine.
  • 18. Function group and Function module • Function groups are created using transaction SE37 (function builder). A • Function Group is realized in the SAP Software system as a program, containing • a logically related set of function modules. • Create the function group by selecting the menu path Goto -> Function Groups • -> Create Group.
  • 19. Function Module • Function modules are created using transaction SE37 (function builder). The standard SAP system has a number of predefined function modules. Function Modules are Global ABAP programs created by SAP for reusable purpose. • Function modules are best used for carrying out database updates and communicating with different SAP systems. • • In contrast to subroutines, function modules do not need to be defined in the source of your ABAP program. Function modules may have both input and output parameters. The input parameters can be mandatory or optional.
  • 20. • You can also assign default values to parameters. Function modules also provide the option of exception handling, which catches errors when the function • module executes. You may also test function modules from transaction SE37 before including them in your programs. • Function Modules must begin with a Z_ or a Y_, and can be created as follows:
  • 21. • The Attributes of the function module should be reviewed first, as it controls the behavior of the overall function module. • The processing type controls the behavior of the function module. • Normal Function Module Used for modularizing code and is not externally visible to other systems, but globally visible within the same SAP software system. Remote Function Module Visible to external systems, and thus can be called via the RFC gateway.
  • 22. • Update Function Module • Denotes the use of the function module for Asynchronous update purposes.
  • 23. Interface of function module Import • Data to be received from the calling program export • Data to be returned to the calling program • Changing • Data to be received and returned using the same reference variable
  • 24. • Tables • Obsolete interface for passing arrays of information • Exceptions • Exceptions , resulting in non zero values of the System variable SY-SUBRC • Exceptions are raised using the RAISING <exception> command in the source code of the function module.
  • 25. • Note the use of the RAISE statement in the code above to trigger an exception. • When the RAISE statement occurs, the program processing jumps to the ENDFUNCTION, and the control is passed back to the calling application.
  • 26. • Testing the Function Module • The Function Builder has its own test workbench, and can be accessed using the • TEST icon, the same one used in the ABAP Editor.