IDCAMS DELETE/DEFINE
Problem Description
Write IDCAMS to delete a VSAM file if it exists, then define a new KSDS.
Expected Output
Safe delete and define VSAM cluster
Hints
Use DELETE with PURGE, DEFINE CLUSTER for KSDS.
Solution
//VSAMJOB JOB (ACCT),CLASS=A
//*
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE MY.VSAM.KSDS CLUSTER PURGE
SET MAXCC = 0
DEFINE CLUSTER -
(NAME(MY.VSAM.KSDS) -
INDEXED -
KEYS(10 0) -
RECORDSIZE(100 100) -
SHAREOPTIONS(2 3) -
CYLINDERS(5 1)) -
DATA -
(NAME(MY.VSAM.KSDS.DATA)) -
INDEX -
(NAME(MY.VSAM.KSDS.INDEX))
/*
//
Explanation:
SET MAXCC=0 ignores delete error if file not found. KEYS(length offset).