IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Rexx - Latest GDG's creation date check


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Sep 19, 2011 4:51 pm
Reply with quote

Hello Pals,

Objective of req is to check the GDG's last generation date, if the date is current date, i am returning RC of 15. Based on that, i have written my rexx code which works different when runs via TSO and JCL

Code:
CURRDATE=0                                                             
CURRYEAR=0                                                             
FILEDATE=0                                                             
FILEYEAR=0                                                             
CNTR=0                                                                 
I=0                                                                   
/** PULL LVL **/                                                       
/** SAY 'LVL:' LVL **/                                                 
CALL GDG_FUNCTION                                                     
CALL CNTR_CHECK       
EXIT                                               
GDG_FUNCTION:                                                         
LVL="W635968.TEST.GDG(0)"         
"ISPEXEC LMDINIT LISTID(TMPID) LEVEL("LVL")"                           
CURRDATE = DATE('DAYS')                                                 
CURRYEAR = SUBSTR(DATE('STANDARD'),1,4)                                 
SAY 'CURTDATE' CURRDATE                                                 
SAY 'CURRYEAR' CURRYEAR                                                 
DO FOREVER                                                             
  "ISPEXEC LMDLIST LISTID("TMPID") OPTION(LIST) DATASET(DSVAR) STATS(YES)"
   IF RC = 0 THEN DO                                                   
     SAY 'ZDLCDATE:' ZDLCDATE                                             
     FILEYEAR = SUBSTR(ZDLCDATE, 1,4)                                     
     FILEMON  = SUBSTR(ZDLCDATE, 6,2)                                     
     FILEDATE = SUBSTR(ZDLCDATE, 9,2)                                     
     SAY 'FILEDATE:' FILEDATE                                             
     SAY 'FILEYEAR:' FILEYEAR                                             
     DATSAM = FILEYEAR||FILEMON||FILEDATE                                 
     DDX = DATE('D',DATSAM,'S')                                           
     SAY 'DDX:' DDX                                                       
     IF CURRDATE = DDX & FILEYEAR = CURRYEAR                           
     THEN                                                               
     IF CURRDATE = DDX & FILEYEAR = CURRYEAR             
     THEN                                                 
         CNTR=0                                           
     ELSE                                                 
         CNTR=10                                         
   END                                                   
   ELSE LEAVE                                             
  SAY 'CNTR:' CNTR                                         
END                                                       
/*** CALL COUNTER CHECK FUNCTION ***/                     
CNTR_CHECK:                                               
SAY 'CNTR2' CNTR                                         
IF CNTR=10                                               
THEN                                                     
    EXIT 15


Problem is the logic works till checking the date, when i run via TSO, it clearly says CNTR value is 10, but when i run via JCL it says CNTR value is 0 and it returns RC = 0.

I couldnt simulate it to return RC = 15, when it has different creation date.

I have also tried using the
Code:
ZISPFRC = Your_return_code
Address ISPEXEC "VPUT (ZISPFRC)", 
dint helped me either.

Is there anything to be taken care to get the RC = 15, Please advise.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Sep 19, 2011 5:03 pm
Reply with quote

A post of a run-time trace would be helpful. I suspect that your LMDLIST service is not executing successfully and the whole DO FOREVER code is being bypassed.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Sep 19, 2011 5:14 pm
Reply with quote

Superk,

Quote:
I suspect that your LMDLIST service is not executing successfully


Thanks for the quick reply. I think you are correct, when i run via JCL, SAY statement which used in the DO FOREVER is not displayed in the SYSTSPRT. If that is the case, what shall be done.

PS: But when i run via TSO, SAY statement in DO FOREVER works fine and display exactly as it is.

Please suggest, since i have no deep knowledge on REXX, couldnt proceed it.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Sep 19, 2011 5:46 pm
Reply with quote

LMDINIT and LMDLIST are ISPF Services and require ISPF to be active in order for them to work. Try this exec as a test:

Code:

/* REXX */                                         
Parse Source s1 s2 s3 s4 s5 s6 s7 s8 .             
If s8 = "ISPF" Then Say "ISPF is active"           
Else Say "ISPF is not active. Environment is "s8   
Exit 0                                             


