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

small piece of Rexx to retrieve the relative generation


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Mon Sep 03, 2012 8:51 pm
Reply with quote

Hi,

This is just informational post not actually a query.

I've designed the below small snippet of rexx code to retrieve the current and relative generation of a gdg.

Code:


PARSE VAR DSN GBSE "(" GGEN ")" REST   /* GET GDG BASE AND GEN */
                                                                 
IF GGEN > 0 then do                                 /* ONLY NEGATIVE GEN       */
    say 'Only negative Gens Allowed'
    Exit
END                                                             
X=OUTTRAP(LST.)                                                 
" LISTC ENT('"GBSE"')"                               /* LISTCAT GDG BASE      */
X=OUTTRAP(OFF)                                                   
IF rc <> 0 then do                                      /* NO VALID GDG BASE     */
    say 'The GDG doesn't exist'
    Exit                                                   
END                                                             
GGEN = (GGEN * 2) - 1                                           
GGEN = (LST.0 + GGEN)                            /* LOCATE RELATIVE GEN   */
A = POS('NONVSAM',LST.GGEN)                                     
IF A <= 0 then do                                               
    say 'The generation of GDG doesn't exist' Exit                                                                                                     
END                                                             
ELSE do                                                         
  A=A+13                                                  /* LOCATE START OF GDS  */
  DSN = STRIP(SUBSTR(LST.GGEN,A,44))   /* RETRIEVE FINAL GEN      */
  SAY DSN
END                                                             
                                                                 
DROP LST.                                                       


Please add any comments if we can finetune it some more. I have tested the code and it is working. Thought it would be useful to post it.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Sep 03, 2012 8:52 pm
Reply with quote

why not simply use BPXWDYN ???
Back to top
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Mon Sep 03, 2012 9:49 pm
Reply with quote

yes, my first choice was BPXWDYN. But It appeared to me that we need to allocate the dsn and free it to get the full dataset name. It should be ok when we browse the test datasets. But if it is prod, and before we free the dataset if the prod dataset gets used by some other job, then we may face issues.

Please correct me if I am wrong.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Sep 03, 2012 10:04 pm
Reply with quote

my personal opinion ( naturally ) the <busy> time should not be a show stopper

Your worry implies that the tool might be of frequent use
so in this case the listcat might be the hog

You might want to measure the elapsed between a bpxwdyn alloc and a bpxwdyn free

Code:
call time("r")
... alloc ...
... free ...
say time("r")


rather than mangling the listcat output, my preference goes to the

REALNAME program by Doug Nadel
www.sillysot.com/mvs/

or it' s successor
FULLDSN command from Gilbert Saint Flour ( rip )
gsf-soft.com/Freeware/

naturally if You can install a small load module

here is the source of it ( I do not see any IP infrigement by posting it )


Code:


