View previous topic :: View next topic
|
Author |
Message |
Ravi Kuchi
New User
Joined: 29 May 2012 Posts: 14 Location: INDIA
|
|
|
|
Hi Friends,
Is there a possibility to write an assembler module that could open a file (it could be either FB or VB) and check if it is empty or not ?
or else
do we need to have seperate modules for each of these kind?
Thanks! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
posting a question on an internet forum is RESEARCHING?
in addition to being either FB or VB, is the DSN (Dataset Name) known at run-time,
or is this dynamic?
also, do you differentiate between allocated
and allocated/opened/closed
when you mean empty?
IF the DSN is known at run-time, there are plenty of threads in the
DFSORT forum (as well as the JCL forum - syncsort as well as IBM utilities)
that deal with this question
that you could research.
So is this a question about Assembler
or the function of determining if a file is empty? |
|
Back to top |
|
|
Ravi Kuchi
New User
Joined: 29 May 2012 Posts: 14 Location: INDIA
|
|
|
|
Yes, The DSN name is known at run time.
Let me explain the assembler module we are trying to build.
1) The module should open the file.
2) If the file open is succesful, then it would try to read the first record.
3) If the file open is not successful then it should return with return-code 8
4) If a record is present then it should close the file and exit with return code of 4
5) If the file is empty then it should exit with return code of Zero.
Hope, I am clear.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It is still not clear to me if the goal is the process to determine if the file is empty or the goal is just to write some assembler
What does "open not successful" mean? If the file does not exist, it cannot be opened and if named in the JCL will cause a jcl error before the code is even running.
As DBZ mentioned, look in the sort and jcl parts of the forum as there are several topics dealing with detecting an empty file. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If you issue an IDCAMS PRINT COUNT(0) and the RC=04, then the file is empty. COUNT(0) prevents records from being printed as their contents might not be for non-authorized eyes. Management likes precautions like this.... |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Quote: |
If you issue an IDCAMS PRINT COUNT(0) and the RC=04, then the file is empty. |
Really Bill ?
Code: |
IDCAMS SYSTEM SERVICES TIME:
08:47:20 07/20/12 PAGE 1
REPRO IFILE(DUMMY) OFILE(OUTPUT)
IDC0005I NUMBER OF RECORDS PROCESSED WAS 0
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0
PRINT IFILE(OUTPUT) COUNT(0)
IDCAMS SYSTEM SERVICES TIME: 08:47:20 07/20/12 PAGE 2
LISTING OF DATA SET -SYS12202.T084720.RA000.XIBFIDC.R0000001
IDC0005I NUMBER OF RECORDS PROCESSED WAS 0
IDC0001I FUNCTION COMPLETED, HIGHEST CONDITION CODE WAS 0
IDCAMS SYSTEM SERVICES TIME: 08:47:20 07/20/12 PAGE 3
IDC0002I IDCAMS PROCESSING COMPLETE. MAXIMUM CONDITION CODE WAS 0
|
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
It's Friday Peter, go slow... |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Anuj, just saying have a nice week-end. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Well the strange thing is :
with a PRINT of
COUNT(0) will give a max cond code of 0
COUNT(1) will give a max cond code of 4
with a repro of the empty file to another dummy dataset :
without COUNT will give a max cond code of 0
with COUNT(1) will give a max cond code of 4 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Well, it "successfully" processed zero records . . . hence the cc zero?
And unsuccessfully processes one record - so the cc 4?
The successful count of zero records varified the existence of the file (which would have caused a jcl error if it did not exist)?
Yup, kinda strange. . . |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Peter,
COUNT(1) is the correct choice, returning an RC=04 for an empty file.
I've used this for many years. But, as CRS kicks in , I may have been thinking of a VSE environment, where COUNT("whatever") returns an RC=04 for an empty file. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Hallo Bill,
with all respect, i was just doing some tests with that idcams stuff. And did you mean with CRS this ? :
crs.org/ |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Hi Peter,
Actually, CRS is correct (Can't Remember Sh*t).
|
|
Back to top |
|
|
|