Now, run this exec in different environments and you'll get different results. Run it in batch (PGM=IRXJCL) and you'll get "ISPF is not active. Environment is MVS". Run it in TSO and you'll get "ISPF is not active. Environment is TSO/E". Run it in ISPF and you'll get "ISPF is active". Run it in batch TSO (PGM=IKJEFT01) and you'll get "ISPF is not active. Environment is TSO/E". Run in it batch ISPF (PGM=IKJEFT01 and ISPSTART command issued) and you'll get "ISPF is active".
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Sep 19, 2011 6:02 pm
Reply with quote

Quote:
LMDINIT and LMDLIST are ISPF Services and require ISPF to be active in order for them to work
Thanks for the information, helped me to understand better. icon_smile.gif

Yes as you suggested ran it TSO (6) option from ISPF - Message was ISPF ACTIVE, and when ran it thru TSO/BATCH - IKJEFT01 utility - Message was ISPF is not active. Environment is TSO/E. icon_eek.gif

Inorder to make it active, to run with IKJEFT01, any feasible solution is there.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Mon Sep 19, 2011 7:14 pm
Reply with quote

A batch ISPF job step needs to have the following, as a minimum:

Code:

//STEPNAME EXEC PGM=IKJEFT01,DYNAMNBR=128                       
//SYSPROC  DD   DISP=SHR,DSN=<your REXX library>
//ISPPLIB  DD   DISP=SHR,DSN=<your site's panel library>
//ISPSLIB  DD   DISP=SHR,DSN=<your site's skeleton library>
//ISPMLIB  DD   DISP=SHR,DSN=<your site's message library>
//ISPTLIB  DD   DISP=SHR,DSN=<your PROFILE library>
//         DD   DISP=SHR,DSN=<your site's table library>
//ISPPROF  DD   DISP=SHR,DSN=<your PROFILE library>
//ISPLIST  DD   SYSOUT=*,LRECL=121,BLKSIZE=1210,RECFM=FBA       
//SYSTSPRT DD   SYSOUT=*                                         
//SYSTSIN  DD   *                                               
 PROFILE PREFIX(<your TSO user id>)
 ISPSTART CMD(%<your REXX exec name>) NEWAPPL(ISR)               
