I am sure I am not the only person who has come across a CLP program, not been able to find its source, and been thankful for the RTVCLSRC command to be able to retrieve its source. By all means the code retrieved was not pretty, but it was a lot better than having nothing.
When the CLLE create program (CRTBNDCL) and module (CRTCLMOD) commands were introduced the "Allow RTVCLSRC" parameter was not included. With IBM i 7.1 the parameter has been reintroduced for both commands.
The default for the Create CLP program (CRTCLPGM) command, and the CCLE CRTBNDCL and CRTCLMOD commands "Allow RTVCLSRC" (ALWRTVSRC) parameter is *YES. Therefore, if your IBM i is running 7.1 you have probably been compiling your CLLE objects with the default to allow you to retrieve the source. But if you have been compiling your CLLE programs and modules for an earlier release, the "Target release" (TGTRLS) parameter is not either *CURRENT or V7R1M0, then you cannot retrieve the source.
Below are examples of the 3 commands where I have decided to give the ALWRTVSRC parameter.
CRTCLPGM PGM(MYLIB/CLP_PGM) SRCFILE(MYLIB/MYSRC) ALWRTVSRC(*YES) CRTBNDCL PGM(MYLIB/CLLE_PGM) SRCFILE(MYLIB/MYSRC) ALWRTVSRC(*YES) CRTCLMOD MODULE(MYLIB/CLLE_MOD) SRCFILE(MYLIB/MYSRC) ALWRTVSRC(*YES)
Having created the programs and modules how do we retrieve the source?
When you prompt the RTVCLSRC command for the first time in 7.1 the first thing you notice is all the extra parameters:
Retrieve CL Source (RTVCLSRC) Type choices, press Enter. Program . . . . . . . . . . __________ Name Library . . . . . . . . . *LIBL Name, *LIBL, *CURLIB Service program . . . . . . __________ Name Library . . . . . . . . . *LIBL Name, *LIBL, *CURLIB Module . . . . . . . . . . . *PGM Name, *PGM Library . . . . . . . . . __________ Name, *LIBL, *CURLIB Source file . . . . . . . . QCLSRC Name Library . . . . . . . . . *LIBL Name, *LIBL, *CURLIB Source member . . . . . . . *PGM Name, *PGM Retrieve included source . . *NO *NO, *YES
The following parameters are new:
- "Service program" and library, SRVPGM
- "Module" and library, MODULE
- "Retrieve included source", RTVINCSRC
When you think about how modules can be bound to programs and service programs the first two parameters are understandable. The third is whether to include source that has been included into CLLE, this feature was added in 6.1 and I am not going to describe it in this post.
If you created a CLP or a CLLE program using the CRTCLPGM or CRTBNDCL commands then the source can simply retrieve like this:
RTVCLSRC PGM(MYLIB/CLLE_PGM) SRCFILE(MYLIB/MYSRC) + SRCMBR(CLLE_PGM_1)
If I had created a CLLE module, using the CRTCLMOD command, and bound it into program I would retrieve the source:
RTVCLSRC PGM(TESTPGM) MODULE(CLLE_MOD) SRCFILE(MYLIB/MYSRC) + SRCMBR(CLLE_MOD_1)
Or if the CLLE module was bound into a service program I would retrieve the source:
RTVCLSRC SRVPGM(SRVPGM) MODULE(CLLE_MOD) SRCFILE(MYLIB/MYSRC) + SRCMBR(CLLE_MOD_2)
If the person who created the programs and modules changed the ALWRTVSRC parameter to *NO then it is not possible to retrieve the source in this manner. The only time I have compiled CL with the ALWRTVSRC as *NO was when I was working for a software company. They did not want their customers to be able to retrieve and modify their source.
You can learn more about these from the IBM web site:
This article was written for IBM i 7.1.