Page 1 of 1

Create an empty file using SORT.

Posted: Tue Sep 20, 2016 11:27 am
by ForoXLL
Hi,

Can we Create an empty file using SORT? By empty I mean is it should have any data, it should not be like having a record with sapces but just no record. And it should have based on a condition. Like, if in the input file if we have a string "FORO" somewhere in the record, output file should be empty else it should end with RC=8? Please help how can I do this.

Re: Create an empty file using SORT.

Posted: Tue Sep 20, 2016 2:32 pm
by nicc
What have you tried so far? Did you try INCUDing non-existent records only? Have you looked up in the manual as to when you can influence the return code?

Re: Create an empty file using SORT.

Posted: Tue Sep 20, 2016 8:14 pm
by Magesh_j
ForoXLL wrote:By empty I mean is it should have any data,
I assume it should NOT
ForoXLL wrote:if in the input file if we have a string "FORO" somewhere in the record, output file should be empty else it should end with RC=8? Please help how I can do this.
If input has "FORO", output file should be empty with RC0
If the input doesn't have "FORO", the output should be empty with RC8.

If my understanding of the requirement is right, following code may help you.

Assuming LREC=80

Code: Select all

//CPYJK EXEC PGM=ICETOOL                                                
//TOOLMSG DD SYSOUT=*                                                   
//SYSOUT DD SYSOUT=*                                                    
//DFSMSG DD SYSOUT=*                                                    
//IN1 DD your input file FB/80
//OUT2 DD DSN=OUTPUT.FILE,DISP=(,CATLG,DELETE),                         
//            SPACE=(CYL,(1,1),RLSE),DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)  
//TOOLIN DD *                                                           
  COUNT FROM(IN1) USING(CNT1) RC8 EMPTY                                 
//CNT1CNTL DD *                                                         
  INCLUDE COND=(1,80,SS,EQ,C'FORO')                                     
/*                                                                      
thanks
Magesh

Re: Create an empty file using SORT.

Posted: Tue Sep 20, 2016 8:28 pm
by nicc
I think that shout be OMIT rather than INCLUDE as he wants an empty file - but it depends on interpretation. I think he does NOT want 'FORO'.

But if he has a data set with different types of records in it, and not all types will be present every time, and he wants to extract certain types, which may or may not be there, and he wants an RC of 8 when none of those specific records are present: then INCLUDE is right.

Re: Create an empty file using SORT.

Posted: Tue Sep 20, 2016 10:39 pm
by ForoXLL
Magesh_j wrote:
ForoXLL wrote:By empty I mean is it should have any data,
I assume it should NOT
ForoXLL wrote:if in the input file if we have a string "FORO" somewhere in the record, output file should be empty else it should end with RC=8? Please help how I can do this.
If input has "FORO", output file should be empty with RC0
If the input doesn't have "FORO", the output should be empty with RC8.

If my understanding of the requirement is right, following code may help you.

Assuming LREC=80

Code: Select all

//CPYJK EXEC PGM=ICETOOL                                                
//TOOLMSG DD SYSOUT=*                                                   
//SYSOUT DD SYSOUT=*                                                    
//DFSMSG DD SYSOUT=*                                                    
//IN1 DD your input file FB/80
//OUT2 DD DSN=OUTPUT.FILE,DISP=(,CATLG,DELETE),                         
//            SPACE=(CYL,(1,1),RLSE),DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)  
//TOOLIN DD *                                                           
  COUNT FROM(IN1) USING(CNT1) RC8 EMPTY                                 
//CNT1CNTL DD *                                                         
  INCLUDE COND=(1,80,SS,EQ,C'FORO')                                     
/*                                                                      
thanks
Magesh
Both the assumptions you said are correct. Missed NOT. It works for me.