SORT JCL - INREC OVERLAY

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

SORT JCL - INREC OVERLAY

Post by Gurugars » Thu Aug 16, 2012 10:12 pm

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
Guru:-)

You're never fully dressed without a smile :)

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Aug 17, 2012 12:00 am

Your input does not appear to match the code . . .

Possibly i'm missing something.
Have a good one

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Aug 17, 2012 6:16 am

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.

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Fri Aug 17, 2012 12:02 pm

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.
Guru:-)

You're never fully dressed without a smile :)

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Fri Aug 17, 2012 1:50 pm

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?

User avatar
Gurugars
Active Member
Posts: 107
Joined: Sat Oct 23, 2010 2:17 pm
Location: Chennai,India.

Post by Gurugars » Fri Aug 17, 2012 3:36 pm

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  
Guru:-)

You're never fully dressed without a smile :)

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Aug 17, 2012 8:35 pm

Good to hear it is working - thank you for the followup :)

d

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 9:53 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others