Page 2 of 2

Re: VSAM file is allocated to another job or user

PostPosted: Sun Jul 11, 2010 8:50 pm
by Robert Sample
I am sure that my dataset was not opened any where even then the failure message says" DATASET IN USE".
Given the choice between your sureness and the system message, I will 100% of the time believe the system over you -- sorry but the system just has no reason to lie about this. Could you have the data set open in ISPF (browse or edit)? That would cause "DATASET IN USE" messages.

Why not take the simple way out and just include a DD statement pointing to the file being renamed with DISP=OLD? That way the job won't even start running until the RENAME can succeed. The DD statement does not have to be used in the IDCAMS commands -- it is there merely so the system will grant exclusive access to the data set to your job.

Re: VSAM file is allocated to another job or user

PostPosted: Mon Jul 12, 2010 4:13 pm
by cvrupesh
Hi Robert,

Why not take the simple way out and just include a DD statement pointing to the file being renamed with DISP=OLD?


I am afraid that I didn get what you were trying to suggest me here.
Can you please elaborate on this as I am a beginner to JCL's?

Thanks everyone for your help.
Rupesh.

Re: VSAM file is allocated to another job or user

PostPosted: Mon Jul 12, 2010 4:55 pm
by Robert Sample
//ZZ25TEST JOB 1,'RENAME',MSGCLASS=2,CLASS=Y,NOTIFY=&SYSUID
//*==============================================================
//*%%R S=RENAME1 P=IDCAMS R=*
//*%%C RENAME THE FILE FROM READY TO COMPLETE
//*==============================================================
//*
//RENAME1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE   DD DISP=OLD,DSN=ZZ25.READY
//SYSIN DD *
ALTER ZZ25.READY -
NEWNAME (ZZ25.COMPLETE)
//*
The DD statement causes the job to wait until ZZ25.READY can be allocated exclusively, if another job or TSO user has the data set allocated.

Re: VSAM file is allocated to another job or user

PostPosted: Mon Jul 12, 2010 5:15 pm
by cvrupesh
wow...thats fantastic and will resolve my problem...Thanks Robert..

Re: VSAM file is allocated to another job or user

PostPosted: Wed Jul 14, 2010 7:15 pm
by cvrupesh
Hi Robert,

Can I take your time again to ask how actually the INFILE Statement with DISP=OLD makes the job not to fail?

Thanks,
Rupesh.

Re: VSAM file is allocated to another job or user

PostPosted: Wed Jul 14, 2010 7:44 pm
by NicC
DISP=OLD (basic JCL this) means the job wants EXCLUSIVE use of the dataset therefore it will wait until it has exclusive use. Read about DISP in the JCL manual.

Re: VSAM file is allocated to another job or user

PostPosted: Wed Jul 14, 2010 10:08 pm
by Robert Sample
The ALTER command means you must have exclusive access to the dataset. If there is no DD statement for the data set, JES does not "know" you need to use the data set and will not prevent other jobs from running at the same time that use the data set. If you put the DD statement in the job, JES "knows" that your job requires exclusive access to the data set and will not start it until you get that exclusive access.

Re: VSAM file is allocated to another job or user

PostPosted: Thu Jul 15, 2010 7:52 am
by steve-myers
Actually JES2 knows nothing about the data sets in your JCL. JES3 does, but not JES2.

JES2 will start your job. Before z/OS actually starts to run your job it gets control of all of the data sets specified in the job's JCL. If some other job is using any of your data sets your job will wait until all of the data sets are available.

A way to specify a data set name that may not actually exist is to code something like this
//MYDS     DD  DISP=OLD,VOL=REF=SYS1.SVCLIB,
//             DSNAME=MY.DATASET.NAME
Data set SYS1.SVCLIB must be cataloged and it must be cataloged on the SYSRES volume, whatever that might be, so this allocation will always go through, even if MY.DATASET.NAME does not actually exist on the SYSRES volume, or even exist. I would suggest you do this for both the old and new data set names in the ALTER NEWNAME control statement.

Re: VSAM file is allocated to another job or user

PostPosted: Thu Jul 22, 2010 1:13 pm
by cvrupesh
One more doubt on this, please clarify and help me.

When I say the job failed with errors while renaming a flat file using IDCAMS, is it possible for me to check what exactly(job/sms etc..) is using the dataset at the time the IDCAMS tried to rename the dataset from Spool?

The error from current spool looks as below:

IDCAMS SYSTEM SERVICES TIME: 00:31:06

ALTER ZZ25..READY -
NEWNAME (ZZ25.COMPLETE)
IDC3028I DATA SET IN USE
IDC3009I ** VSAM CATALOG RETURN CODE IS 184 - REASON CODE IS IGG0CLEC-4
IDC0532I **ENTRY ZZ25.READY NOT ALTERED
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 8

IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 8

Re: VSAM file is allocated to another job or user

PostPosted: Thu Jul 22, 2010 4:42 pm
by Robert Sample
Ask your site support group about what is available at your site. The CBT web site has a program available called WHOHAS that allows you to go to ISPF 3.4 and put WHOHAS beside the data set to find out everyone currently allocating that data set. There are other tools as well -- but only your site support group will know for sure what is installed at your site.