Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Close and open a PS in read mode from write mode using REXX.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 160
Location: India

PostPosted: Fri Apr 16, 2010 7:27 pm    Post subject: Close and open a PS in read mode from write mode using REXX.
Reply with quote

Hi,

I have REXX program which is writing some data into a new PS file.

Sometimes its is creating empty file.

Now I need to avoid creating empty file.

To do this, I am planning to

1. Close already opened file which is in Write mode.
2. Open the file in read mode.
3. Read all the records into array.
4. Check the count.
4. 1 If Count is ZERO then delete the file.

Please let me know how to close a file in REXX.

I have coded for 2-4 points.
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Fri Apr 16, 2010 7:31 pm    Post subject: Reply to: Close and open a PS in read mode from write mode u
Reply with quote

Specifying 'FINIS' as part of an EXECIO statement essentially closes the file:

"EXECIO 0 DISKW ddname (FINIS"
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Apr 16, 2010 7:38 pm    Post subject:
Reply with quote

Why not just keep a count of the records written and delete the file if the count is zero? This would avoid the extra opening, reading, closing of the file.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Fri Apr 16, 2010 7:49 pm    Post subject:
Reply with quote

Why read ALL of the records into an array to determine if the file is EMPTY? Why not read just ONE record - if not EOF on the first read, the file is not empty.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 160
Location: India

PostPosted: Fri Apr 16, 2010 7:54 pm    Post subject:
Reply with quote

Thanks for your quick reply.

This program is copying joblog from spool by taking jobname and jobid as input.

To do this task, couple of TSO commands are QUEUED and those are executed. Then joblog is getting copied to the PS.

If jobname name or jobid is not present in spool it is creating empty dataset.

Hi Kevin,

I have coded below commands.

Code:

"ALLOC F(TEMPPRT) DA("XDCNAME") NEW CATALOG REU "

.....
.....
.....
.....

"EXECIO * DISKW TEMPPRT(FINIS"

"ALLOC DD(INFILE) DSN("XDCNAME") OLD"

"EXECIO * DISKR INFILE(FINIS STEM MYVAR."
Say MYVAR.0
If  MYVAR.0 = 0 Then
Do
 Say 'Either JOBNAME or JOBID is not present in SPOOL'
 "DELETE "||XDCNAME
 Say 'DELETED.............!: 'XDCNAME
 Exit
End


Here XDCNAME contains 'ABCD.USERID.JOBNAME.JOBLOG' PS name.

It is giving below error message and is creating the file.


Code:
 DATA SET ABCD.USERID.JOBNAME.JOBLOG NOT ALLOCATED, FILE IN US
E


Please suggest me how to resolve this error and how can I delete if the file is empty.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Fri Apr 16, 2010 8:52 pm    Post subject: Reply to: Close and open a PS in read mode from write mode u
Reply with quote

Not really a REXX issue, but anyway ...

You coded:

"ALLOC F(TEMPPRT) DA("XDCNAME") NEW CATALOG REU"

which is a TSO command that allocates the dataset name held in the variable 'XDCNAME' to the TEMPPRT DD name. A disposition of NEW gives exclusive access to the dataset (I presume you already know this).

Then, you coded:

"EXECIO * DISKW TEMPPRT (FINIS"

which, as I mentioned, closes the DD TEMPPRT for WRITE access.

Then, you coded:

"ALLOC DD(INFILE) DSN("XDCNAME") OLD"

which is going to cause a problem. You already have the dataset contained in the variable 'XDCNAME' allocated to the DD name TEMPPRT from above, which as I stated with the NEW disposition has an exclusive lock on that resource. You already have the dataset allocated, so why bother to perform another allocation? But, you're the programmer, so that's your call. You can just forget about performing another allocation, or you have to remove the exclusive lock, either by issuing a TSO FREE command ("FREE F(TEMPPRT)") and/or by remembering to use the REUSE parameter for your subsequent allocate command:

"ALLOC DD(INFILE) DSN("XDCNAME") OLD REU"
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Sat Apr 17, 2010 1:18 am    Post subject: Reply to: Close and open a PS in read mode from write mode u
Reply with quote

You did not answer Craq's question:
Quote:
Why not just keep a count of the records written and delete the file if the count is zero? This would avoid the extra opening, reading, closing of the file.


I would amend to say: Why allocate and write to it if you have no records to write? That is, why not delay allocating until you know you have data to write?

Use the QUEUED() function to determine if there are records in the queue.
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 160
Location: India

PostPosted: Mon Apr 19, 2010 2:47 pm    Post subject:
Reply with quote

Thank you very much Kevin and all,

It's working.

I just deleted "ALLOC DD(INFILE) DSN("XDCNAME") OLD" line form code and changed "EXECIO * DISKR INFILE(FINIS STEM MYVAR." line to "EXECIO * DISKR TEMPPRT(FINIS STEM MYVAR.".

Now it is working as expected.

Once again thank you for help.
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Mon Apr 19, 2010 4:48 pm    Post subject:
Reply with quote

...just one hint:

If you have Beta Products for JobLog and PrintOut installed, you could use the batch programm BSS01RFF to collect the informations you want.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Mon Apr 19, 2010 10:21 pm    Post subject: Re: Reply to: Close and open a PS in read mode from write mo
Reply with quote

You completely ignored Craq's question and Pedro's remarks:
Pedro wrote:
You did not answer Craq's question:
Quote:
Why not just keep a count of the records written and delete the file if the count is zero? This would avoid the extra opening, reading, closing of the file.


I would amend to say: Why allocate and write to it if you have no records to write? That is, why not delay allocating until you know you have data to write?

Use the QUEUED() function to determine if there are records in the queue.


Although you've got your result, your program is definitely badly written.
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us