/*                                                 
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Mon Sep 19, 2011 11:20 pm
Reply with quote

Thank you very much for your time and information.

I have one last doubt, is this a normal way of REXX for executing on TSO Batch, to get the custom return code from REXX to JCL, Or Is there any util for rexx to make it possible. Just for learning purpose i am inquiring it. icon_smile.gif

Thanks,
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Sep 20, 2011 12:27 am
Reply with quote

If you write a REXX exec, and have it end with the statement:

EXIT <somevalue>

Then it WILL return that value back to the caller, whether it's the Terminal Monitor Program (TMP) IKJEFT01 or the REXX Interpreter (IRXJCL). When you involve ISPF, that changes things a bit sometimes.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Sep 20, 2011 1:45 am
Reply with quote

After all of this, and notwithstanding the syntax errors your code contains, what exactly is supposed to be the purpose of your exec? Couldn't you have saved a lot of time and effort and used a simpler method, like using AMS (Access Method Services) or even the REXX built-in function LISTDSI?
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Tue Sep 20, 2011 10:38 am
Reply with quote

Quote:
If you write a REXX exec, and have it end with the statement:

EXIT <somevalue>


Yes kevin, i have also tested using IKJEFT01 (TSO Batch) EXIT instruction is working. However have noticed different RC thrown using PGM=(IKJEFT1A, IKJEFT1B & IKJEFT01)

Quote:
what exactly is supposed to be the purpose of your exec?


Purpose is to determine the latest GDG creation date, if the date is current date then RC 0 else RC 15 , so the subsequent steps based on RC, will resume.

Quote:
Couldn't you have saved a lot of time and effort and used a simpler method, like using AMS (Access Method Services) or even the REXX built-in function LISTDSI?


If i would have known, could have used. icon_smile.gif Thank u very much for info on LISTDSI function, now i have got some idea to resume the work and will make it simpler as u suggested icon_smile.gif
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Sep 21, 2011 2:48 pm
Reply with quote

Kevin,

Given Batch ISPF job step works like charm. icon_biggrin.gif

Code:
//STEP01   EXEC PGM=IKJEFT01,DYNAMNBR=120               
//ISPPROF  DD DISP=SHR,DSN=W63.COPY.PROFILE         
//ISPPLIB  DD DISP=SHR,DSN=ISP.USER.ISPPLIB             
//             DD DISP=SHR,DSN=SYSL.TPM.DEVL.ISPPENU         
//ISPMLIB  DD DISP=SHR,DSN=ISP.USER.ISPMLIB             
//              DD DISP=SHR,DSN=ISP.SISPMENU                 
//ISPSLIB  DD DISP=SHR,DSN=ISP.SISPSLIB                 
//              DD DISP=SHR,DSN=ISP.SISPSENU                 
//              DD DISP=SHR,DSN=ISP.USER.ISPSLIB             
//ISPTLIB  DD DISP=SHR,DSN=ISP.USER.ISPTLIB             
//              DD DISP=SHR,DSN=ISP.SISPTENU                 
//SYSPROC  DD  DISP=SHR,DSN=W635968.REXX.PDS             
//SYSTSPRT DD  SYSOUT=*                                 
//SYSTSIN  DD  *                                         
 PROFILE PREFIX(W63)                                 
 ISPSTART CMD(%REXX2) NEWAPPL(ISR) 


Thanks for the good guidance icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2011 3:00 pm
Reply with quote

Code:
LVL="W635968.TEST.GDG(0)"         
"ISPEXEC LMDINIT LISTID(TMPID) LEVEL("LVL")"     


show evidence that the two statement quoted provide valid results

anyway You are taking the <wrong> road ...
use BPXWDIN to get the latest GDG ..
YES, even if You are not aware of it, BPXWDYN accepts relative GDG specifications
and provides back the real name
ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html
not the most recent one but useful enough
You might want to search the zOS manuals for the latest info starting from here
www-03.ibm.com/systems/z/os/zos/bkserv/index.html
after that You can use the real name to find out all You might want to kno about it

as an alternative You might use the realname rexx funtion
at Use [URL] BBCode for External Links file 183
or at gsf-soft.com/Freeware/
but beware about installing not authorized software on Your system
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Sep 21, 2011 4:43 pm
Reply with quote

Quote:
show evidence that the two statement quoted provide valid results


Below are the statements that am displaying in the REXX

Code:
READY                                                       
 PROFILE PREFIX(W635968)                                   
READY                                                       
 ISPSTART CMD(%REXX1) NEWAPPL(ISR)                         
CURTDATE 264                                               
CURRYEAR 2011                                               
ZDLCDATE: 2011/09/21                                       
FILEDATE: 21                                               
FILEYEAR: 2011                                             
DDX: 264                                                   
CNTR: 0                                                     
NNTR2 0                                                     
 W635968.D10A.SPFLOG1.LIST has been kept.                   
READY                                                       
END 



Quote:
anyway You are taking the <wrong> road ...
use BPXWDIN to get the latest GDG ..


I didnot aware of that.... thank you very much for directing me with the info icon_biggrin.gif

Quote:
but beware about installing not authorized software on Your system


Sure enrico.. icon_exclaim.gif icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2011 5:14 pm
Reply with quote

Quote:
Code:
LVL="W635968.TEST.GDG(0)"         
"ISPEXEC LMDINIT LISTID(TMPID) LEVEL("LVL")"     


show evidence that the two statement quoted provide valid results

anyway You are taking the <wrong> road ...

icon_redface.gif my bad
got curious and tested

ISPF resolving relative gdg generations ... GO FIGURE


disregard my comment about the wrongness
consider the other alternatives just as alternatives for different situations
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Sep 21, 2011 6:15 pm
Reply with quote

enrico-sorichetti wrote:
ISPF resolving relative gdg generations ... GO FIGURE


I don't know. Doesn't work on my system.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2011 6:30 pm
Reply with quote

here is the snippet I used to test


Code:
 EDIT       ENRICO.ISPF.EXEC(LMD00) - 01.08                 Columns 00001 00072
 Command ===>                                                  Scroll ===> CSR 
 ****** ***************************** Top of Data ******************************
 000001 /*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000002 /*                                                                   */
 000003 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 000004 Trace "O"                                                               
 000005                                                                         
 000006 Parse Source _sys _how _cmd .                                           
 000007                                                                         
 000008 parse arg gen                                                           
 000009 gen = strip(gen)                                                       
 000010 if  gen = "" then ,                                                     
 000011     gen = "ENRICO.TEST.GDG1(0)"                                         
 000012                                                                         
 000013 call $ispex "CONTROL ERRORS RETURN"                                     
 000014                                                                         
 000015 init_cmd = "LMDINIT LISTID(LIST) LEVEL("gen") "                         
 000016 init_rc  = $ispex(init_cmd)                                             
 000017 say init_rc                                                             
 000018                                                                         
 000019 list_cmd  = "LMDLIST LISTID("list") OPTION(LIST) DATASET(DSN) "         
 000020 do while ( $ispex(list_cmd) = 0 )                                       
 000021    say dsn                                                             
 000022 end                                                                     
 000023                                                                         
 000024 free_cmd = "LMDLIST listid("list") OPTION(FREE) "                       
 000025 free_rc  = $ispex(free_cmd)                                             
 000026                                                                         
 000027 Exit                                                                   
 000028                                                                         
 000029 /* */                                                                   
 000030 $ispex:                                                                 
 000031    isp_0tr = trace("O")                                                 
 000032    Address ISPEXEC arg(1)                                               
 000033    isp_0rc = rc                                                         
 000034    trace value(isp_0tr)                                                 
 000035    return isp_0rc                                                       
 000036                                                                         
 000037 /* */                                                                   
 000038 $isred:                                                                 
 000039    isr_0tr = trace("O")                                                 
 000040    Address ISREDIT arg(1)                                               
 000041    isr_0rc = rc                                                         
 000042    trace value(isr_0tr)                                                 
 000043    return isr_0rc                                                       
 000044                                                                         
 000045 /* */                                                                   
 000046 $tsoex:                                                                 
 000047    tso_0tr = trace("O")                                                 
 000048    Address TSO arg(1)                                                   
 000049    tso_0rc = rc                                                         
 000050    trace value(tso_0tr)                                                 
 000051    return tso_0rc                                                       
 000052                                                                         
 ****** **************************** Bottom of Data ****************************
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Sep 21, 2011 6:55 pm
Reply with quote

