SAP ABAP supports modularization by implementing subroutines and functions, and since it was modified to be object oriented it also supports methods. Subroutines are local to the ABAP program (technically they can be called form other programs, but this is only for backwards compatibility and should not be used), while function modules are shared. Methods can be either local as part of a local class or shared as part of a global class.

A subroutine has the following format,
FORM form_name.
(actions)
ENDFORM
and is called thusly.
PERFORM form_name.
The format above is simplified, and not very useful. Most likely the subroutine will need to have variables passed back and forth, below is the extended syntax.
FORM my_form
USING
value(variable_one)
CHANGING
value(variable_two)
variable_three.
(actions)
ENDFORM.
In the above example variable_one and variable_two are passed by value, whereas variable_three is passed by reference. The USING section is for read-only variables, while the CHANGING sections is for variables which will be modified.

Tags: Blogger Programming SAP ABAP

Published: 2009-01-17