View Expanded Source
View Expanded Source allows the user to view the content of preprocessed COBOL and PL/I programs or JCL.
The COBOL preprocessing implies expanding all include files and applying all REPLACE compiler directives. For JCLs, preprocessing implies expanding all JCL procedures and JCL include files.
File inclusion: %INCLUDE File, %XINCLUDE File, ++INCLUDE File, -INC File
Library member inclusion: %INCLUDE MEMBER, %INCLUDE LIB (MEMBER)
Cobol Resource Expanded
To view the Cobol expanded source, go to the Editor window and from the right-click menu choose View expanded source. A new tab is displayed indicating that it contains the expanded resource.
The expanded Cobol code contains a comment that is inserted before a copy expansion, full path of the Copy file used with the source line number for the Copy/Include statement, and a comment inserted at the end of the expansion with the same copy file information (path and line number) matching the start comment.
Example 1 REPLACE compiler directing statement
REPLACE Compiler directing statement replaces one or more words with another sequence of words (or by nothing), in all sources, including all nested (copied) ones, until REPLACE OFF statement is met or till the end of the program if REPLACE OFF is not specified.
Note that a blank space in the text to be replaced may mean one or more blanks in the source itself. In the following example, two pseudo texts were replaced with two other.
REPLACE compiler directing statement:
REPLACE ==TEXT TO BE REPLACED== BY ==NEW TEXT== ==EXHIBIT NAMED== BY ==DISPLAY==
Example 2 COPY statement replacing
COPY statement can be found in a basic format, copying only the source code as is without changes (unless REPLACE is active at the point of COPY), or with a REPLACING clause which can modify the text within that COPY and all copies nested within it.
A blank in the text to be replaced can translate into one or more blanks in the source itself, for example, two token replacements and one pseudocode replacement.
COPY statement replacing:
COPY CPY00001 REPLACING V1 BY V0001 V2 BY V0002 ==TEXT TO BE REPLACED== BY ==NEW TEXT==
Example 3 "-INC" replacing
"-INC" is another format of Copy, and copies only the source code as is without changes unless used with prefix.
The additional information for performing the replacement is stored into the repository.
Example 3 Prefix replacing
Prefixes are used together with "–INC" commands and are defined within comments in the original Cobol source.
After a prefix is defined, each record or variable name that is mentioned in variable definition will have a prefix as indicated in the prefix declaration, including a hyphen. The prefix is added to all variables defined following the Prefix start, these could be both in the program code and copybooks code, until a comment with PREFIX,END is found. Prefix would be applied on all nested COPY/-INC too.
01 ITF1-AREA. *PREFIX,ITF1 -INC CCMNT000 *PREFIX,END
If copybook CCMNT000 has the following definitions:
copybook CCMNT000 definitions:
02 REC1. 03 V1 PIC 999 03 V2 REDEFINES V1 PIC 9V99 03 FILLER PIC XX.
The expanded copybook has variables with “ITF1-“ prefix:
02 ITF1-REC1. 03 ITF1-V1 PIC 999 03 ITF1-V2 REDEFINES ITF1-V1 PIC 9V99. 03 FILLER PIC XX.
Example 4 SQL Include
Embedded SQL INCLUDE commands are handled in a similar way to a simple COPY statement.
The SQL include files are inserted in the place of the EXEC SQL INCLUDE statements.
JCL Resource Expanded
To view the expanded JCL source, go to the Editor window and from the right-click menu choose View expanded source. A new tab is displayed indicating that it contains the expanded resource.
- Per each symbol in the Job, performs the replacement;
- Per each Proc/Include usage, performs the symbol replacement and expands the Proc file;
- The Proc file or Include file content is included after the Proc step or Include command and appears with two leading characters (‘XX’) for every line, replacing the original two slash characters used in the PROC/Include (‘//’).
JCL symbols are defined or set in the job code. The symbols are similar to template variables that can be initialized and set along the JCL Jobs Procs and include files code.
When defined, the symbols are used as a name followed by equal sign and value, and when used in the Job code or Proc or Include code, the same name is used with an ampersand ("&") before it. When the Job is expanded, the symbols are replaced both within the job code and Proc/Include code, from the point of definition of the symbol till the end of that job. Symbols are relevant for the Job they are defined in, and other jobs defined in the same JCL file don’t use them. The Proc code may have symbols set at the beginning of the Proc as a default value in case the Job did not override (define or set) some/all symbols before calling the proc.
The reference for symbols is done with "&" before the symbol name and period following it (if there is more text after the symbol) as in the example below.
//STP010 EXEC PGM=IKJEFT1B, // REGION=&RGN //XSBCF DD DSN= &PARML..CONTRLIB(PISYPP20), // DISP=SHR //XSOCF DD SYSOUT=* //PSZP316 DD DSN=&&STP0100, // DISP=(NEW,PASS), // DCB=(BLKSIZE=21600,LRECL=120,RECFM=FB), // SPACE=(&CYL,(5,5),RLSE), // UNIT=(&WORK,&VOL) //PSZP317 DD DSN= &DSNGP..P00PS.BP.PSBMPP20, // DISP=(NEW,CATLG), // DCB=(BLKSIZE=21600,LRECL=120,RECFM=FB), // SPACE=(&CYL,(5,5),RLSE), // UNIT=(&DATA,&VOL)
XXSTP010 EXEC PGM=IKJEFT1B, XX REGION=4096K XXXSBCF DD DSN= PJ.OPRPO.CONTRLIB(PISYPP20), XX DISP=SHR XXXSOCF DD SYSOUT=* XXPSZP316 DD DSN=&&STP0100, XX DISP=(NEW,PASS), XX DCB=(BLKSIZE=21600,LRECL=120,RECFM=FB), XX SPACE=(CYL,(5,5),RLSE), XX UNIT=(WORK,6) XXPSZP317 DD DSN= PJ.P00PS.BP.PSBMPP20, XX DISP=(NEW,CATLG), XX DCB=(BLKSIZE=21600,LRECL=120,RECFM=FB), XX SPACE=(CYL,(5,5),RLSE), XX UNIT=(DATA,6)
Double ampersands before a word (for example, "&&STP0100") are not a symbol reference but rather a temporary file name.
PL/I Resource Expanded
- a comment that is inserted before an include expansion.
- the full path of the Include file used with the source line number for the Include statement.
- a comment inserted at the end of the expansion with the same include file information (path and line number) matching the start comment.
Example %INCLUDE replacing
The "%INCLUDE" preprocessor statement is used to include the text of another file, having the effect of including the specified file code without any further changes.