IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Whether the particular file inside a PS is existing or not


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prakash404

New User


Joined: 09 Mar 2010
Posts: 12
Location: chennai

PostPosted: Tue Mar 09, 2010 11:54 am
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Mar 09, 2010 11:57 am
Reply with quote

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" icon_question.gif icon_question.gif
Back to top
View user's profile Send private message
prakash404

New User


Joined: 09 Mar 2010
Posts: 12
Location: chennai

PostPosted: Tue Mar 09, 2010 12:32 pm
Reply with quote

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Mar 09, 2010 12:34 pm
Reply with quote

It will NOT exist because the dataset name will not conform to standards and will result in a JCL error.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 09, 2010 12:37 pm
Reply with quote

Quote:
AAA.100309

Not valid data set name! So...

Is it AAA.PD100309 ?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Mar 09, 2010 12:39 pm
Reply with quote

I feel this is typical REXX candidate to get it done with..
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Mar 09, 2010 12:43 pm
Reply with quote

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
View user's profile Send private message
prakash404

New User


Joined: 09 Mar 2010
Posts: 12
Location: chennai

PostPosted: Tue Mar 09, 2010 1:05 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Mar 09, 2010 1:30 pm
Reply with quote

Code:
//AMS EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
  LISTC ENT(<your new dataset name>)
  IF LASTCC = 0 THEN DO
    ALLOCATE .....
  END
/*


see publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DGT2I260/CCONTENTS?SHELF=DGT2BK71&DN=SC26-7394-07&DT=20080123101112
for the proper statements syntax
Back to top
View user's profile Send private message
prakash404

New User


Joined: 09 Mar 2010
Posts: 12
Location: chennai

PostPosted: Tue Mar 09, 2010 4:52 pm
Reply with quote

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? icon_sad.gif
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Tue Mar 09, 2010 5:12 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Mar 09, 2010 5:42 pm
Reply with quote

Quote:
So how can we excecute the above code?

no reason to be confused ...
why don' t You use a bit of imagination... icon_question.gif icon_evil.gif
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
View user's profile Send private message
prakash404

New User


Joined: 09 Mar 2010
Posts: 12
Location: chennai

PostPosted: Tue Mar 09, 2010 5:46 pm
Reply with quote

Thank you Gnana Sekaran Nallathambi and enrico-sorichetti.
The code is working fine.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 09, 2010 10:59 pm
Reply with quote

Hello,

Quote:
The code is working fine.
Good to hear it is working - thank you for letting us know icon_smile.gif

It will probably help someone else one day if you post the final working code. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top