Retrieve CL Source (RTVCLSRC)

Where allowed to run: All environments (*ALL)
Threadsafe: No
Parameters
Examples
Error messages

The Retrieve CL Source (RTVCLSRC) command is used to retrieve the source statements from an original program model (OPM) CL program or an integrated language environment (ILE) CL module. In the case of an ILE CL module, RTVCLSRC can also retrieve the CL source from an ILE program (*PGM) or service program (*SRVPGM) object which contains the specified CL module.

In order to retrieve the CL source, *YES must have been specified for the Allow RTVCLSRC (ALWRTVSRC) parameter when the CL source was compiled.

The CL source statements are placed into a source file member, which can be used as input to recompile the CL source.

Top

Parameters

Keyword Description Choices Notes
PGM Program Qualified object name Optional, Positional 1
Qualifier 1: Program Name
Qualifier 2: Library Name, *LIBL, *CURLIB
SRVPGM Service program Qualified object name Optional
Qualifier 1: Service program Name
Qualifier 2: Library Name, *LIBL, *CURLIB
MODULE Module Single values: *PGM
Other values: Qualified object name
Optional
Qualifier 1: Module Name
Qualifier 2: Library Name, *LIBL, *CURLIB
SRCFILE Source file Qualified object name Optional, Positional 2
Qualifier 1: Source file Name, QCLSRC
Qualifier 2: Library Name, *LIBL, *CURLIB
SRCMBR Source member Name, *PGM Optional, Positional 3
RTVINCSRC Retrieve included source *NO, *YES Optional
Top

Program (PGM)

Specifies the program object from which the original CL source is to be retrieved.

Note: This parameter and the Service program (SRVPGM) parameter are mutually exclusive.

Qualifier 1: Program

name
Specify the name of the program.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the thread is used to locate the program. If no library is specified as the current library for the thread, the QGPL library is used.
name
Specify the name of the library where the program is located.
Top

Service program (SRVPGM)

Specifies the service program object from which the original CL source is to be retrieved.

Note: This parameter and the Program (PGM) parameter are mutually exclusive.

Qualifier 1: Program

name
Specify the name of the service program.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the job is searched. If no library is specified as the current library for the job, the QGPL library is used.
name
Specify the name of the library to be searched.
Top

Module (MODULE)

Specifies the CL module from which the original CL source is to be retrieved. If a value is specified for either the Program (PGM) parameter or the Service program (SRVPGM) parameter, this parameter identifies which CL module in the program or service program contains the CL source to be retrieved.

Note: This parameter is ignored if an original program model (OPM) program object is specified for the Program (PGM) parameter.

Single values

*PGM
The name of the CL module is the same as the value specified for either the PGM or SRVPGM parameter. If no value was specified for PGM and SRVPGM, *PGM is not a valid value.

Qualifier 1: Module

name
Specify the name of the CL module from which the CL source is to be retrieved.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library is used for the module. If no library is specified as the current library for the job, the QGPL library is used.
name
Specify the name of the library for the module.
Top

Source file (SRCFILE)

Specifies the database source file into which the CL source statements are to be written. This file must exist when the command is run.

Qualifier 1: Source file

QCLSRC
The source file named QCLSRC is used.
name
Specify the name of the source file.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found.
*CURLIB
The current library for the thread is used to locate the source file. If no library is specified as the current library for the thread, the QGPL library is used.
name
Specify the name of the library to be searched.
Top

Source member (SRCMBR)

Specifies the database source file member into which the CL source statements are to be written. If the member existed before the command was run, it is cleared before any source statements are written into it. If the member did not exist, it is created.

*PGM
If the CL source statements are retrieved from an original program model (OPM) CL program, the member name will be the same as the program name. If the CL source statements are retrieved from an integrated language environment (ILE) CL module object or a CL module in an ILE program or service program, the member name will be the same as the module name.
name
Specify the name of the source file member that will contain the CL source statements.
Top

Retrieve included source (RTVINCSRC)

Specifies whether or not to retrieve CL commands that were included by INCLUDE (Include CL Source) commands in the original source CL program.

*NO
If the original CL source contained any INCLUDE commands, the retrieved source will contain the same INCLUDE commands, but will not contain the source statements that were included when the CL source was compiled.

Specifying *NO for this parameter will produce CL source which most closely matches the original CL source.

