Page 1 of 1

Omit the data

PostPosted: Mon Mar 14, 2016 12:51 pm
by mvmanish
As per my JCL. the output looks like below. Here i want to omit the data that comes after numeric digits(omit the all data starts from "FOR')
2895 FOR TABLE DBOW
82374 FOR TABLE    
68657 FOR TABLE    
896 FOR TABLE      
251 FOR TABLE      
34772 FOR TABLE DBO
32534 FOR TABLE    
118582 FOR TABLE  
230569 FOR TABLE  
3031 FOR TABLE DBOW

Re: Omit the data

PostPosted: Mon Mar 14, 2016 1:21 pm
by Aki88
Hello,

Look up PARSE function of DFSORT in the 'DFSORT Application Programming Guide'.
Few assumptions before the solution, since you have not specified the length of the 'number' that can appear before 'FOR', I have assumed that there can be 50 characters at maximum before 'FOR' appears. Next, you have not specified if the input file is fixed length or variable, I have assumed it to be of fixed length. You have not shown the expected output, I have assumed that the output looks something as below:


Expected output:

2895  
82374  
68657  
896    
251    
34772  
32534  
118582
230569
3031  
 


A quick and dirty solution:


 SORT FIELDS=COPY                            
 INREC PARSE=(%01=(ENDBEFR=C'FOR',FIXLEN=50)),
         BUILD=(1:%01)                        
 


Hth.

Re: Omit the data

PostPosted: Mon Mar 14, 2016 3:18 pm
by BillyBoyo
One small point, which is that there is a blank before the FOR. ENDBEFR=C' FOR' or simply ENDBEFF=BLANK will do. It won't matter for the result of fixed-length output, but someone looking at the code later may wonder about that blank, so don't give them an opportunity to wonder :-)

Re: Omit the data

PostPosted: Mon Mar 14, 2016 3:54 pm
by mvmanish
Hi Aki88,

The data which i posted is the output of sort jcl. My input file is VBA.There are 73 characters before "FOR". Only 10 characters after "FOR". I want to eliminate the characters after "FOR" in my output. I'm using include condition in my JCL.

Re: Omit the data

PostPosted: Mon Mar 14, 2016 5:04 pm
by BillyBoyo
Well, you apply Aki88's solution to your data. You can't use INCLUDE for this, INCLUDE/OMIT COND and INCLUDE=/OMIT= operate at the record level.

SORT FIELDS=COPY                            
 INREC PARSE=(%01=(ENDBEFR=C' FOR',FIXLEN=73)),
         BUILD=(1,4,%01)
 OUTFIL VLTRIM=C' '


The PARSE pads up to 73 bytes, the VLTRIM=C' ' will chop off the trailing blanks for the final output, automatically adjusting the record-length.

Re: Omit the data

PostPosted: Mon Mar 14, 2016 5:09 pm
by Aki88
Hello Billy,

I second your point :)

Thank you.