2

We periodically runs jobs and we need to save the output into a PDS and then parse the output to extract parts of it to save into another member. It needs to be done by issuing a REXX command using the percent sign and the REXX member name as an SDSF command line. I've attempted to code a REXX to do this, but it is getting an error when trying to invoke an ISPF service, saying the ISPF environment has not been established. But, this is SDSF running under ISPF.

My code has this in it (copied from several sources and modified):

  parse arg PSDSFPARMS "(" PUSERPARMS
  parse var PSDSFPARMS PCURRPNL PPRIMPNL PROWTOKEN PPRIMCMD .
  PRIMCMD=x2c(PPRIMCMD)

  RC = isfquery()
  if RC <> 0 then
  do
    Say "** SDSF environment does not exist, exec ending."
    exit 20
  end

  RC = isfcalls("ON")

  Address SDSF "ISFGET" PPRIMPNL "TOKEN('"PROWTOKEN"')" ,
    " (" VERBOSE ")"
  LRC = RC

  if LRC > 0 then
    call msgrtn "ISFGET"
  if LRC <> 0 then
    Exit 20

  JOBNAME = value(JNAME.1)
  JOBNBR  = value(JOBID.1)

  SMPDSN   = "SMPE.*.OUTPUT.LISTINGS"
  LISTC. = ''
  SMPODSNS. = ''
  SMPODSNS.0 = 0
  $ = outtrap('LISTC.')
  MSGVAL = msg('ON')
  address TSO "LISTC LVL('"SMPDSN"') ALL"
  MSGVAL = msg(MSGVAL)
  $ = outtrap('OFF')
  do LISTCi = 1 to LISTC.0
    if word(LISTC.LISTCi,1) = 'NONVSAM' then
    do
      parse var LISTC.LISTCi . . DSN
      SMPODSNS.0 = SMPODSNS.0 + 1
      i = SMPODSNS.0
      SMPODSNS.i = DSN
    end
    IX = pos('ENTRY',LISTC.LISTCi)
    if IX <> 0 then
    do
      IX = pos('NOT FOUND',LISTC.LISTCi,IX + 8)
      if IX <> 0 then
      do
        address ISPEXEC "SETMSG MSG(IPLL403E)"
        EXITRC = 16
        leave
      end
    end
  end

  LISTC. = ''
  if EXITRC = 16 then
    exit 0

  address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
                  "NAMES(TSEL TSMPDSN)"

I execute this code by typing %SMPSAVE next to the spool output line on the "H" SDSF panel and it runs fine until it gets to this point in the REXX:

    114 *-* address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
                             "NAMES(TSEL TSMPDSN)"
        >>>   "TBCREATE SMPDSNS NOWRITE NAMES(TSEL TSMPDSN)"
 ISPS118S SERVICE NOT INVOKED. A VALID ISPF ENVIRONMENT DOES NOT EXIST.
        +++ RC(20) +++

Does anyone know why it says I don't have a valid ISPF environment and how I can get around this?

I've done quite a bit in the past with REXX, including writing REXX code to handle line commands, but this is the first time I've tried to use ISPEXEC commands within this code.

Thank you, Alan

Alan
  • 21
  • 2
  • You can only use **ISPF** commands (`address ispexec`) when running under **ispf**. If running in a background job, you can run ISPF (i.e. `ISPF CMD(myrexx)`). You will need to allocate the ISPF libraries (ISPPLIB, ISPMLIB, ISPTLIB aswell) – Bruce Martin Jul 27 '22 at 00:00
  • Hello Bruce, This is running under ISPF in my interactive TSO session. This is not running in a batch job. I select SDSF from my primary menu, then I do a "H" to get to the held output panel, and then put a % next to the job I want to get. Then I enter the name of my REXX and hit Enter. The REXX comes back with the error when I try to do the first ISPF command. – Alan Jul 27 '22 at 17:05
  • I cannot reproduce the behaviour you describe **unless** I start SDSF outside if ISPF, i.e. directly from the TSO READY prompt. What does a `say SYSVAR("SYSISPF")` at the start of your REXX tell? – phunsoft Jul 27 '22 at 20:04
  • Hello phunsoft. This is getting stranger and stranger... – Alan Jul 28 '22 at 00:58
  • I put this at the beginning of my REXX: ``` say SYSVAR("SYSISPF") address ISPEXEC "ISPQRY" ``` This is what I got: ``` 16 *-* say SYSVAR("SYSISPF") >>> "ACTIVE" ACTIVE 17 *-* address ISPEXEC "ISPQRY" >>> "ISPQRY" ISPS118S SERVICE NOT INVOKED. A VALID ISPF ENVIRONMENT DOES NOT EXIST. +++ RC(20) +++ ``` I am really perplexed... – Alan Jul 28 '22 at 01:06
  • Not that it would help, probably, but you'd inkove `ISPQRY` as TSO command, i.e. `"ISPQRY"`, then `say "ISPQRY retuned RC =" RC`. – phunsoft Jul 28 '22 at 12:52
  • I queried the internet and found IBM APAR [II04892](https://www.ibm.com/support/pages/apar/II04892), which would have some explanation, but only if SDSF was running as authorized task in your environment. I wouldn't know any reason to run SDSF authorized, but can you double check? – phunsoft Jul 28 '22 at 13:07
  • Hello all. I just received a reply back from IBM SDSF support that there is an APAR, PH40067, that matches this issue. We have the PTF received for that APAR, but it not yet applied. I'm requesting that the PTF be applied with out next maintenance build. It says that SDSF is not using the ISPF SELECT service to start the REXX, so it is breaking the process. The APAR changes SDSF to use the ISPF SELECT service and will correct the issue. This is only for REXX started with %. Thanks for everyone that looked at this. – Alan Jul 28 '22 at 16:02

1 Answers1

1

This is a challenge that many have had - I wrote a tool many years ago that did this and then last year created a new tool using the SDSF REXX API that is more generalized.

If nothing else you can borrow from it for your own needs or use as is.

You can find it here: https://github.com/lbdyck/sdsfxdd

The syntax may look convoluted but it actually fairly simple:

%sdsfxdd JOBname(jobname(jobid)) +
   STEPname(stepname) +
   DDname(ddname) +
   HLQ(high-level-qualifier) +
   QUALifier(qualifier) +
   SUFfix(suffix) +
   LISt(list) +
   OWNer(owner) +
   SYStem(sys) +
   DATE(date)

This allows you to run it as a step within your job (probably the last step).

Hope this helps

Lionel B Dyck
  • 552
  • 2
  • 9