MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cobol Program to identify which Job(JCL) triggered
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
anchala
Beginner


Joined: 22 Jan 2004
Posts: 1
Topics: 1

PostPosted: Thu Jan 22, 2004 2:24 pm    Post subject: Cobol Program to identify which Job(JCL) triggered Reply with quote

Please advise on how a Cobol Program can identify the Job(JCL) that triggered it. There could be more than 1 job that triggeres the program.
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Thu Jan 22, 2004 2:51 pm    Post subject: Reply with quote

Look down a few lines from your post to the one titled "Userkey of user who submitted job".
Back to top
View user's profile Send private message
haatvedt
Beginner


Joined: 14 Nov 2003
Posts: 66
Topics: 0
Location: St Cloud, Minnesota USA

PostPosted: Tue Feb 10, 2004 1:55 am    Post subject: Reply with quote

go to Gilbert Saint-Flour's homepage and look in his tools section for a cobol program which retrieves jobname / step name and other information..

http://mywebpages.comcast.net/gsf/tools/index.html

have fun.
_________________
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jul 30, 2004 6:17 am    Post subject: Reply with quote

Hi,

The link is really great. Thanks haatvedt. I addition to the ones listed in the link, I would like to retrieve the following information from a job.

For a given DD name can I get the actual file which is allocated ?

for example if I have a job as the one shown below

Code:

//JOBCARD....
//*
//*
//R010   EXEC  PGM=COBOL123
//STEPLIB    DD  DSN=XXX.YYY.LOAD,DISP=SHR
//INPUT       DD  DSN=MY.INPUT.FILE,DISP=SHR
//*
...


In the above code, for the DD Name INPUT, the file "MY.INPUT.FILE" is allocated. Can I get this info. from inside the cobol program ?

Thanks a lot,
Phantom
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Fri Jul 30, 2004 6:18 am    Post subject: Reply with quote

In addition to the file details, I would also like to have the PS parameters (Volume, LRECL, Blksize, etc.....)

Thanks,
Phantom
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Mon Aug 02, 2004 8:13 am    Post subject: Reply with quote

Phantom,

There is an Assembler/rexx routine which will get all the DSN allocations in the job. The BatchPDF edit macro by Doug nadel gives the DD names

check this link for BATCHPDF edit macro(3rd post from the bottom)

http://www.mvsforums.com/helpboards/viewtopic.php?t=2608&highlight=batchpdf

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Aug 03, 2004 4:04 am    Post subject: Reply with quote

Thanks a lot kolusu,

This is what I wanted. The link is wonderful !!!. Also, Is there a way to get these info directly from COBOL (COBOL - ASSEMBLER directly) without invoking an intermediate REXX routine ? I don't want to do this way (COBOL - REXX - ASSEMBLER).

(Just to learn Smile )


Regards,
Phantom
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Tue Aug 03, 2004 11:55 pm    Post subject: Reply with quote

Hi Phantom,

do you need assembler code and / or PL1 Code (should not be difficult to transfer to cobol) to get the job name which invoked an cobol program? Ist this your request.

Pls let me know, i will send you some lines code.

regards,
bauer
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Aug 04, 2004 1:35 am    Post subject: Reply with quote

Bauer,

I just wanted to reduce the three step process to 2 steps. I have my cobol program ready (which does some other process). I want to know what file is allocated to its input DDNAME. If this could be done via an assembler or PL1 and if that can be invoked directly by my cobol program that would be fine.

I don't mind if its is an assember routine or PL1. Could you please post your code here. I will learn something new. Wink

Thanks for your guidance,
Phantom
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Wed Aug 04, 2004 2:15 am    Post subject: Reply with quote

Phantom,

sorry, i have only code to find out jobname etc., but not any code to find out allocated datasets (at the moment).

I think reading the mvs controlblocks could solve the problem, Jobstep controlblock, my be ..... ?! I will check the documentatin the nexts days .......

Solution to find out jobname
Code:

