Friday, March 15, 2024

How to transfer a set of text files to a PDS as individual members in the IBM PCOM session

To transfer a set of text files to a PDS as individual members, we need to create a batch file. Let us transfer two text files to PDS USERID.DDF.TOOL. So, put the below two lines in a file and save the batch file with “srl” extension. 

C:\Downloads\ASMEXIT.JCL text~'USERID.DDF.TOOL(ASMEXIT)'
C:\Downloads\BUCKETS.JCL text~'USERID.DDF.TOOL(BUCKETS)'
 
In the Mainframe IBM PCOM session, Select option “6  Command Enter TSO or Workstation commands” form ISPF main menu. From the IBM PCOM Menu, click on “Action” and then click on “Send File to Host”. You will get the below screen. In the below screen, click on “Options” and then you will get “File Transfer Settings” window.
 

 
In the “File Transfer Settings” window, click on “MVS/TSO” tab and select “text” under “Transfer type” drop down box.  Then make sure “ascii” and “crlf” options are ticked in the “File options” and then select “Default” under “Record Format” drop down box.



Now go back to the “Send File to Host” window, click on “Open List” button and select the “srl” batch file that we already created and then click on “Send” button. This will transfer text files one by one to PDS as members.
 
 
 

Tuesday, March 5, 2024

Generating a report of dynamically called COBOL programs

IBM Enterprise COBOL V6R4 allows you to produce a report of all subroutines called by dynamic call. Use ddname IGZPROUT at the run step of your JCL to generate a report of all dynamically called programs that are compiled with Enterprise COBOL 5 or later.

The report details include the Program Name, Compiler Version, and Time and Date of compilation of the programs. Only programs that are compiled with COBOL 5 or later will be listed. Details of cancelled programs are printed at the end.

Note: If a program is cancelled multiple times, then the report prints it only once.

Recommended attributes for the IGZPROUT ddname are as follows:
DSORG = PS   RECFM = FB   78 = LRECL = 80

Here are the examples of setting the IGZPROUT ddname:
//IGZPROUT DD SYSOUT=*

or
//IGZPROUT DD DSN=dynamic.call.report.dsname,DISP=SHR

or
//IGZPROUT DD DSN=dynamic.call.report.dsname,
// UNIT=SYSDA,SPACE=(TRK,(5,10),RLSE),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB,BLKSIZE=0),
// DISP=(NEW,CATLG,DELETE)

You can get an output report as follows:

*********************** DYNAMICALLY CALLED PROGRAM REPORT ********************
************************* FOR COBOL 5 AND LATER RELEASES *********************

NAME       COMPILER VER.       DATE/TIME COMPILED
-----------------------------------------------------------------------------
PROG1      V06 R02 M00         2021/01/01 15:30:02
PROG2      V06 R02 M00         2021/01/01 15:30:12

The following programs are marked as cancelled at termination:
PROG3      V06 R03 M00         2022/02/13 17:36:29
*************************** END OF PROGRAM REPORT ****************************

Note: For dynamic calls, the program-name in the PROGRAM-ID paragraph or ENTRY statement must be identical to the corresponding program object name or program object alias of the program object that contains the program. If the PROGRAM-ID paragraph or the ENTRY statement is not identical to the corresponding program object (PDSE member) name or program object alias of the program object that contains the program, then the report will list the program-name in the PROGRAM-ID paragraph or the ENTRY statement, as opposed to listing the program object (PDSE member) name or the program object alias name.

A Very good youtube from "Dinosaur Parkour" about this feature can be found in the below link.



Wednesday, February 28, 2024

Exclusive control over datasets in JCL

When any step of a job requests exclusive control of a data set, with an exception of when the job is allowed to downgrade ENQs via the DSENQSHR specification, the system converts all requests for shared control of that data set within that job (DISP=SHR) to requests for exclusive control. One of two methods can be used to request exclusive control:

  • DISP=NEW, DISP=MOD, or DISP=OLD on a JCL request.
  • DISP=NEW, DISP=MOD, or DISP=OLD on a dynamic allocation request,

including dynamic allocation requests that result from the use of certain utility control statements. For example, utility control statements that delete/scratch a data set will result in exclusive use of that data set.

If a dynamic allocation requests exclusive control of a data set then all subsequent DISP=SHR JCL references to that data set within that job will be upgraded to exclusive control. The job will retain exclusive control of that data set until the end of the last step of that job which references that data set in its JCL. For example:

//STEP1 EXEC PGM=anypgm1
//DD1 DD DSN=A.B.C,DISP=SHR
//STEP2 EXEC PGM=IDCAMS
 DELETE A.B.C
 DEFINE A.B.C
//STEP3 EXEC PGM=anypgm3
//DD3 DD DSN=A.B.C,DISP=SHR
//STEP4 EXEC PGM=anypgm4

