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
 

 

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: 158
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: 4648
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: 158
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: 4648
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: 2033
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: 158
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: 755
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: 1226
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 REXX cdoe to purge a JOB from spool a... Sulabh Agrawal CLIST & REXX 11 Thu Mar 09, 2017 11:36 am
No new posts Overriding PS data in rexx Shaheen Shaik CLIST & REXX 8 Fri Mar 03, 2017 5:08 pm
No new posts Write R1 and R2 to OP1 and R1 to OP2 bhaskar_kanteti DFSORT/ICETOOL 10 Fri Mar 03, 2017 11:18 am
No new posts Can you write 2 recs on SORTOUT when ... Sysaron DFSORT/ICETOOL 6 Thu Feb 23, 2017 12:07 am
No new posts REXX compiled via RXTCOMP sergeyken CLIST & REXX 7 Tue Feb 07, 2017 9:41 pm


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