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
 

 

Write a text message when the file is EMPTY

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
V S Amarendra Reddy

Active User


Joined: 13 Sep 2006
Posts: 189
Location: INDIA

PostPosted: Fri Nov 25, 2011 8:06 pm    Post subject: Write a text message when the file is EMPTY
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    Post subject: Reply to: Write a text message when the file is EMPTY
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    Post subject: Reply to: Write a text message when the file is EMPTY
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 Moderator


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

PostPosted: Sat Nov 26, 2011 7:11 am    Post subject:
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: 189
Location: INDIA

PostPosted: Sat Nov 26, 2011 10:21 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm
No new posts Updating a VSAM file with DISP=OLD sheersh JCL & VSAM 8 Tue Mar 14, 2017 6:14 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm


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