//GILBERTN JOB (ACCT#),NOTIFY=&SYSUID,CLASS=A,MSGCLASS=X,COND=(0,NE)    00010000
//HLASM EXEC PGM=ASMA90,PARM=(OBJECT,NODECK,NOESD,NORLD,NOXREF)         00020000
*********************************************************************** 00030000
*                                                                     * 00040000
* MODULE NAME = FULLDSN                                               * 00050000
*                                                                     * 00060000
* DESCRIPTIVE NAME = REXX function: returns fully-qualified dsname.   * 00070000
*                                                                     * 00080000
* STATUS = R100                                                       * 00090000
*                                                                     * 00100000
* FUNCTION = This assembler sub-routine can be invoked in a REXX      * 00110000
*            EXEC to convert an alias name into the corresponding     * 00120000
*            real dsname, or a dsname with a relative generation      * 00130000
*            number such as PROD.MASTER(-2) into a fully-qualified    * 00140000
*            dsname such as PROD.MASTER.G12345V00.                    * 00150000
*                                                                     * 00160000
* AUTHOR = Gilbert Saint-Flour <gsf@pobox.com>                        * 00170000
*                                                                     * 00180000
*        Note: This is a rewrite of Doug Nadel's REALNAME program     * 00190000
*              to make it re-entrant and improve performance when     * 00200000
*              FULLDSN is invoked multiple times in the same exec.    * 00210000
*                                                                     * 00220000
* ENVIRONMENT = SEE BELOW                                             * 00230000
*                                                                     * 00240000
*    DEPENDENCIES: TSO/E V2                                           * 00250000
*                                                                     * 00260000
* MODULE TYPE = PROCEDURE, (CSECT TYPE)                               * 00270000
*                                                                     * 00280000
*    PROCESSOR = IBM OS/ASSEMBLER H VERSION 2 or                      * 00290000
*                IBM HIGH LEVEL ASSEMBLER/MVS                         * 00300000
*                                                                     * 00310000
*    MODULE SIZE = 2K                                                 * 00320000
*                                                                     * 00330000
*    ATTRIBUTES = REENTERABLE, RMODE ANY, AMODE 31,                   * 00340000
*                 PROBLEM STATE, KEY 8                                * 00350000
*                 APF AUTHORIZATION: NONE                             * 00360000
*                                                                     * 00370000
* SYNTAX  =  See below                                                * 00380000
*                                                                     * 00390000
*         fdsn=FULLDSN(dsname)                                        * 00400000
*                                                                     * 00410000
*    Arguments:                                                       * 00420000
*                                                                     * 00430000
*         dsname    This is the input data set name which will be     * 00440000
*                   converted to a real dsname or a fully-qualified   * 00450000
*                   GDS name such as PROD.MASTER.G12345V00.           * 00460000
*                                                                     * 00470000
*********************************************************************** 00480000
FULLDSN  RSECT                                                          00490000
FULLDSN  RMODE ANY                                                      00500000
         SAVE  (14,12),,FULLDSN                                         00510000
         LR    R12,R15                                                  00520000
         USING FULLDSN,R12                                              00530000
         LM    R2,R3,16(R1)        R2/R3                                00540000
*                                                                       00580000
*        Allocate dynamic storage                                       00590000
*                                                                       00600000
         GETMAIN R,LV=DYNAML                                            00610000
         LR    R11,R1              A(DYNAM)                             00620000
         USING DYNAM,R11                                                00630000
*                                                                       00640000
*        Make sure I stay in memory for the life of the exec            00650000
*                                                                       00660000
         L     R4,PSATOLD-PSA(0,0) my TCB                               00670000
         USING TCB,R4                                                   00680000
         L     R4,TCBJSTCB         job-step TCB                         00690000
         L     R5,TCBJPQ           my CDE                               00700000
         USING CDENTRY,R5                                               00710000
         CLI   CDUSE+1,1           first time through?                  00720000
         BNE   PIN99               no, jump                             00730000
         TM    CDATTR,CDREN        reentrant module?                    00740000
         BZ    PIN99               no, jump                             00750000
         CL    R12,CDENTPT         is this my CDE?                      00760000
         BNE   PIN99               no, jump                             00770000
         LOAD  EPLOC=CDNAME        bump my own use count                00780000
PIN99    EQU   *                                                        00790000
         DROP  R5                  CDENTRY                              00800000
*                                                                       00810000
         L     R3,0(,R3)           R3 = address REXX eval block         00820000
         USING EVALBLOCK,R3                                             00830000
*                                                                       00840000
*        Move dsname to result area                                     00850000
*                                                                       00860000
         LM    R4,R5,0(R2)         R6/R7 = Addr/Length of input dsn     00870000
         LA    R6,EVALBLOCK_EVDATA R4 = addr(evalblock_evdata);         00880000
         LA    R7,44               R5 = length(evalblock_evdata);       00890000
         ST    R7,EVALBLOCK_EVLEN  Result length=44                     00900000
         ICM   R5,B'1000',=C' '    padding character                    00910000
         MVCL  R6,R4               evalblock_evdata(1:44) = input dsn   00920000
