Wednesday 29 June 2016

Subroutines



  • A subroutine is a block of code introduced by FORM and concluded by ENDFORM.
  • Defining Subroutines.

                             FORM <subroutine> [<parameters>].
                                    <statements>
                             ENDFORM.
  • Calling Subroutines. 
  • Internal subroutines have the source code in the calling ABAP/4 program:  
                            PERFORM <subroutine> [<parameters>].

  1. Internal Subroutines without passing parameters
  2. External Subroutines without passing parameters
  • Understanding pass by value and pass by reference.
  1. Pass by Reference
  2. Pass By Value
                                    

  • To know more.



  • Passing variable / tables to subroutine.
  • Defining Subroutine
                PERFORM <SUBROUTINE NAME> USING <AV1> <AV2>
                                                                               CHANGING <CHANGING1> <CHANGING2>
                                                                              TABLES <TABLE1> <TABLE2>.
  • Implementing Subroutine.
                        FORM <SUBROUTINE NAME > USING <FV1> <FV2>
                                                                                 CHANGING <CHANGING1> <CHANGING2>
                                                                                 TABLES <TABLE1> <TABLE2>.


                       ENDFORM.


  • In the above syntax <av1> and <av2> are actual parameters and <fv1> <fv2> are formal parameters.
  • Note :
  1. Perform and form must contain the same number of parameters.
  2. The syntax on the perform and form statements can differ.
  3. The syntax on the form statement alone determines the method by which a parameters is passed.
  4. The value() addition cannot be used on the perform statements.
  5. Using must come before changing.
  6. The addition using can only occurs once in a statement.. The same rule applies to changing.


No comments:

Post a Comment