Page 1 of 1

SORT JCL - INREC OVERLAY

Posted: Thu Aug 16, 2012 10:12 pm
by Gurugars
Hi,

I am trying to do - INREC OVERLAY as follows

Code: Select all

//SYSIN    DD *                                        
   INREC IFTHEN=(WHEN=(25,04,CH,EQ,C'0.00'),           
                 OVERLAY=(5:5,20,C'"0.00"',29,35)),    
         IFTHEN=(WHEN=(22,04,CH,EQ,C'0.00'),           
                 OVERLAY=(5:5,17,C'"0.00"',26,35))     
   SORT FIELDS=COPY                                    
// 



Input:

Code: Select all

----+----1----+----2----+----3----+----4----+----5----
C01.C03.YRCOMP.0001.0.00."25,000.00"                  
3CR..YRCOMP.0001.0.00."25,000.00"                     
Output:

Code: Select all

----+----1----+----2----+----3----+----4----+----5---
********************************* Top of Data *******
C01.C03.YRCOMP.0001."0.00"0"25,000.00"               

Code: Select all

----+----1----+----2----+----3----+----4----+--
3CR..YRCOMP.0001."0.00"0"25,000.00"            
Could someone please tell me why I'm getting 0 after "0.00"
C01.C03.YRCOMP.0001."0.00"0"25,000.00"

My intention is to change the 0.00 to "0.00" that's it.

I/P info - 80 B, VB file (Tab delimited file)
O/P info - 80B, VB file

Posted: Fri Aug 17, 2012 12:00 am
by DikDude
Your input does not appear to match the code . . .

Possibly i'm missing something.

Posted: Fri Aug 17, 2012 6:16 am
by William Collins
Along with DikDude, I don't see how you get from your input to your output with those cards.

Code: Select all

//SYSIN    DD *                                       
   INREC IFTHEN=(WHEN=(25,04,CH,EQ,C'0.00'),           
                 OVERLAY=(25:C'"0.00"',29)),   
         IFTHEN=(WHEN=(22,04,CH,EQ,C'0.00'),           
                 OVERLAY=(22,C'"0.00"',26))     
   SORT FIELDS=COPY                                   
// 
The above should not change the output you get, but there is no reason to change the first portion of your record to its original content. You are "overlaying", so leave the first part of the record alone, put your new zero, then pick up the end of the record - don't specify a length, DFSORT will do "from 29/26 to the end if the record" for you.

You might find a simpler solution with PARSE if you records are tab-delimited.

Posted: Fri Aug 17, 2012 12:02 pm
by Gurugars
Thanks DickDude and William -

Yes I was doing PARSE only in the OUTREC. But the thing is - my input will be having amount fields, when ever zeros coming as an amount value I will be getting that value as 0.00 but if it is greater than zero it will be "xxxxxx.00". In order to make the parse condition consistent I am doing this INREC OVERLAY.

Please see my input -

Code: Select all

----+----1----+----2----+----3----+----4----+-
********************************* Top of Data 
C01.C03.YRCOMP.0001.0.00."25,000.00"          
C01.C03.YRCOMP.0002."25,001.00"."50,000.00"   
C01.C03.YRCOMP.0003."50,001.00"."100,000.00"  
in the first row after 0001 the value came as 0.00, but in the second row the value came as "25,000.00". here I want to make my PARSE condition as a consistent one in all the record where I am doing parse in the outrec.

Posted: Fri Aug 17, 2012 1:50 pm
by William Collins
At a guess, then, you are getting "25,000.00" because your file is being created as a genuine "comma-seperated" file. The double-quotes "protect" the "," in the number.

This would mean that it is not only zero which will give you a problem, but anything less than 1,000 will, as that will not contain a comma either.

"Something" has then "converted" the comma-separators to tabs and not bothered to remove the double-quotes which no longer have a function.

The "neatest" solution would be to get the creation of the file as genuinely tab-delimited. Tab delimiters are often chosen because the tab character, unlike the comma, is unlikely to genuinely appear in plain text data.

Next "neatest" is to change the definition of the output numeric fields so that they do not include the commas.

Next "neatest" would be to change the "fixer-upper-to-tabs" so that it removes the double-quotes.

Next "neatest" is to use PARSE and deal with the number formats yourself.

On the other hand, if you think about it, if that tab-delimited file was going back into a spreadsheet program, there is no problem with the data content one moment being 10.00 and the next "25,000.00". Are you sure that the data actually causes you a problem, or are you only expecting that?

Posted: Fri Aug 17, 2012 3:36 pm
by Gurugars
William - Thanks a lot for your time in this.

Yes you are absolutely correct -
This would mean that it is not only zero which will give you a problem, but anything less than 1,000 will, as that will not contain a comma either.
I solved this with FINDREP in INREC.!

Code: Select all

//SYSIN    DD *                                      
   INREC IFTHEN=(WHEN=INIT,                          
         FINDREP=(INOUT=(C'"',C'')))                 
   SORT FIELDS=COPY                                  
   OMIT COND=(5,3,CH,EQ,C'IBD')                      
   OUTREC PARSE=(%01=(ENDBEFR=X'05',FIXLEN=04),      
                 %02=(ENDBEFR=X'05',FIXLEN=03),      
                 %03=(ENDBEFR=X'05',FIXLEN=10),      
                 %04=(ENDBEFR=X'05',FIXLEN=04),      
                 %05=(ENDBEFR=X'05',FIXLEN=24),      
                 %06=(ENDBEFR=X'05',FIXLEN=24)),     
   BUILD=(%01,%02,X,%03,%04,X,                       
         %05,SFF,TO=ZD,X,%06,SFF,TO=ZD,80:X),VTOF    

Now I am able to get all the values even which is lesser tahn 1,000

output -

Code: Select all

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----
********************************* Top of Data ****************************
3CR 3CR NETWTH    0001 000000000000000000000100 000000000000000000200000  
3CR 3CR NETWTH    0002 000000000000000000200100 000000000000000000300000  
3CR 3CR NETWTH    0003 000000000000000000300100 000000999999999999999900  

Posted: Fri Aug 17, 2012 8:35 pm
by DikDude
Good to hear it is working - thank you for the followup :)

d

Topic deleted by Admin

Posted: Mon Jan 25, 2016 9:53 pm
by academyindia4
<< Content deleted By Admin >>