0% found this document useful (0 votes)
63 views2 pages

Subroutines: Form - Endform

This document discusses subroutines, macros, and parameter passing in ABAP. Subroutines are used to call reusable pieces of code within a program using the PERFORM statement. Parameters can be passed by value, where only copies are passed, or by reference, where the addresses are passed. Macros are reusable blocks of code defined with DEFINE that can only be used within the program they are created in.

Uploaded by

vkbvpalem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views2 pages

Subroutines: Form - Endform

This document discusses subroutines, macros, and parameter passing in ABAP. Subroutines are used to call reusable pieces of code within a program using the PERFORM statement. Parameters can be passed by value, where only copies are passed, or by reference, where the addresses are passed. Macros are reusable blocks of code defined with DEFINE that can only be used within the program they are created in.

Uploaded by

vkbvpalem
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SUBROUTINES

FORM - ENDFORM

This statement is used to create subroutines.


PERFORM

This statement is used to invoke the subroutine created. Subroutines are used to call a piece of code frequently within the program or externally from other program.
LOCAL SUBROUTINES:

The subroutine is called locally from the same program using PERFORM statement.
Eg:

PERFORM NAME. FORM NAME. DO 5 TIMES. WRITE: / 'WELCOME TO ABAP'. ENDDO. ENDFORM.
Pass by value:

Only the copies of the actual parameter will be sent to formal parameter. In this case if you change the values of formal parameters it will not affect the actual parameter.
Eg:

DATA: A (10) VALUE 'INDIA', B TYPE I VALUE '20'. PERFORM NAME USING A B. FORM NAME USING X Y. X = 'BANGALORE'. Y = '100'. WRITE: / X, Y. ENDFORM.

Pass by reference:

Only the address of the actual parameter will be sent to formal parameter. In this case if you change the values of formal parameters it will not affect the actual parameter.
Eg:

DATA: A (10) VALUE 'INDIA', B TYPE I VALUE '20'. PERFORM NAME USING A B. FORM NAME USING X Y. WRITE: / X, Y. ENDFORM.
Macros:

A macro is a set of statements that can be used more than once in the ABAP program. For example, a macro can be useful for long calculations or for writing complex WRITE statements. A macro can be used only in that program in which it is created.
Syntax:

DEFINE macro. Statements END-OF-DEFINITION.

You might also like