Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Nov 11, 2005 3:20 am Post subject:
Nabanita Das,
Reading the dataset name dynamically during runtime is not possible with any sort product. Instead you can use a combination of REXX/SAS and sort. Will you be interested for this ?
Is this a one time run or are you going to move the code to production ?
For the current assignment this is going to be one time code. But we get similar requests very often for data correction wherein we need to process many files. So my intention is to keep this code ready whenever we get similar requests.Also my intention here is to learn how to dynamically read the date from the filename
Please guide me how to accomplish this using REXX/SAS.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Nov 11, 2005 4:27 am Post subject:
Nabanita Das,
The code below will work irrespective of the size of your input datasets.
Here is the Rexx code to get the last qualifier of your input datasets. This is customized from Doug Nadel's BATCHPDF code. To understand the code, you must first know something about DATA AREAS. Anyway, you can use this code to satisfy your requirement.
DO I = 1 TO DSQUAL.0
PUSH DSQUAL.I
"EXECIO 1 DISKW OUT"||I||" (FINIS"
END
EXIT 1
/*-------------------------------------------------------------------*/
/*------------------ SUBROUTINES FOLLOW -----------------------------*/
/*-------------------------------------------------------------------*/
GET_ALLOCATIONS: PROCEDURE EXPOSE DDNAME. DSQUAL. DSNAME.
NUMERIC DIGITS 10 /* ALLOW UP TO 7FFFFFFF */
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 */
LAST_QUAL_IDX = LASTPOS('.', DSNAME.A) + 1
DSQUAL.A = SUBSTR(DSNAME.A, LAST_QUAL_IDX)
END
END
TIOTPTR=TIOTPTR+TIOELNGH /* GET NEXT ENTRY */
TIOELNGH=C2D(STG(TIOTPTR,1)) /* GET ENTRY LENGTH */
END
DSQUAL.0=A
DROP DDNAME. DSNAME.
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
/*-------------------------------------------------------------------*/
Store the REXX program in your REXX library in the name "GETDSN". Then run the following JCL which will get the Date from the last qualifier and also merges all your input files together.
NOTE:
In the JCL above, for Step R010, you need to define output (OUTxx) files as many as your inputs. In the example above, I am trying to merge 3 input files and hence I have defined 3 OUTxx datasets. You need to tailor your JCL to suit your needs.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Fri Nov 11, 2005 4:47 am Post subject:
Oh Yes!.
Need to try that option. Unfortunately, I typed an un-authorized command which "Suspended" my mainframe ID. Need to call our system folks during US day time to un-suspend it.
After I ran the job I am facing problem. I am pasting the sysout for the step R010.
%GETDSN INPUT
DDNAME: INPUT
36 +++ DSQUAL.A = SUBSTR(DSNAME.A, LAST_QUAL_IDX)
5 +++ CALL GET_ALLOCATIONS DDNS
Error running GETDSN, line 36: Incorrect call to routine
Please let me know where I am going wrong. I have used the exact REXX code and JCL you have given. I have just replaced the input files and output filenames and my rexx library.
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