Retrieve current DSN



IBM's Command List programming language & Restructured Extended Executor

Retrieve current DSN

Postby GeorgeQ » Fri Jun 16, 2017 1:39 am

Hello everyone,

Could you please teach me if there is a solution that I can retrieve current jcl job's DSN name and show it in log?

For example the current jcl job's DSN name is "USER.MEMBER.PDS(LIST05)", I want add some code(use some system function(like &SYSUID,&SYSDATE...) or some automatic method instead of manually input) in this jcl to show the DSN(current job) in the log after the job was executed.


Thanks!

Geo
GeorgeQ
 
Posts: 28
Joined: Fri Jun 16, 2017 1:08 am
Has thanked: 12 times
Been thanked: 0 time

Re: Retrieve current DSN

 

Re: Retrieve current DSN

Postby Robert Sample » Fri Jun 16, 2017 2:07 am

The system doesn't really track the source for a job -- once the job enters JES, it is converted / interpreted into control blocks and tokens that are what the system uses to execute the job. The source is kept for the output listing, but the origination of the source is not stored anywhere that I'm aware of. So there's nothing really to tell you the source of the job -- not in SAS, not in the system, not anywhere. Use documentation by writing a SAS program to run one-time to create a comment line with the source PDS and member name; some job schedulers will track the source of the job for you (which is good for production but not for test at most sites).
Robert Sample
Global moderator
 
Posts: 3624
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 267 times

Re: Retrieve current DSN

Postby GeorgeQ » Fri Jun 16, 2017 2:21 am

Thank you very much for the quick and informative response!
as you said the source is not stored. I feed that is very make sense, so that is why in "=s.st" page we can use sj to see a jcl code only and not the full path of that jcl code. am I right?

Thanks!
GeorgeQ
 
Posts: 28
Joined: Fri Jun 16, 2017 1:08 am
Has thanked: 12 times
Been thanked: 0 time

Re: Retrieve current DSN

Postby Robert Sample » Fri Jun 16, 2017 2:29 am

Yes, the source JCL is kept for the job output, but where that source came from isn't tracked. You might be able to modify the SUBMIT command to track where the job came from (I haven' t checked to see if that is possible), but you would still miss anything coming in from the internal reader.
Robert Sample
Global moderator
 
Posts: 3624
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 267 times

Re: Retrieve current DSN

Postby GeorgeQ » Fri Jun 16, 2017 2:38 am

So I think the only possible way so far to do this is retrieve that from CVT or not.
GeorgeQ
 
Posts: 28
Joined: Fri Jun 16, 2017 1:08 am
Has thanked: 12 times
Been thanked: 0 time

Re: Retrieve current DSN

Postby steve-myers » Fri Jun 16, 2017 5:20 am

GeorgeQ wrote:So I think the only possible way so far to do this is retrieve that from CVT or not.

The data set and member containing the source of a submitted job is not kept anywhere. If you want this insert it as a JCL comment in the JCL. You have to do this yourself unless you can alter the agent that submits the job (such as the TSO SUBMIT command) to do it for you.
steve-myers
Global moderator
 
Posts: 2041
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 221 times

Re: Retrieve current DSN

Postby ebenciogandiajr » Sat Jun 17, 2017 9:41 am

What exactly do you want to achieve here? Can you please elaborate?
ebenciogandiajr
 
Posts: 1
Joined: Sat Jun 17, 2017 9:29 am
Has thanked: 0 time
Been thanked: 0 time

Re: Retrieve current DSN

Postby prino » Sat Jun 17, 2017 1:52 pm

Add this exec (suitably changed) to SYSEXEC, and call if LOGSUB (or change the name below). It was written to prevent the submission of non-conforming jobs on "that" system, and also logs the dataset/member of the JCL.

Note to moderators: Please do not remove contact details!