DCL CVT_ADDR_INIT     BIN FIXED(31) INIT(16),
    CVT_ADDR          PTR BASED(ADDR(CVT_ADDR_INIT)),
    CVT_PTR           PTR BASED(CVT_ADDR) ;

DCL 1 CVT             BASED(CVT_PTR),
       2 LIST_PTR     PTR ;

DCL 1 TCB_LIST        BASED(LIST_PTR),
       2 NEXT_TCB     PTR,
       2 CURR_TCB     PTR;

DCL 1 TCB             BASED(CURR_TCB),
       2 FILLER       CHAR(12),
       2 TIOT_PTR     PTR;

DCL 1 TIOT            BASED(TIOT_PTR),
       2 JOBNAME      CHAR(8) ,
       2 STEPNAME     CHAR(8) ;
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Aug 04, 2004 11:10 pm    Post subject: Reply with quote

Thanks a lot bauer, I will try this and let u know.

Thanks
Phantom
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Tue Sep 07, 2004 12:16 pm    Post subject: Reply with quote

The code below is a clone of BATCHPDF. I am trying to extract the DCB parameters of all the DDNAMEs allocated in a particular step.

I went through the Data Area manuals Vol 4 (JFCB) and found that the offsets for LRECL, RECFM, Primary, Secondary and Dir quantity.

Code:

get_allocations:  Procedure Expose ddname. dsname. volume. lrecl.       
Numeric digits 10                      /* Allow up to 7fffffff       */
Drop ddname. dsname. volume. lrecl. blksz. primq. secq. dir. recfm.     
tiotptr=24+ptr(12+ptr(ptr(ptr(16))))   /* Get ddname array           */
tioelngh=c2d(stg(tiotptr,1))           /* Nength of 1st entry        */
a=0                                                                     
ddname=' '                                                             
Do Until tioelngh=0                    /* Scan until dd found        */
  tioeddnm=strip(stg(tiotptr+4,8))     /* Get ddname from tiot       */
  If substr(tioeddnm,1,1) <>'00'x Then                                 
    Do                                                                 
      If substr(tioeddnm,1,1) <>" " Then                               
        ddname=tioeddnm                                                 
      If ddname=Arg(1) THEN
        Do                                                             
          a=a+1                                                         
          ddname.a=ddname                                               
          tioelngh=c2d(stg(tiotptr,1)) /* Length of next entry       */
          tioejfcb=stg(tiotptr+12,3)                                   
          jfcb=swareq(tioejfcb)        /* Convert sva to 31-Bit addr */
          dsname.a=strip(stg(jfcb,44)) /* Dsname jfcbdsnm            */
          lrecl.a =c2d(stg((jfcb+104),2)) /*Lrecl jcfclrecl */         
          blksz.a =c2d(stg((jfcb+102),2)) /*blksize JFCBLKSI */         
          primq.a =c2d(stg(jfcb+152,3))  /*Dir qty JFCBPQTY  */         
          secq.a  =c2d(stg(jfcb+156,3))  /*Dir qty JFCBSQTY  */         
          dir.a   =c2d(stg(jfcb+160,3))  /*Dir qty JFCBDQTY  */         
          recfm.a =c2x(stg(jfcb+100,1))  /*Dir qty JFCRECFM  */         
          volume.a=storage(d2x(jfcb+118),6)/* Volser jfcbvols (Not     
                                          used)                      */
          say 'Iterations  : ' a                                       
          say 'Dataset Name: ' dsname.a                                 
          say 'LRECL       : ' lrecl.a                                 
          say 'Blksize     : ' blksz.a                                 
          say 'Dir blocks  : ' dir.a                                   
          say 'Prim Qty    : ' primq.a                                 
          say 'Sec Qty     : ' secq.a                                   
          say 'Volume      : ' volume.a                                 
          say 'Recfm       : ' recfm.a                                 
        End                                                             
    End                                                                 
  tiotptr=tiotptr+tioelngh             /* Get next entry             */
  tioelngh=c2d(stg(tiotptr,1))         /* Get entry length           */
