Can we capture JOBNAME through the COBOL program?

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Sunny Malhotra
New Member
Posts: 6
Joined: Mon Jul 21, 2014 10:32 pm

Can we capture JOBNAME through the COBOL program?

Post by Sunny Malhotra »

Hi,

There is one COBOL program which is exeuting multiple times in a day. But it gets executed in different JCLs. If there is a problem, every time I have to identify in which JCL it is getting executed. I want to tweak the code in a way that I can get the Job name from the program itself. Is there any way can I achieve this?

Thanks in advance.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Can we capture JOBNAME through the COBOL program?

Post by Robert Sample »

Yes, you can read the MVS control blocks in COBOL to retrieve the job name. A Google search of cobol z/os job name returns about 110,000 results and one of them on the first page has this IBM program:

Code: Select all

IDENTIFICATION DIVISION.    

PROGRAM-ID. JOBNAME.  
ENVIRONMENT DIVISION.
DATA DIVISION.  
LOCAL-STORAGE SECTION.
77 PSAAOLD-PTR        USAGE POINTER.
77 PSAAOLD-ADDR       REDEFINES PSAAOLD-PTR PIC S9(9) BINARY.
77 ASCB-PTR           USAGE POINTER.
77 ASCB-ADDR          REDEFINES ASCB-PTR    PIC S9(9) BINARY.
77 JOBNAME-PTR        USAGE POINTER.
77 JOBNAME-ADDR       REDEFINES JOBNAME-PTR PIC S9(9) BINARY.
LINKAGE SECTION.  
77 A-PTR              USAGE POINTER.
77 JOBNAME-CHARS      PIC X(8).    
PROCEDURE DIVISION.
*    GET OUR ASCB ADDRESS FROM THE PSA    
    MOVE 548 TO PSAAOLD-ADDR.    
    SET ADDRESS OF A-PTR TO PSAAOLD-PTR.
    SET ASCB-PTR TO A-PTR.  
*    ASCBJBNI  
    COMPUTE JOBNAME-ADDR = ASCB-ADDR + 172.
    SET ADDRESS OF A-PTR TO JOBNAME-PTR.  
    SET JOBNAME-PTR TO A-PTR.    
    IF JOBNAME-PTR IS NOT EQUAL NULL THEN
        SET ADDRESS OF JOBNAME-CHARS TO JOBNAME-PTR          
        DISPLAY "INITIATED JOBNAME IS " JOBNAME-CHARS        
    END-IF.                                                  
*    ASCBJBNS    
    COMPUTE JOBNAME-ADDR = ASCB-ADDR + 176.
    SET ADDRESS OF A-PTR TO JOBNAME-PTR.  
    SET JOBNAME-PTR TO A-PTR.  
    IF JOBNAME-PTR IS NOT EQUAL NULL THEN                    
        SET ADDRESS OF JOBNAME-CHARS TO JOBNAME-PTR          
        DISPLAY "START/MOUNT/LOGON JOBNAME IS " JOBNAME-CHARS
    END-IF.
    GOBACK. 
Sunny Malhotra
New Member
Posts: 6
Joined: Mon Jul 21, 2014 10:32 pm

Re: Can we capture JOBNAME through the COBOL program?

Post by Sunny Malhotra »

Thanks Robert.
jjourneyy22
New Member
Posts: 3
Joined: Thu Feb 26, 2015 12:23 pm

Re: Can we capture JOBNAME through the COBOL program?

Post by jjourneyy22 »

Mate, who is in Australia, the rsgpfast servers are in Russia and EU. Please tell me other game with "great netcode" wich allow you to play normal with 400 ping?This reminds me of the time when our community had BF servers. So many times there was people from US who FIFA 15 PC Coins joined there, and the servers was located in Stuttgart. So they play round or two on EU server (they have filters and know...or dont know may be...where they join) and start to moan: This server is laggy! And so on...
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”