Before the start of STEP1, the job will request shared control of data set A.B.C. In STEP2, the DELETE/DEFINE of data set A.B.C will cause the shared control from STEP1 to be upgraded to exclusive control. In STEP3, control of data set A.B.C will remain exclusive, since it is not possible to downgrade an ENQ from EXCL to SHR in the case that a dynamic allocation upgrades the ENQ. At the end of STEP3, control of data set A.B.C will be released. The ENQ on data set A.B.C will therefore not be held at all during STEP4. If, however, the job also contained a STEP5 which requested use of data set A.B.C, then exclusive control of that data set would continue to be held by the job all the way through both STEP4 and STEP5.

DISP and ENQ: Before starting the first step of a job, the initiator requests control of all of the data sets in that job by issuing an ENQ for each of them, using the value specified for DISP to determine the kind of ENQ issued. The initiator issues the ENQ for each data set at the highest level required for that data set by any step of the job. For example, if all steps of the job request shared control of a specific data set (DISP=SHR) then the ENQ for that data set is requested as SHR. If, on the other hand, any step of the job requests exclusive control of a specific data set (DISP=NEW, DISP=MOD, or DISP=OLD), then the ENQ for that data set is requested EXCL.

If the job is allowed to downgrade ENQs, then ENQs will be downgraded from exclusive control to shared control at the last step for which the data set is referenced EXCL. The downgrade will not occur if the ENQ has been upgraded by a dynamic allocation request in the current or a previous step. If the job is not allowed to downgrade ENQs, then ENQs cannot be downgraded from EXCL to SHR. If one step needs the ENQ EXCL and a following step only needs it SHR, the ENQ is still held as EXCL.

In both cases, the ENQ is held until the end of the last step which references that data set, at which point the ENQ is released entirely.

DISP and ENQ for generation data sets: The way the initator issues an ENQ to control generation data sets can be different than with other data sets. The initiator only issues the ENQ for the GDG base name for a generation data set that is referenced by either:

  • Their relative GDG names (for example, DSN=TEST.GDG.DATASET(0)).
  • As GDG ALLs (for example, DSN=TEST.GDG.DATASET)

For example, the initiator issues the ENQ for the GDG base name, TEST.GDG.DATASET for the generation data sets shown in the previous list. Generation data sets referenced by either their relative GDG names or as GDG ALLs are processed this way because the initiator does not know which specific absolute generation names will be required. This is because the conversion from relative generation name to absolute generation name is done during the allocation for the step referencing the data set. The ENQ for the specific, absolute, generation (G0000V00) data set name or names is issued at the start of the step requesting the relative GDG or GDG ALL.

Note that the initiator does not issue an ENQ for the GDG base name for a generation data set that is referenced by its absolute GDG name. Instead it issues an ENQ for that specific G0000V00 data set name.


Monday, January 8, 2024

Difference between EXIT PROGRAM, GOBACK, STOP RUN in COBOL

Let us assume we have a Batch JOB step which executes MAIN-PGM. 
Let us assume job step has below call chain. 

MAIN-PGM --> SUB-PGM1 --> SUB-PGM2 --> SUB-PGM3

That is MAIN-PGM calls SUB-PGM1
SUB-PGM1 program inturn calls SUB-PGM2
SUB-PGM2 program inturn calls SUB-PGM3

A run unit is a running set of one or more programs that communicate with each other by COBOL static or dynamic CALL statements. So, the above entire flow is called "run unit"

EXIT PROGRAM or GOBACK in sub programs(called programs) returns the control to the calling program.

For example, if we code EXIT PROGRAM or GOBACK in SUB-PGM3, then control returns to the point in the SUB-PGM2 immediately following the CALL statement that invoked SUB-PGM3

GOBACK in main program MAIN-PGM passes the control to the operating system program that invoked it.

EXIT PROGRAM in main program does NOT do anything, control goes to the next statement that immediately follows EXIT PROGRAM.
So, EXIT PROGRAM works only in sub programs (called programs).

If we code STOP RUN in SUB-PGM3 (or any other program in the calling chain), it will directly pass the control to the operating system program that invoked main program MAIN-PGM. That is STOP RUN ends the execution of entire "run unit".

Friday, January 5, 2024

Initialize FILLER data item

INITIALIZE statement wont initialize FILLER data items. If you want to initialize FILLER items as well, then include "WITH FILLER" in the INITIALIZE statement.

If you include "ALL VALUE" clause in the INITIALIZE statement, then it will initialize ONLY the data items that are defined with VALUE clause to the value specified in the VALUE clause.

Below is the sample code to explain the usage of FILLER and VALUE clauses in the INITIALIZE statement.

WORKING-STORAGE SECTION.
01 WS-X.
   05 WS-A    PIC X(16).
   05 WS-A1   PIC X(16) VALUE '1234567890A.CDEF'.
   05 WS-B    PIC X(5).
   05 WS-C    PIC 9(5).
   05 FILLER  PIC 9(5).
PROCEDURE DIVISION.
   MOVE ALL '*'    TO WS-X
   DISPLAY WS-X
   INITIALIZE WS-X WITH FILLER
   DISPLAY WS-X
   MOVE ALL '*'    TO WS-X
   INITIALIZE WS-X ALL VALUE
   DISPLAY WS-X
   STOP RUN.

Output of the above program

***********************************************    
                                     0000000000    
****************1234567890A.CDEF***************