Weird. I'm at z/OS V1R12 here. I get:

Code:

Invalid data set level                           
Qualifiers cannot be longer than 8 characters.

Current dialog statement:                             
LMDINIT LISTID(tmpid) LEVEL(XXXXX.XXX.XXX.XXXXXXX(0))
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Sep 21, 2011 7:01 pm
Reply with quote

even weirder I am testing on a 1.10

that odd

here is the model for the LMDINIT

Quote:
****** ***************************** Top of Data ******************************
000001 'LMDINIT LISTID(LISTIDV) LEVEL('dslev') VOLUME('volser')'
=NOTE=
=NOTE= LMDINIT - Name of dialog service
=NOTE= LISTIDV - Name of the variable into which is stored the list-id
=NOTE= to be associated with the list of data set names.
=NOTE= DSLEV - Optional, data set name pattern which all data set
=NOTE= names in list must match
=NOTE= VOLSER - Optional, the volume on which data sets must reside in
=NOTE= order to be in the data set list.
=NOTE=
=NOTE= EXAMPLE: ADDRESS ISPEXEC
=NOTE= 'LMDINIT LISTID(DSLISTID) LEVEL(SYS1.ISP*) '
=NOTE=
000002 If rc ¬= 0 Then /* Return codes */
000003 Do /* 8 - Listid not created */
000004 End /* 12 - Invalid parameter value */
000005 Else /* 16 - Truncation or translation */
000006 /* error in accessing dialog */
000007 /* variables */
000008 /* 20 - Severe error */
. . . . . . . . . . . . . . . . . . . . . . . . . . .


the <LEVEL> is not a level in the LISTCAT sense,
it' s just a dataset pattern
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed Sep 21, 2011 7:26 pm
Reply with quote

I guess ISPF is adding up all of the characters, and if the last node, plus the open parentheses, the generation, and the close parentheses are no more than 8 characters, then it allows it as the level.
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Sep 21, 2011 9:38 pm
Reply with quote

Quote:
consider the other alternatives just as alternatives for different situations


Enrico,

Sure and thank you for info .. anyway it has enlightened me about new function. Day by day am learning more rexx icon_biggrin.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top