*YES
If the original CL source contained any INCLUDE commands, the retrieved source will contain the included source statements instead of the original INCLUDE commands.

Specifying *YES for this parameter will produce CL source which most closely matches the full CL source used to create the CL program or module.

Top

Examples

Example 1: Retrieving the Original CL Source

RTVCLSRC   PGM(JOHN1/TEXT1)  SRCFILE(JOHN2)  SRCMBR(JOHN3)

This command retrieves the source statements from the CL program named TEXT1 in library JOHN1. The retrieved source statements are placed into the file named JOHN2, and are named as member JOHN3. If the original CL source program contained any INCLUDE commands, the retrieved source will contain the same INCLUDE commands.

If program TEXT1 was created using the Create Bound CL Program (CRTBNDCL) command, the CL source is retrieved from module TEXT1 within program TEXT1.

Example 2: Retrieving the Expanded CL Source

RTVCLSRC   PGM(MYAPP1)  SRCFILE(RTVAPPSRC)  RTVINCSRC(*YES)

This command retrieves the source statements from the CL program named MYAPP1 located using the library list. The retrieved CL source statements are placed into member MYAPP1 of source file RTVAPPSRC, which is also located using the library list. If the original CL source contained INCLUDE commands, the retrieved CL source will contain the included CL source in place of the INCLUDE commands.

Example 3: Retrieving CL Source from an ILE Program

RTVCLSRC   PGM(ACCTRCV)  MODULE(GETACCT)

This command retrieves the CL source statements from module GETACCT which is part of the integrated language environment (ILE) program named ACCTRCV. Program ACCTRCV is located using the library list. The retrieved CL source statements are placed into member GETACCT of source file QCLSRC, which is also located using the library list. If the original CL source contained INCLUDE commands, the retrieved source will contain the same INCLUDE commands.

Example 4: Retrieving CL Source from a Service Program

RTVCLSRC   SRVPGM(AR_LIB/AR_PROCS)  MODULE(GETCUST)
           SRCFILE(AR_SRC)  RTVINCSRC(*YES)

This command retrieves the source statements from module GETCUST which is part of the integrated language environment (ILE) service program AR_PROCS located in library AR_LIB. The retrieved CL source statements are placed into member GETCUST of source file AR_SRC, which is also located using the library list. If the original CL source contained INCLUDE commands, the retrieved CL source will contain the included CL source in place of the INCLUDE commands.

Example 5: Retrieving CL Source from a CL Module

RTVCLSRC   MODULE(TOOLSLIB/MAILPDF)  SRCFILE(TOOLSLIB/QCLSRC)

This command retrieves the CL source statements from module MAILPDF which is located in library TOOLSLIB. The retrieved CL source statements are placed into member MAILPDF of source file QCLSRC, which is also located in library TOOLSLIB. If the original CL source contained INCLUDE commands, the retrieved source will contain the same INCLUDE commands.

Top

Error messages

*ESCAPE Messages

CPF0560
Program &1 in &2 not a CL program.
CPF0561
Unable to retrieve CL source from CL program &2.
CPF0562
File &1 in &2 not a data base source file.
CPF0563
Record length too small for data base source file.
CPF0564
Unable to add data base member &3 to file.
CPF0565
Source from CL program &4 not retrieved.
CPF0566
Source not available for CL program &1 in &2.
CPF0567
Module &1 in library &2 not a CL module or has no CL source.
CPF0568
Module &4 not found in &3 &1 in library &2.
CPF0569
Module &4 in &3 &1 in library &2 does not contain CL source.
CPF0571
Error occurred trying to retrieve CL source from module &4.
CPF9801
Object &2 in library &3 not found.
CPF9802
Not authorized to object &2 in &3.
CPF9803
Cannot allocate object &2 in library &3.
CPF9805
Object &2 in library &3 destroyed.
CPF9806
Cannot perform function for object &2 in library &3.
CPF9807
One or more libraries in library list deleted.
CPF9808
Cannot allocate one or more libraries on library list.
CPF9809
Library &1 cannot be accessed.
CPF9810
Library &1 not found.
CPF9820
Not authorized to use library &1.
CPF9822
Not authorized to file &1 in library &2.
CPF9830
Cannot assign library &1.
CPF9848
Cannot open file &1 in library &2 member &3.
CPF9849
Error while processing file &1 in library &2 member &3.
Top