Skip to main content

modularization 1

Modularization Techniques:
===========================
modularilization techniques are used to divide the business processing logic into reuseable block of statements.

this is tow step procedure.
===========================
1. define the resuable block.
2.calling the resuable block.

two types of modularilization techniques:
========================================
source code modularization

1. include.
2. macros.


functionality modularization

1.subroutines
2. function modules.


Include:
========

we cannot execute an include program independently, whereas the same include program can be included in any
number of executable programs.

include programs are used to improve the redeablity of the program.

in the real time include programs are used to maintain the all the decleration of the program.


STEPS TO CREATE INCLUDE PROGRAM:
=================================
EXECUTE SE38.

Provide the program name.

click on create .

provide the title.
select the type is include program.

click on save.
local object or own package.


syntax of calling the include program.
======================================

INCLUDE <INCLUDE PROGRAM NAME>.




NOTE :
======
If you make the changes in the include it would reflect in all the programs where the include is used.


MACROS:
======


Macros are used to perform the arthematical operations .
Macros can take up to nine-place holders [&1 &2 &3 &4 &5 &6 &7 &8 &9]

If you want to maintain the same set of statements in more than one location of the same program instead
of maintaing in multiple locations , it is better to maintain those statements in the macro defentions
and later we call the same macro defention from multiple locations of the same program.


Syntax of defiing the macro:
============================

Define <macro name>.
----
-----
----
business logic
end-of-definition.


syntax of calling the macro.
=============================

<macro name > <place holder1 value > <palce holder2> ....


Note :
=====
 in macors defention should be the first and the calling should be the next.



examples :
==========


perform the addition of two numbers by using macros.

Data r type i.

define ADD1.

R = &2 + &1.

END-OF-SELECTION.

ADD1  15 25 .

WRITE R.


----------------------------------------

Data R type i.
define zcal.

r = &1 &2 &3 .

end-of-definition.


zcal 30 * 3.

write r.

zcal 25 + 15.




--------------------------------


types : begin of ty_t001,
        bukrs tyep t001-bukrs,
butxt type t001-butxt,
ort01 type t001-ort01,
end of tye_t001.

data : wa_t001 type ty_t001,
       it_t001 type table of ty_t001.
 
define fill_itab.
wa_t001-bukrs = &1.
wa_t001-butxt = &2.
wa_t001-ort01 = &3.

end-of-selection.

fill_itab  '1000' 'TCS' 'HYD'.
fill_itab   '2000' 'IBM' 'CHE'.

loop at it_too1 into wa_t001.

write : / wa_t001-bukrs , wa_t001-butxt,
          wa_t001-ort01.
endloop.



Note :
======

we cannot next the defention of macros.

define abc.
-----
----
   define xyz.
    -----
    -----

end-of-definition.

end-of-definition.

Subroutines:
===========

Subroutines are procedures that we can define in any ABAP program and calling from the same or
some other abap program.


procedure is the collection of statements.


syntax of defining the subroutine.
=================================

form <formname> using    <iv1> type <datatype>
                         <iv2> type <datatype>
    changing  <ov1> type <datatype>
          <ov2> type <datatype>.
 
 
 
--------
-------
Business logic.

endform.


Syntax of calling the subroutine.
=================================

perform <form name > using <ip1>  <ip2>----
                     changing <op1> <op2>----.



Note :
=====
In subroutines calling should be the first and definition should be the next.


Note :
======
we cannot place any executable statements after the defention of the subroutine.


eg:
===

addtion of two numbers.
=======================

Data r tyep i.

parameter : p1 type i,
            p2 tyep i.

perform ADD1 using p1 p2 changing r.

write r.

from add1 using a type i
                b type i
changing c tyep i.

c = a + b.
endform.



There are two types od subroutine.
=================================

1. internal subroutine.
2. external subroutine.


Internal subroutine:
====================

Internal subroutine is nothing but the defention of the subroutine as well as
calling of the subroutine in the same program.


External subroutine:
====================
External subroutine is nothing but the defention of the subroutine in one program and calling of the subroutine
in some other program.


Syntax of calling the external subroutine program.
==================================================
perform <form name> in program <program name which contains the definition>
                     using    <ip1> <ip2>-----
changing <op1> <op2>-----.

Note :
=====
the form uses parameters called as actual parameter , calling perform uses parameter is called as formal parameters.

zsprexe2.
==========

data result type i.

perform ADD1 in program ZSPREXE1
       using 13 12
   changing result.
 
Write result.


zsprexe1
========

Data r type i.

parameter : p1 type i,
            p2 tyep i.

perform ADD1 using p1 p2 changing r.

write r.

from add1 using a type i
                b type i
changing c tyep i.

c = a + b.
endform.






Comments

Popular posts from this blog

ABAP BASICS CONTINUEATION

message: daily just follow my post maximum i will cover upto 90% of abap.                   DATA TYPES IN ABAP Data type specifies what type of the variable it is. data types in abap are divided into two categories.                                    NUMERIC DATATYPE                                   CHARACTER DATATYPE         1. Integer  [ I ]                                             1. Char  [ C ]           2. Float       [ F ]                                         ...

STEPS TO LOG ON TO SAP

            STEPS   TO   UP (ON) THE  SERVER: >> Double  click  on   the  SAP  Management  console  on desktop.   >> Select   the   server   , right   click ,   all tasks,  start. >> Provide  the  password. >>Expand  the server [ECC6], double click on the  ABAP WP               Table  in   the  leftside  , contiuncely  click  on  Refresh  button       until  the  status  is  wait   then  minimize  the  server. >>  Check  until  the  status  is  wait  ,if  it is  in  run  status  you             cannot  login.  so  check  until  status  is  wait. ...

INTRODUCTION TO SAP ABAP

                                                        SAP SAP   stands   as Systems Applications  and  Products in data processing. manufacturing unit Purchasing : The    purchasing department purchases  raw materials from the shops . Warehouse: The raw materials which are received  by  the unit is stored in the ware house. Finance: The amount of the raw materials are paid to shops by the finance department. Production: The production department looks after the production from the raw materials which are in the warehouse. Sales and Distribution: This department looks after the sales. Shipping: Shipping department looks after delevering the products from ware houseto the customers. And again finance department collects the amount from the customers. Human resou...