| Writing Subroutine in CL program |
Subroutines in CL
Command Syntax for Calling Subroutine
CALLSUBR SUBR(Subroutine_Name)
Command Syntax for Begin Subroutine
SUBR SUBR(Subroutine_Name)
Command Syntax for End Subroutine
ENDSUBR
Command Syntax for the Return value from Subroutine
RTNSUBR RTNVAL(INTVALUE)
Example of Writing Subroutine in CL program
Write a program to create the duplicate object of an object in Qtemp library with Data /without Data
PGM PARM(&LIBNAME &OBJNAME)
/*Library Name :I/P parameter*/
DCL VAR(&LIBNAME) TYPE(*CHAR) LEN(10)
/*Object Name :I/P parameter*/
DCL VAR(&OBJNAME) TYPE(*CHAR) LEN(10)
DCL VAR(&QTEMPLIB) TYPE(*CHAR) LEN(10) VALUE('QTEMP')
/*Call Subroutine to Create Duplicate Object in Qtemp library*/
CALLSUBR SUBR(CreateDupObj)
/*begin Subroutine */
SUBR SUBR(CreateDupObj)
/*With Data: */
CRTDUPOBJ OBJ(&OBJNAME) FROMLIB(&LIBNAME) +
OBJTYPE(*FILE) TOLIB(&QTEMPLIB) DATA(*NO)
/*OR Without Data: */
CRTDUPOBJ OBJ(&OBJNAME) FROMLIB(&LIBNAME) +
OBJTYPE(*FILE) TOLIB(&QTEMPLIB) DATA(*NO)
/*End Subroutine :Exit */
ENDSUBR
ENDPGM