*                                                                       00930000
*        Look up dsname in the catalog                                  00940000
*                                                                       00950000
         L     R14,CAMLST1         CAMLST flags                         00960000
         LA    R15,EVALBLOCK_EVDATA R15 = addr(dsname)                  00970000
         SLR   R0,R0               CVOL addr                            00980000
         LA    R1,WORKAREA         addr of LOCATE work-area             00990000
         STM   R14,R1,CAMLST2      build CAMLST in dynamic storage      01000000
         LOCATE CAMLST2            Issue locate                         01010000
         LTR   R15,R15             IF r15 = 0 THEN                      01020000
         BZ    EXIT                  goto exit                          01030000
*                                                                       01040000
*        Set up error code                                              01050000
*                                                                       01060000
         LA    R0,7                RESULT length=7                      01070000
         ST    R0,EVALBLOCK_EVLEN  RESULT length=7                      01080000
         MVC   EVALBLOCK_EVDATA(7),=CL7'UNKNOWN'  RESULT='UNKNOWN'      01090000
*                                                                       01100000
*        Clean up and exit                                              01110000
*                                                                       01120000
EXIT     FREEMAIN R,LV=DYNAML,A=(R11)                                   01130000
         RETURN (14,12),RC=0       Return code(0)                       01140000
*                                                                       01150000
*        Model catalog parm list                                        01160000
*                                                                       01170000
CAMLST1  CAMLST NAME,*-*,,*-*                                           01180000
*                                                                       01190000
*        Dynamic storage area                                           01200000
*                                                                       01210000
DYNAM    DSECT                                                          01220000
CAMLST2  CAMLST NAME,EVALBLOCK_EVDATA,,WORKAREA                         01230000
WORKAREA DS    32D                                                      01240000
DYNAML   EQU   *-DYNAM                                                  01250000
*                                                                       01260000
*        Control Block Definitions                                      01270000
*                                                                       01280000
TCB      DSECT                                                          01290000
TCBJPQ   EQU   *+44,4                  last CDE                         01300000
TCBJSTCB EQU   *+124,4                 JS TCB                           01310000
PSA      DSECT                                                          01320000
PSATOLD  EQU   *+540,4                 own TCB                          01330000
         IHACDE                                                         01340000
         IRXEVALB                                                       01350000
         YREGS                                                          01360000
         END   FULLDSN                                                  01370000
//SYSLIB   DD DSN=SYS1.MACLIB,DISP=SHR                IRXEVALB          01380000
//         DD DSN=SYS1.MODGEN,DISP=SHR                IHACDE            01390000
//SYSPRINT DD SYSOUT=*                                                  01400000
//SYSUT1   DD UNIT=VIO,SPACE=(CYL,1)                                    01410000
//SYSLIN   DD UNIT=VIO,SPACE=(TRK,1),DISP=(,PASS),DCB=BLKSIZE=3200      01420000
//*                                                                     01430000
//LKED    EXEC PGM=IEWL,PARM=RENT                                       01440000
//SYSLIN   DD DSN=*.HLASM.SYSLIN,DISP=(OLD,PASS)                        01450000
//SYSLMOD  DD DSN=GILBERT.LOAD(FULLDSN),DISP=SHR                        01460000
//SYSPRINT DD SYSOUT=*                                                  01470000
//*                                                                     01480000
//GO      EXEC PGM=IKJEFT01                                             01490000
//STEPLIB  DD DSN=GILBERT.FILE183.LOAD,DISP=SHR       REXXTRY           01500000
//         DD DSN=GILBERT.LOAD,DISP=SHR               FULLDSN           01510000
//SYSTSPRT DD SYSOUT=*                                                  01520000
//SYSTSIN  DD *                                                         01530000
REXXTRY                                                                 01540000
SAY FULLDSN('GILBERT.CTC(0)')                                           01550000
SAY FULLDSN('GILBERT.CTC(0)')                                           01560000
SAY FULLDSN('GILBERT.CTC(0)')                                           01570000
/*                                                                      01580000
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
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 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