Page 1 of 1

Get JCl name dynamically from cobol

PostPosted: Mon Dec 14, 2015 8:19 pm
by Raja190
Hi,

The below Cobol program gets the JCL name (from which its submitted) dynamically. Could you please explain me how the below program works pointer in cobol ?


IDENTIFICATION DIVISION.
 PROGRAM-ID. JOBINFO.

 DATA DIVISION.
 WORKING-STORAGE SECTION.
 01 JOB-NAME             PIC X(8).
 01 PROGRAM-NAME         PIC X(8).
 01 STEP-NAME            PIC X(8).

 LINKAGE SECTION.
 01 PSA.
    05 FILLER     PIC X(540).
    05 PSATOLD    POINTER.

 01 TCB.
    05 FILLER     PIC X(12).
    05 TCBTIO     POINTER.
    05 FILLER     PIC X(164).
    05 TCBJSCBB   POINTER.

 01 TIOT.
    05 TIOCNJOB   PIC X(8).
    05 TIOCSTPN   PIC X(8).

 01 JSCB.
    05 FILLER     PIC X(360).
    05 JSCBPGMN   PIC X(8).

 PROCEDURE DIVISION.
*    Address PSA
     SET ADDRESS OF PSA TO NULL

*    Address TCB
     SET ADDRESS OF TCB TO PSATOLD

*    Address TIOT
     SET ADDRESS OF TIOT TO TCBTIO

     MOVE TIOCNJOB TO JOB-NAME
     MOVE TIOCSTPN TO STEP-NAME

*    Address JSCB
     SET ADDRESS OF JSCB TO TCBJSCBB

     MOVE JSCBPGMN TO PROGRAM-NAME
     DISPLAY 'JOB NAME     = ' JOB-NAME
     DISPLAY 'STEP NAME    = ' STEP-NAME
     DISPLAY 'PROGRAM NAME = ' PROGRAM-NAME
     GOBACK
     .

Re: Get JCl name dynamically from cobol

PostPosted: Mon Dec 14, 2015 8:36 pm
by NicC
Which part are you having a problem with? What is it about the explanation in the COBOL Language Reference Manual that you do not understand?

Pleae, when osting code - use the code tags. They preserve spacing: as it is your code apears to start in the saame column as the * for the comments.

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 1:36 pm
by Raja190
Hi Nic,

Thanks for your reply, my question here is ? how the pointer variable accesses the MVS system and directly the space that holds the job name ?

because the pointer variable declared in the linkage section or the variable length specified helps to get the job name or anything else ?

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 3:36 pm
by BillyBoyo
The address of the PSA is "zero", so the NULL in the POINTER gets the PSA. Beyond that it uses addresses from the PSA to reach other Control Blocks, and then reach others.

They have to be in the LINKAGE SECTION because the Control Blocks are "elsewhere", not in your WORKING-STORAGE.

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 5:51 pm
by Raja190
@Billy Boyo, Thanks a lot for your time and explanation on this.

I had posted a query long back in ICETOOL & DFSort and you had answered for that too .I also seen you answering to many people in various areas I wonder how you are Master in everything in Mainframe ?. Please tell us the secret ;)



Thanks again Billy Boyo :)

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 7:19 pm
by NicC
It is a case of years of experience, years of learning, years of reading the manuals (not only the manuals to get the job done but those that give background information) and experimentation.

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 7:41 pm
by Raja190
NicC wrote:It is a case of years of experience, years of learning, years of reading the manuals (not only the manuals to get the job done but those that give background information) and experimentation.

Re: Get JCl name dynamically from cobol

PostPosted: Tue Dec 15, 2015 8:06 pm
by Robert Sample
You can figure this out yourself -- IBM lays out many control blocks in their Data Areas manuals. However, following the control block chains and determining the offsets to use can be a challenge; there's a lot of interaction between the various control blocks. That's where the years of experience and learning and reading the manuals comes in handy.