View previous topic :: View next topic
|
Author |
Message |
prakash404
New User
Joined: 09 Mar 2010 Posts: 12 Location: chennai
|
|
|
|
Hi ,
I am creating a dynamic file inside a PS. Now i want to check whether the particular file inside a PS is existing or not. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
prakash404 wrote: |
Hi ,
I am creating a dynamic file inside a PS. Now i want to check whether the particular file inside a PS is existing or not. |
What does this mean.. "dynamic file inside a PS" |
|
Back to top |
|
|
prakash404
New User
Joined: 09 Mar 2010 Posts: 12 Location: chennai
|
|
|
|
Hi Sambhaji,
//**********************************************************************
//* CREATING DYNAMIC FILES WITH CURRENT DATE APPENDED TO COUNT FILE NAME
//**********************************************************************
//STEP040 EXEC SORTD5
//SORTIN DD *
NEWNAME (AAA.PDYYMMDD)
/*
//SORTOUT DD DSN=AAA.CNTL,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(5,2),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(18:DATENS=(YMD))
/*
In the above code i am creating a file name AAA.PDYYMMDD(here the YYMMDD will be the current YEARMONTHDATE) . This file name is created in the output file AAA.CNTL as NEWNAME (AAA.100309) .
now i want to check whether the file AAA.100309 is existing or not.(File name will varry based on date) |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
It will NOT exist because the dataset name will not conform to standards and will result in a JCL error. |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Not valid data set name! So...
Is it AAA.PD100309 ? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
I feel this is typical REXX candidate to get it done with.. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
In the above code i am creating a file name AAA.PDYYMMDD(here the YYMMDD will be the current YEARMONTHDATE) . This file name is created in the output file AAA.CNTL as NEWNAME (AAA.100309) .
now i want to check whether the file AAA.100309 is existing or not.(File name will varry based on date) |
just sloppy writing I guess
the first sentence tells that the dataset name should generated as AAA.PD100309
( anyway the offset/position seems wrong )
my advice at this point is to review/describe better the process...
what if the datasets exists already
if the action is ... no action in case of existence then a two phase approach might be enough ...
using the IDCAMS allocate function
phase one ... listc the new dataset name
phase two
if LASTCC = 0 then ALLOCATE ELSE do nothing
if more sophisticated processing is needed then I would say that REXX is the way to go |
|
Back to top |
|
|
prakash404
New User
Joined: 09 Mar 2010 Posts: 12 Location: chennai
|
|
|
|
phase one ... listc the new dataset name
phase two
if LASTCC = 0 then ALLOCATE ELSE do nothing
Could you explain it briefly |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
Back to top |
|
|
prakash404
New User
Joined: 09 Mar 2010 Posts: 12 Location: chennai
|
|
|
|
Hi enrico-sorichetti,
The above code will only work when if we know the exact name of the file right.But our file will created in runtime. So how can we excecute the above code? |
|
Back to top |
|
|
Gnanas N
Active Member
Joined: 06 Sep 2007 Posts: 792 Location: Chennai, India
|
|
|
|
Hi,
I guess you can fabricate LISTCAT statement for IDCAMS using SORT as I did in step STEP050 (perhaps in STEP040). I'm sorry this code is untested as I don't have access to mainframe right now. Please check for exact syntax.
Code: |
//STEP040 EXEC SORTD5
//SORTIN DD *
NEWNAME (AAA.PDYYMMDD)
/*
//SORTOUT DD DSN=AAA.CNTL,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(5,2),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(18:DATENS=(YMD))
/*
//*
//STEP050 EXEC SORTD5
//SORTIN DD DSN=AAA.CNTL,DISP=SHR
//SORTOUT DD DSN=&&TEMP,
// DISP=(NEW,PASS,),
// SPACE=(TRK,(5,2),RLSE),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0)
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(1:C'LISTCAT ENTRY(',10,13)
/*
//*
//STEP060 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD DSN=&&TEMP,
// DISP=(OLD,DELETE,) |
Check the return code of STEP060 in next step and do the rest. Or do the things in step STEP060 itself by checking LASTCC. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
Quote: |
So how can we excecute the above code? |
no reason to be confused ...
why don' t You use a bit of imagination...
You found a way of generating one statement, didn' You ?
use the same approach to generate more
something along the lines of
Code: |
//sortin dd *
LISTC ENT(AAA.PD.$$$$$$)
IF LASTCC = 0 THEN DO
ALLOCATE DATASET(AAA.PD.$$$$$$) ....
... other allocation parameters
END
/*
//sortout dd ... |
use for example sort FINDREP to change the $$$$$$ to yymmdd |
|
Back to top |
|
|
prakash404
New User
Joined: 09 Mar 2010 Posts: 12 Location: chennai
|
|
|
|
Thank you Gnana Sekaran Nallathambi and enrico-sorichetti.
The code is working fine. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
The code is working fine. |
Good to hear it is working - thank you for letting us know
It will probably help someone else one day if you post the final working code. . . |
|
Back to top |
|
|
|