Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Whether the particular file inside a PS is existing or not

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Whether the particular file inside a PS is existing or not
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    Post subject: Re: HOW TO FIND WHETHER THE DYNAMIC FILE IS EXISTING OR NOT
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    Post subject: Dynamic file
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: 8593
Location: Back in jolly old England

PostPosted: Tue Mar 09, 2010 12:34 pm    Post subject:
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: 785
Location: Chennai, India

PostPosted: Tue Mar 09, 2010 12:37 pm    Post subject:
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Mar 09, 2010 12:43 pm    Post subject: Reply to: HOW TO FIND WHETHER THE DYNAMIC FILE IS EXISTING O
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    Post subject: phase one ... listc the new dataset name
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Mar 09, 2010 1:30 pm    Post subject: Reply to: Whether the particular file inside a PS is existin
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 http://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    Post subject: Hi
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: 785
Location: Chennai, India

PostPosted: Tue Mar 09, 2010 5:12 pm    Post subject: Reply to: Whether the particular file inside a PS is existin
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Mar 09, 2010 5:42 pm    Post subject: Reply to: Whether the particular file inside a PS is existin
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    Post subject: Thankq
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

Site Director


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

PostPosted: Tue Mar 09, 2010 10:59 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us