%PROC()
%PROC returns the external name of the current procedure.
%PROC can only be specified in calculation statements.
- For a cycle-main procedure,
the external name of the procedure is the name of the module when it was compiled.
- For a linear-main procedure,
the external name of the procedure is the uppercase form of name of the main procedure.
See 1 in the example below.
- For a subprocedure where EXTPROC was not specified,
the external name of the procedure is the uppercase form of the name of the procedure.
See 2 in the example below.
- For a subprocedure where EXTPROC was specified,
the external name of the procedure is the value specified by EXTPROC.
See 3 in the example below.
- For a Java procedure,
the external name of the procedure is in the form "Java_classname_methodname".
See 4 in the example below.
Figure 1. %PROC ExampleCTL-OPT MAIN(myPgm);
DCL-S x VARCHAR(100);
DCL-PR myPgm EXTPGM('MYLIB/MYPGM345') END-PR;
DCL-PR proc1 END-PR;
DCL-PR proc2 EXTPROC('myProc2') END-PR;
DCL-PR proc3 EXTPROC(*JAVA:'MyClass':'proc3') END-PR;
DCL-PROC myPgm; // 1
x = %PROC();
// x = "MYPGM"
END-PROC;
DCL-PROC proc1; // 2
x = %PROC();
// x = "PROC1"
END-PROC;
DCL-PROC proc2; // 3
x = %PROC();
// x = "myProc2"
END-PROC;
DCL-PROC proc3 EXPORT; // 4
x = %PROC();
// x = "Java_MyClass_proc3"
END-PROC;