|
View previous topic :: View next topic
|
| Author |
Message |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Hi,
My requirement is to check the COUNT of the record of the i/p file and if the file is EMPTY write a message in the same file.
I've achieved that using the below code. But it is throwing return code 12 when the file is NOT EMPTY. I read the manual and understood that it works the same way.
We are not expecting the max cc as 12 to pass to down stream steps, so can someone please give some other idea or give someway to reset the code to zero even in case of NOT EMPTY?
| Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//DD1 DD DSN=i/p file,DISP=OLD
//TOOLIN DD *
COUNT FROM(DD1) NOTEMPTY
COPY FROM(DD1) USING(CTL1)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=DD1,TRAILER1=(C'THIS IS AN EMPTY DATASET',80:X),
REMOVECC,NODETAIL
/*
|
Regards
Amar |
|
| Back to top |
|
 |
girishbs13
New User
Joined: 11 Nov 2011 Posts: 24 Location: India
|
|
|
|
You can do this in two steps.
1. Use DFSORT NULLOUT to set return code if the file is empty.
2. Write the message to the file if the return code is set
Not sure if this can me done in a single step |
|
| Back to top |
|
 |
girishbs13
New User
Joined: 11 Nov 2011 Posts: 24 Location: India
|
|
|
|
something like this
| Code: |
//STEP0010 EXEC PGM=SORT,PARM='NULLOUT=RC4'
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTOUT DD DUMMY
//SORTIN DD i/p dataset
//SYSIN DD *
OPTION COPY,NULLOUT=RC4,STOPAFT=1
//*
//STEP0020 EXEC PGM=SORT,COND=(04,NE,STEP0010)
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTOUT DD same i/p dataset
//SORTIN DD dummy dataset
//SYSIN DD *
OPTION COPY
OUTFIL TRAILER1=(C'THIS IS AN EMPTY',80:X),
REMOVECC,NODETAIL
//* |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
girishbs13,
Your job returns RC=4 or RC=0. Amar wanted RC=0 in both cases so your job doesn't do what he asked for.
Amar,
DFSORT does NOT support a COPY application using the same file for input and output. You could end up losing your file.
Here's a DFSORT job that will do what you asked for without the possibility of losing your input data set. Note that step S1 uses DISP=SHR for the input file and step S2 uses DISP=MOD for the input filet. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed for other attributes.
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=... input file
//CT DD DSN=&&CT,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY,STOPAFT=1
OUTFIL FNAMES=CT,REMOVECC,NODETAIL,
TRAILER1=(COUNT=(M11,LENGTH=1))
//*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DISP=MOD,DSN=.... input file
//SORTOUT DD DSN=&&IN,DISP=(MOD,PASS)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,1,ZD,EQ,0)
INREC BUILD=(C'THIS IS AN EMPTY DATASET',80:X)
/*
|
|
|
| Back to top |
|
 |
V S Amarendra Reddy
Active User

Joined: 13 Sep 2006 Posts: 221 Location: USA
|
|
|
|
Hi Frank,
Well, Thank you very much for the solution given. I had been expecting something like this...
Regards
Amar |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|