IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Write a text message when the file is EMPTY


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Fri Nov 25, 2011 8:06 pm
Reply with quote

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
View user's profile Send private message
girishbs13

New User


Joined: 11 Nov 2011
Posts: 24
Location: India

PostPosted: Fri Nov 25, 2011 10:25 pm
Reply with quote

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
View user's profile Send private message
girishbs13

New User


Joined: 11 Nov 2011
Posts: 24
Location: India

PostPosted: Fri Nov 25, 2011 10:40 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Nov 26, 2011 7:11 am
Reply with quote

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
View user's profile Send private message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 216
Location: USA

PostPosted: Sat Nov 26, 2011 10:21 pm
Reply with quote

Hi Frank,

Well, Thank you very much for the solution given. I had been expecting something like this... icon_smile.gif


Regards
Amar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top