首页 > 代码库 > 子程序调用

子程序调用

假定程序包 含子程序:
PROGRAM FORMPOOL.
FORM SUB1.
WRITE: / ‘Subroutine 1‘.
ENDFORM.
FORM SUB2.
WRITE: / ‘Subroutine 2‘.
ENDFORM.
可在运行时 指定子程序 名,如下所 示:
PROGRAM SAPMZTST.
DATA: PROGNAME(8) VALUE ‘FORMPOOL‘,
SUBRNAME(8).
SUBRNAME = ‘SUB1‘.
PERFORM (SUBRNAME) IN PROGRAM (PROGNAME) IF FOUND.
SUBRNAME = ‘SUB2‘.
PERFORM (SUBRNAME) IN PROGRAM (PROGNAME) IF FOUND.

子程序调用