A subroutine is a block of code introduced by FORM and concluded by ENDFORM.
FORM subr [USING p1 TYPE type
p2 LIKE field
...
VALUE(p3) TYPE type
VALUE(p4) LIKE field
... ]
[CHANGING { {VALUE(p1)}|{p1 [{TYPE type}|{LIKE field}]}
{VALUE(p2)}|{p2 [{TYPE type}|{LIKE field}]}
... } ]
...
ENDFORM.
subr is the name of the subroutine. The optional additions USING and CHANGING define the parameter interface. Like any other processing block, subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program, especially for executable programs. In this way, you eliminate the risk of non-executable statements occurring by mistake through a subroutine closing an event block at the wrong place.
Global Data from the Main Program