If the user enter the PDS/PS name it delete the all the GDGbase present in the dataset.The problem is if any Base file containing the version that base file not getting deleted.I want the version to be deleted first then the base with out using JCL.can any one pls help
/**********************************REXX********************************/
/* REXX : GDGCREAT */
/* */
/* VERSION : 1.0 */
/* */
/* FUNCTION : DELETE the GDG bases that are used in JCLs. */
/* */
/* USAGE : GDGDEL */
/**********************************************************************/
Address TSO
MAIN:
CALL PANEL1
IF RUN_FLAG ¬= 0 THEN DO
rc = LISTDSI("'"PDS_NAME"'")
if SYSDSORG ¬= "PS" then DO
CALL CONCPDS
mem.k = STRIP(SYSVAR(SYSUID)) || '.CONCDSN.FILE'
END
ELSE DO
mem.k = PDS_NAME
END
CALL delete_gdg
DSNNAME = STRIP(SYSVAR(SYSUID)) || '.GDGLIST.FILE'
call process
END
RETURN;
/* GET THE PDS NAME USING PANEL1 */
/* REXX : GDGCREAT */
/* */
/* VERSION : 1.0 */
/* */
/* FUNCTION : DELETE the GDG bases that are used in JCLs. */
/* */
/* USAGE : GDGDEL */
/**********************************************************************/
Address TSO
MAIN:
CALL PANEL1
IF RUN_FLAG ¬= 0 THEN DO
rc = LISTDSI("'"PDS_NAME"'")
if SYSDSORG ¬= "PS" then DO
CALL CONCPDS
mem.k = STRIP(SYSVAR(SYSUID)) || '.CONCDSN.FILE'
END
ELSE DO
mem.k = PDS_NAME
END
CALL delete_gdg
DSNNAME = STRIP(SYSVAR(SYSUID)) || '.GDGLIST.FILE'
call process
END
RETURN;
/* GET THE PDS NAME USING PANEL1 */
Panel1:
run_flag = 1
"ISPEXEC LIBDEF ISPPLIB DATASET ID('A527971.GDGDEL.PDS')"
"ISPEXEC ADDPOP"
ZWINTTL = 'Tool to DELETE a set of GDG bases at one go'
"ISPEXEC DISPLAY PANEL(newpnl)"
IF RESPKEY = ENTER
THEN DO
/* check pds_name having quotes or not if exist strip them */
/* source = pds_name */
pds_name = STRIP(SOURCE,B,"'")
if PDS_NAME = ' ' then DO
run_flag = 0
"ISPEXEC REMPOP"
MESSAGE1 = 'Enter a valid PDS/PS name';
CALL PANEL1
END
eND
IF EXKEY = PF03 THEN EXIT
RETURN;
CONCPDS:
/* check pds_name is valid or not */
if SYSDSN("'"pds_name"'") ¬= "OK" then do
RUN_FLAG = 0
MSG = SYSDSN("'"pds_name"'")
MSG_LOWER_CASE = TRANSLATE(MSG,,
'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
SAY PDS_NAME' - 'MSG_LOWER_CASE
EXIT
END
ELSE DO
rc = LISTDSI("'"pds_name"'")
if rc > 8 then do
RUN_FLAG = 0
"ISPEXEC REMPOP"
MESSAGE1 = 'Enter the valid PDS name';
CALL PANEL1
end
end
/* if pds_name is existing & it is a PDS then get list of members */
x=OUTTRAP("list.",'*')
LISTDS "'"pds_name"'" MEMBERS
x=OUTTRAP("OFF")
i = list.0 ; j = 1; l = 7 ; i = i - 6
Do until i = 0
mem.j = STRIP(list.l)
i = i - 1 ; l = l + 1 ; j = j + 1
End
/* get all the members into stack */
/* say 'Please wait concatinating all the members ' */
SIGNAL ON ERROR name error_in_pgm;
i = 1 ; k = 1 ; j = j - 1
bot1 = "******************************** "
bot2 = "Top of data"
bot3 = " ********************************"
record.k = bot1||bot2||bot3 /* set the top of data */
k = k + 1
Do until j = 0
"ALLOC F(temp) DA('"pds_name"("mem.i")') SHR REU"
"EXECIO * DISKR temp (STEM rec. FINIS"
SIGNAL ON ERROR name end_pgm;
"FREE FI(temp)" /* free the member */
l = rec.0; p = 1
Do until l = 0
record.k = rec.p
rec.p = ""
p = p + 1 ; k = k + 1 ; l = l - 1
End
l = rec.0
l = l + 1
bot1 = "*********** "mem.i" *********** "
bot2 = "Bottom of Data"
bot3 = " ********************************"
record.k = bot1||bot2||bot3 /* set bottom of data */
k = k + 1 ; i = i + 1 ; j = j - 1 /* subscripts */
End
seqfile_name = STRIP(SYSVAR(SYSUID)) || '.CONCDSN.FILE'
seqfile_name = "'" ||seqfile_name|| "'"
IF SYSDSN(seqfile_name) ¬= 'OK' THEN DO
"ALLOC F(seqfile) DA("seqfile_name") NEW SPACE(1,1) CYLINDERS
DSORG(PS) LRECL(80) BLKSIZE(8000)"
END
ELSE DO
"ALLOC F(seqfile) DA("seqfile_name") SHR REUSE"
END
/* write the concatinated data into output file */
"EXECIO * DISKW seqfile (STEM record. FINIS)"
SIGNAL ON ERROR name end_pgm;
if RC ¬= 0 then do
say 'Error writting output file !'
FREE F(seqfile)
exit(0); end
else do
/* say k 'no of records written to output file' */
"FREE F(seqfile)" ;end
/* EXIT(0) */
RETURN;
/* signal on end or exit */
end_pgm: nop;
say 'Program is halted by user !'
x = OUTTRAP("ff.",'*')
"FREE F(temp,seqfile)"
x= OUTTRAP("OFF")
EXIT(0)
/* signal on error and exit */
error_in_pgm: nop;
say 'Program is ending with error!'
x = OUTTRAP("ff.",'*')
"FREE F(temp,seqfile)"
x= OUTTRAP("OFF")
EXIT(0)
Return;
delete_gdg:
x=OUTTRAP("OFF")
ADDRESS ISPEXEC
"EDIT DATASET('"mem.k"') MACRO(TESTCRE)"
Return;
Process:
source = STRIP(DSNNAME,B,"'")
IF SYSDSN("'"source"'") ¬= 'OK' THEN DO
SAY 'Input Dataset 'source ' not found';source = "";
END
"ALLOC FI(listdd) DS('"source"') SHR REUSE"
"EXECIO * DISKR listdd (STEM LIST. FINIS"
DO m = 1 to list.0
pos = pos(' ',list.m)
pos = pos - 1
dsname = SUBSTR(list.m,1,pos)
found = SYSDSN("'"dsname"'")
IF found ¬= 'OK' THEN DO
IF pos <= 35 THEN DO
x = OUTTRAP("abc.",'*')
[color=#FF0000][size=150] [u] [b]"DELETE ('"dsname"') GDG FORCE"[/b] [/u] [/size] [/color]
x = OUTTRAP("OFF")
j = 1
IF RC = 0 THEN SAY dsname || ' Deleted'
ELSE DO
MSG_SATUS = MSG("OFF")
MSG_SATUS = MSG("OFF")
SAY dsname ' Not exists'
MSG_SATUS = MSG("ON")
/* DO UNTIL (j = abc.0)
SAY abc.j;
j = j + 1;
END */
END
END
ELSE SAY dsname ' exceeds 35 characters'
END
ELSE SAY dsname ' Not exists'
END
EXIT
"ISPEXEC LIBDEF ISPPLIB DATASET ID('A527971.GDGDEL.PDS')"
"ISPEXEC ADDPOP"
ZWINTTL = 'Tool to DELETE a set of GDG bases at one go'
"ISPEXEC DISPLAY PANEL(newpnl)"
IF RESPKEY = ENTER
THEN DO
/* check pds_name having quotes or not if exist strip them */
/* source = pds_name */
pds_name = STRIP(SOURCE,B,"'")
if PDS_NAME = ' ' then DO
run_flag = 0
"ISPEXEC REMPOP"
MESSAGE1 = 'Enter a valid PDS/PS name';
CALL PANEL1
END
eND
IF EXKEY = PF03 THEN EXIT
RETURN;
CONCPDS:
/* check pds_name is valid or not */
if SYSDSN("'"pds_name"'") ¬= "OK" then do
RUN_FLAG = 0
MSG = SYSDSN("'"pds_name"'")
MSG_LOWER_CASE = TRANSLATE(MSG,,
'abcdefghijklmnopqrstuvwxyz',,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
SAY PDS_NAME' - 'MSG_LOWER_CASE
EXIT
END
ELSE DO
rc = LISTDSI("'"pds_name"'")
if rc > 8 then do
RUN_FLAG = 0
"ISPEXEC REMPOP"
MESSAGE1 = 'Enter the valid PDS name';
CALL PANEL1
end
end
/* if pds_name is existing & it is a PDS then get list of members */
x=OUTTRAP("list.",'*')
LISTDS "'"pds_name"'" MEMBERS
x=OUTTRAP("OFF")
i = list.0 ; j = 1; l = 7 ; i = i - 6
Do until i = 0
mem.j = STRIP(list.l)
i = i - 1 ; l = l + 1 ; j = j + 1
End
/* get all the members into stack */
/* say 'Please wait concatinating all the members ' */
SIGNAL ON ERROR name error_in_pgm;
i = 1 ; k = 1 ; j = j - 1
bot1 = "******************************** "
bot2 = "Top of data"
bot3 = " ********************************"
record.k = bot1||bot2||bot3 /* set the top of data */
k = k + 1
Do until j = 0
"ALLOC F(temp) DA('"pds_name"("mem.i")') SHR REU"
"EXECIO * DISKR temp (STEM rec. FINIS"
SIGNAL ON ERROR name end_pgm;
"FREE FI(temp)" /* free the member */
l = rec.0; p = 1
Do until l = 0
record.k = rec.p
rec.p = ""
p = p + 1 ; k = k + 1 ; l = l - 1
End
l = rec.0
l = l + 1
bot1 = "*********** "mem.i" *********** "
bot2 = "Bottom of Data"
bot3 = " ********************************"
record.k = bot1||bot2||bot3 /* set bottom of data */
k = k + 1 ; i = i + 1 ; j = j - 1 /* subscripts */
End
seqfile_name = STRIP(SYSVAR(SYSUID)) || '.CONCDSN.FILE'
seqfile_name = "'" ||seqfile_name|| "'"
IF SYSDSN(seqfile_name) ¬= 'OK' THEN DO
"ALLOC F(seqfile) DA("seqfile_name") NEW SPACE(1,1) CYLINDERS
DSORG(PS) LRECL(80) BLKSIZE(8000)"
END
ELSE DO
"ALLOC F(seqfile) DA("seqfile_name") SHR REUSE"
END
/* write the concatinated data into output file */
"EXECIO * DISKW seqfile (STEM record. FINIS)"
SIGNAL ON ERROR name end_pgm;
if RC ¬= 0 then do
say 'Error writting output file !'
FREE F(seqfile)
exit(0); end
else do
/* say k 'no of records written to output file' */
"FREE F(seqfile)" ;end
/* EXIT(0) */
RETURN;
/* signal on end or exit */
end_pgm: nop;
say 'Program is halted by user !'
x = OUTTRAP("ff.",'*')
"FREE F(temp,seqfile)"
x= OUTTRAP("OFF")
EXIT(0)
/* signal on error and exit */
error_in_pgm: nop;
say 'Program is ending with error!'
x = OUTTRAP("ff.",'*')
"FREE F(temp,seqfile)"
x= OUTTRAP("OFF")
EXIT(0)
Return;
delete_gdg:
x=OUTTRAP("OFF")
ADDRESS ISPEXEC
"EDIT DATASET('"mem.k"') MACRO(TESTCRE)"
Return;
Process:
source = STRIP(DSNNAME,B,"'")
IF SYSDSN("'"source"'") ¬= 'OK' THEN DO
SAY 'Input Dataset 'source ' not found';source = "";
END
"ALLOC FI(listdd) DS('"source"') SHR REUSE"
"EXECIO * DISKR listdd (STEM LIST. FINIS"
DO m = 1 to list.0
pos = pos(' ',list.m)
pos = pos - 1
dsname = SUBSTR(list.m,1,pos)
found = SYSDSN("'"dsname"'")
IF found ¬= 'OK' THEN DO
IF pos <= 35 THEN DO
x = OUTTRAP("abc.",'*')
[color=#FF0000][size=150] [u] [b]"DELETE ('"dsname"') GDG FORCE"[/b] [/u] [/size] [/color]
x = OUTTRAP("OFF")
j = 1
IF RC = 0 THEN SAY dsname || ' Deleted'
ELSE DO
MSG_SATUS = MSG("OFF")
MSG_SATUS = MSG("OFF")
SAY dsname ' Not exists'
MSG_SATUS = MSG("ON")
/* DO UNTIL (j = abc.0)
SAY abc.j;
j = j + 1;
END */
END
END
ELSE SAY dsname ' exceeds 35 characters'
END
ELSE SAY dsname ' Not exists'
END
EXIT
Thanks,
Nizar
Code'd. Please in future use the Code tags for anything where the preservation of the formatting is important.