/* REXX edit macro to prevent the submission of some jobs             */
/*** trace ?r ***************************************************** \| *
*               (C) Copyright Robert AH Prins, 2010-2010               *
************************************************************************
*  ------------------------------------------------------------------  *
* | Date       | By   | Remarks                                      | *
* |------------+------+----------------------------------------------| *
* |            |      |                                              | *
* |------------+------+----------------------------------------------| *
* | 2010-05-07 | RAHP | Check for > 5 jobs on output queue           | *
* |------------+------+----------------------------------------------| *
* | 2010-03-29 | RAHP | Initial version                              | *
* |------------+------+----------------------------------------------| *
************************************************************************
* LOGSUB is a REXX edit macro to prevent the submission of jobs that   *
* do not follow certain rules:                                         *
*                                                                      *
* 1) The JOBNAME must start with the userid of the submitter           *
* 2) It is not allowed to use any PRTY= keywords                       *
************************************************************************
* Send questions, suggestions and/or bug reports to:                   *
*                                                                      *
* robert(a)prino(d)org / robert(d)a(d)h(d)prins(a)gmail(d)com          *
*                                                                      *
* Robert AH Prins                                                      *
* Ožkinių gatvė 48                                                     *
* Vilnius 08410                                                        *
* Lithuania                                                            *
************************************************************************
* More z/OS tools @ <https://prino.neocities.org/zOS/zOS%20Tools.html> *
************************************************************************
* This program is free software: you can redistribute it and/or        *
* modify it under the terms of the GNU General Public License as       *
* published by the Free Software Foundation, either version 3 of       *
* the License, or (at your option) any later version.                  *
*                                                                      *
* This program is distributed in the hope that it will be useful,      *
* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
* GNU General Public License for more details.                         *
*                                                                      *
* You should have received a copy of the GNU General Public License    *
* along with this program. If not, see <http://www.gnu.org/licenses/>  *
***********************************************************************/
parse source source
parse value source with . . moi .

"isredit macro (parm) PROCESS"
"ispexec control errors return"

user = userid()

if user = someone_special |,
   user = maybe_me        |,
   user = the_boss        |,
   user = another_exception? then
  do
    "isredit builtin submit"
    exit
  end

"isredit (STATE) = user_state"
"isredit (DSN)   = dataset"
"isredit (MEM)   = member"

id = '//* Submit ID: 'dsn'('mem')'

zedsmsg = ''
zedlmsg = ''

"isredit (L) = line 1"
parse value l with '//' jobname ' ' .

/***********************************************************************
* Check that the JOBNAME starts with the USERID                        *
***********************************************************************/
if abbrev(jobname, user) = 0 then
  zedlmsg = 'SUBMIT cancelled, JOBNAME must start with' user
else
  do
    /*******************************************************************
    * Do not allow users to jump the queue                             *
    *******************************************************************/
    "isredit f 'PRTY=' first"
    if rc \= 0 then
      "isredit f '/*PRIORITY' first"

    if rc = 0 then
      zedlmsg = 'SUBMIT cancelled, jumping the queue is NOT allowed'
  end

trap = outtrap('st.')

/***********************************************************************
* Will always capture at least one line, the TSO session               *
***********************************************************************/
"st" user

/***********************************************************************
* Will always capture at least one line, either a job with this name,  *
* or the 'JOB xxxxxxxx NOT FOUND' message                              *
***********************************************************************/
if length(jobname) - length(user) > 1 then
  "st" jobname

trap = outtrap('OFF')

/***********************************************************************
* This allows them to have no more than 4 jobs on the output queue     *
***********************************************************************/
if st.0 > 6 then
  do
    zedlmsg = 'SUBMIT cancelled, too many jobs on the output queue.',
              'Please remove them before resubmitting this job.'
  end

if zedlmsg = '' then
  do
    "isredit f ' EXEC ' first"
    if rc = 0 then
      "isredit line_before .zcsr = (ID)"

    "isredit builtin submit"

    "isredit f ' Submit ID:' first"
    if rc = 0 then
      "isredit del .zcsr .zcsr nx all"
  end
else
  do
    "ispexec setmsg msg(ISRZ001)"

    if st.0 > 5 then
      do
        zcmd = ";sdsf;pre" user"*;owner" user"*;st"
        "ispexec control nondispl end"
        "ispexec display panel(isr@prim)"
      end
  end

"isredit user_state = (STATE)"
exit


Then change a (probably) global site-command table and include this entry:
    Verb      T  Action
    SUBMIT    3  ALIAS LOGSUB


And note that the above only works in ISPF, submitting a job with the actual TSO SUBMIT command, or from READY mode will not log anything.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 593
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 26 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post