Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* REXX */
- ARG volser ds method nds
- /* CHECK FOR RENAME */
- if (nds='' & method/='RENAME')|(nds/='' & method='RENAME') then
- do
- CALL FIND
- SEQ=2+(SEQ-1)*3
- /* THE GENERAL PART OF ALL CODES */
- queue "//a31job1 JOB A31,LEVIN,NOTIFY=&SYSUID,MSGCLASS=X"
- queue "//STEP01 EXEC PGM=ADRDSSU"
- queue "//SYSPRINT DD SYSOUT=*"
- queue "//FROM DD DISP=SHR,UNIT=T1,VOL=SER="TAPE",LABEL=("SEQ",BLP)"
- /* PART OF THE'TEMP' METHOD*/
- IF method='TEMP' THEN
- DO
- queue "//TO DD DISP=SHR,UNIT=SYSDA,VOL=SER=WORKTS"
- queue " RESTORE DATASET(INCLUDE("DS"))-"
- queue " INDD(FROM) OUTDD(TO) TOLERATE(ENQFAILURE) -"
- queue " CANCELERROR ADMIN REPLACE"
- queue "$$"
- "submit * end($$)"
- END
- /* PART OF THE 'REPLACE' METHOD */
- ELSE
- IF method='REPLACE' THEN
- DO
- queue "//TO DD DISP=SHR,UNIT=SYSDA,VOL=SER="VOLSER""
- queue " RESTORE DATASET(INCLUDE("DS"))-"
- queue " INDD(FROM) OUTDD(TO) TOLERATE(ENQFAILURE) -"
- queue " CANCELERROR ADMIN REPLACE"
- queue "$$"
- "submit * end($$)"
- END
- /* PART OF THE 'RENAME' METHOD */
- ELSE
- IF method='RENAME' THEN
- DO
- IF SYSDSN("'"NDS"'")/='OK' THEN
- DO
- queue "//TO DD DISP=SHR,UNIT=SYSDA,VOL=SER="VOLSER""
- queue " RESTORE DATASET(INCLUDE("DS"))-"
- queue " INDD(FROM) OUTDD(TO) TOLERATE(ENQFAILURE) -"
- queue " CANCELERROR ADMIN RENAMEUNCONDITIONAL("DS","NDS") -"
- queue " CATALOG"
- queue "$$"
- "submit * end($$)"
- END
- /* NAME CHECK */
- ELSE
- SAY 'CHOOSE A DIFFERENT NAME,IT ALREADY EXISTS'
- end
- END
- else
- say 'invalid parameters'
- EXIT 0
- /* MAIN FIND PROC */
- FIND: PROCEDURE EXPOSE VOLSER TAPE SEQ
- /* FINDING VOLSER */
- /* cutting disk name */
- DSNLOG=SYSDSN("'SOFT.SUPPORT("VOLSER")'")
- /* CHECKING IF DISK NAME IS EXISTS IN SOFT SUPPORT */
- IF DSNLOG='OK' THEN
- DO
- "alloc da('SOFT.SUPPORT("VOLSER")') F(INPUT) shr reuse"
- "execio * diskr INPUT (stem VOL. finis"
- "FREE F(INPUT)"
- TAPE=SUBSTR(VOL.3,57,6)
- /* IF TEMP FILE(LIB1) IS EXISTS */
- /* THEN DELETE IT */
- if sysdsn("'LIB1'")='OK' THEN
- DO
- ADDRESS TSO "DELETE 'LIB1'"
- END
- /* LISTING OUT ALL FILES FROM THE TAPE: */
- "HSEND LIST DUMPVOLUME("TAPE") ODS('LIB1')"
- /* FINDING PROCESS */
- /* WAITING FOR PREVIOUS FREE F() */
- ADDRESS SYSCALL 'sleep 1'
- "alloc da('lib1') F(indd) shr reuse"
- "execio * diskr indd (stem strings. finis"
- "free f(indd)"
- /* P - VARIABLE FOR INCREMENTING STEMS AND CHECKING FIND RESULT */
- P=0
- DO I=1 TO STRINGS.0
- IF INDEX(STRINGS.I,' 'VOLSER' ') /= 0 THEN
- DO
- P=P+1
- STRS.0=P
- STRSFULL.0=P
- STRS.P=SUBSTR(STRINGS.I,25,3)
- STRSFULL.P=STRINGS.I
- END
- END
- IF P /= 0 THEN
- DO
- IF P>1 THEN
- DO
- /* SETTING UP 1ST LINE AS INITIAL YYYY/MM/DD */
- Y=SUBSTR(STRSFULL.1,50,4)
- M=SUBSTR(STRSFULL.1,55,2)
- D=SUBSTR(STRSFULL.1,58,2)
- SEQ=SUBSTR(STRSFULL.1,25,3)
- DO I=2 TO STRS.0
- IF SUBSTR(STRSFULL.I,50,4)>Y THEN
- DO
- Y=SUBSTR(STRSFULL.I,50,4)
- M=SUBSTR(STRSFULL.I,55,2)
- D=SUBSTR(STRSFULL.I,58,2)
- SEQ=SUBSTR(STRSFULL.I,25,3)
- END
- ELSE
- IF SUBSTR(STRSFULL.I,50,4)=Y THEN
- DO
- IF SUBSTR(STRSFULL.I,55,2)>M THEN
- DO
- M=SUBSTR(STRSFULL.I,55,2)
- D=SUBSTR(STRSFULL.I,58,2)
- SEQ=SUBSTR(STRSFULL.I,25,3)
- END
- ELSE
- IF SUBSTR(STRSFULL.I,55,2)=M THEN
- DO
- IF SUBSTR(STRSFULL.I,58,2)>D THEN
- DO
- D=SUBSTR(STRSFULL.I,58,2)
- SEQ=SUBSTR(STRSFULL.I,25,3)
- END
- END
- END
- END
- SEQ=2+(SEQ-1)*3
- /* SAY 'LAST DATE:'||Y||'/'||M||'/'||D||' */
- RETURN 1
- END
- ELSE
- DO
- SEQ=SUBSTR(STRSFULL.1,25,3)*1
- SEQ=2+(SEQ-1)*3
- RETURN 1
- END
- END
- ELSE
- EXIT 0
- END
- ELSE
- DO
- SAY VOLSER 'NOT FOUND ON SOFT.SUPPORT'
- RETURN 0
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement