Get JCl name dynamically from cobol



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Get JCl name dynamically from cobol

Postby Raja190 » Mon Dec 14, 2015 8:19 pm

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
     .
Raja190
 
Posts: 36
Joined: Mon Dec 14, 2015 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get JCl name dynamically from cobol

Postby NicC » Mon Dec 14, 2015 8:36 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Get JCl name dynamically from cobol

Postby Raja190 » Tue Dec 15, 2015 1:36 pm

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 ?
Raja190
 
Posts: 36
Joined: Mon Dec 14, 2015 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get JCl name dynamically from cobol

Postby BillyBoyo » Tue Dec 15, 2015 3:36 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Get JCl name dynamically from cobol

Postby Raja190 » Tue Dec 15, 2015 5:51 pm

@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 :)
Raja190
 
Posts: 36
Joined: Mon Dec 14, 2015 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get JCl name dynamically from cobol

Postby NicC » Tue Dec 15, 2015 7:19 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Get JCl name dynamically from cobol

Postby Raja190 » Tue Dec 15, 2015 7:41 pm

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.
Raja190
 
Posts: 36
Joined: Mon Dec 14, 2015 8:13 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get JCl name dynamically from cobol

Postby Robert Sample » Tue Dec 15, 2015 8:06 pm

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.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post