End                                                                     
ddname.0=a                                                             
Return                                                                 
/*-------------------------------------------------------------------*/
ptr:  Return c2d(storage(d2x(Arg(1)),4)) /* Return a pointer         */
/*-------------------------------------------------------------------*/
stg:  Return storage(d2x(Arg(1)),Arg(2)) /* Return storage           */
/*-------------------------------------------------------------------*/
swareq:  Procedure                                                     
If right(c2x(Arg(1)),1) \= 'F' Then    /* SWA=BELOW ?                */
  Return c2d(Arg(1))+16                /* YES, RETURN SVA+16         */
sva = c2d(Arg(1))                      /* CONVERT TO DECIMAL         */
tcb = ptr(540)                         /* TCB PSATOLD                */
jscb = ptr(tcb+180)                    /* JSCB TCBJSCB               */
qmpl = ptr(jscb+244)                   /* QMPL JSCBQMPI              */
qmat = ptr(qmpl+24)                    /* QMAT QMADD                 */
Do While sva>65536                                                     
  qmat = ptr(qmat+12)                  /* NEXT QMAT QMAT+12          */
  sva=sva-65536                        /* 010006F -> 000006F         */
End                                                                     
Return ptr(qmat+sva+1)+16                                               


I am invoking this piece of rexx via batch (COBOL program invokes this REXX). Here is the SYSPRINT output.

Code:

Iterations  :  1                                 
Dataset Name:  TSONJAY.INPUT.FILE1
LRECL       :  300                               
Blksize     :  32700                             
Dir blocks  :  0                                 
Prim Qty    :  0                                 
Sec Qty     :  3750                             
Volume      :  TSG085                           
Recfm       :  90                               
Iterations  :  1                                 
Dataset Name:  TSONJAY.INPUT.FILE2 
LRECL       :  300                               
Blksize     :  32700                             
Dir blocks  :  0                                 
Prim Qty    :  0                                 
Sec Qty     :  3750                             
Volume      :  TSG036                           
Recfm       :  90                               
Iterations  :  1                               
Dataset Name:  TSONJAY.COMPARE.OUTPUT1
LRECL       :  304                             
Blksize     :  0                               
Dir blocks  :  0                               
Prim Qty    :  150                             
Sec Qty     :  200                             
Volume      :  TSG077                         
Recfm       :  90                             
Iterations  :  1                               
Dataset Name:  TSONJAY.TEST1.LINKLIB           
LRECL       :  0                               
Blksize     :  23476                           
Dir blocks  :  0                               
Prim Qty    :  0                               
Sec Qty     :  0                               
Volume      :  TSG057                         
Recfm       :  C0                             


Everything works fine but the Dir blocks and Primary quantity are always zero. Could someone please verify my code and let me know what could be the problem.

Thanks a ton,
Phantom
Back to top
View user's profile Send private message
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 09, 2004 1:16 am    Post subject: Reply with quote

The dataset TSONJAY.TEST1.LINKLIB which is allocated to the DD STEPLIB is a PDS. But still I don't get the Dir blocks for this.

What does the field JFCBDQTY refer to ? is the Maximum directory blocks allocated or the no. of directory blocks used ?

If it refers to either of the two mentioned above is there any other field in the JFCB control blocks that give us the other one ?

Please help.

Thanks a lot.
Phantom
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Sep 09, 2004 5:40 am    Post subject: Reply with quote

Phantom,

The control blocks are explained in MVS Data Area Manuals . check this link

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/FINDBOOK?filter=mvs+data+areas&Collection=0

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Thu Sep 09, 2004 8:26 am    Post subject: Reply with quote

Kolusu,

This is where I got the offsets for JFCBDQTY & JFCBPQTY .... from. The LRECL, Sec qty and others work fine but the Primary qty & Directory blocks are always zero. Could you please figure out what could be wrong in my code above ?

Thanks a ton in advance,

Regards,
Phantom
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group