IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Compare fields with decimal


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Thu Apr 04, 2019 5:29 pm
Reply with quote

Hi All,

I have two 13 byte fields in my input file which I want to compare and those fields have hard coded decimal in it. so the field two will be as below

Code:
Field 1 -12.3


Code:
Field 2 - 9.12


I want to eliminate the records prom processing when field1 is greater than Field 2.

Catch here is fields don't have leading zeros so I can't do the character comparison because here
Code:
12
is getting considered less than
Code:
9.


when my fields are like
Code:
12.30
and
Code:
11.40
its working fine.

I tried to search on forum but no luck icon_sad.gif

Any inputs on this will be really appreciated

Thanks,
Chandan
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Apr 05, 2019 1:33 am
Reply with quote

So basically you need to reformat these fields to have leading or/and trailing zeroes and if you know the length or decimal type of these fields then let us know ? If answer is yes then there many post related to it on internet , see if you get one close to what you looking for.
e.g. ibmmainframes.com/about38466.html
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Fri Apr 05, 2019 10:25 pm
Reply with quote

This is a simple example, with SYNCSORT as the tool
Code:
//*=====================================================================
//INPUT    EXEC PGM=SYNCSORT                                           
//*                                                                     
//SYSOUT   DD  SYSOUT=*                                                 
//*                                                                     
//SORTIN   DD  *                                                       
12.3           9.57           X                                         
12.3           11.40          X                                         
12.3           99.57          X                                         
12.3           1000.40        X                                         
12.3           12.300000      X                                         
12.3           0000012.3      X                                         
//*                                                                     
//SORTOUT  DD  SYSOUT=*                                                 
//*                                                                     
//SYSIN    DD  *                                                       
 INREC PARSE=(%1=(ABSPOS=1,                                             
                  STARTAT=NONBLANK,                                     
                  ENDBEFR=C'.',                                         
                  ENDBEFR=BLANKS,                                       
                  FIXLEN=13),                                           
              %2=(ENDBEFR=BLANKS,                                       
                  FIXLEN=13),                                           
              %3=(ABSPOS=15,                                           
                  STARTAT=NONBLANK,                                     
                  ENDBEFR=C'.',                                         
                  ENDBEFR=BLANKS,                                       
                  FIXLEN=13),                                           
              %4=(ENDBEFR=BLANKS,                                       
                  FIXLEN=13)),                                         
       BUILD=(1,15,                                                     
             16,15,                                                     
              %1,JFY=(SHIFT=RIGHT,LENGTH=10,LEAD=C'0000000000'),       
              %2,JFY=(SHIFT=LEFT,LENGTH=5,TRAIL=C'00000'),             
              X,                                                       
              %3,JFY=(SHIFT=RIGHT,LENGTH=10,LEAD=C'0000000000'),       
              %4,JFY=(SHIFT=LEFT,LENGTH=5,TRAIL=C'00000'))             
 SORT FIELDS=COPY                                                       
*                                                                       
 OUTFIL FNAMES=(SORTOUT),                                               
        IFTHEN=(WHEN=(31,15,ZD,GT,47,15,ZD),                           
                BUILD=(1,61,C'<== GREATER')),                           
        IFTHEN=(WHEN=(31,15,ZD,LT,47,15,ZD),                           
                BUILD=(1,61,C'<== LESS')),                             
        IFTHEN=(WHEN=(31,15,ZD,EQ,47,15,ZD),                           
                BUILD=(1,61,C'<== EQUAL'))                             
*                                                                       
 END                                                                   
//*                                                                     
//*=====================================================================


The result looks like this
Code:
********************************* TOP OF DATA *****************************
12.3           9.57           000000001230000 000000000957000<== GREATER   
12.3           11.40          000000001230000 000000001140000<== GREATER   
12.3           99.57          000000001230000 000000009957000<== LESS     
12.3           1000.40        000000001230000 000000100040000<== LESS     
12.3           12.300000      000000001230000 000000001230000<== EQUAL     
12.3           0000012.3      000000001230000 000000001230000<== EQUAL     
******************************** BOTTOM OF DATA ***************************


If you would like to consider also positive/negative values, this is a training opportunity for yourself.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Apr 05, 2019 11:09 pm
Reply with quote

doesn' t syncosrt support the SFF format like dfsort does ?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Fri Apr 05, 2019 11:30 pm
Reply with quote

enrico-sorichetti wrote:
doesn' t syncosrt support the SFF format like dfsort does ?

It does, but everything except digits and minus is ignored, including decimal point...

Quote:
SFF - Signed free format.

Decimal digits (0-9) are extracted from right to left to form a number value. A character of – or ) found within the field will cause the value to be treated as a negative number. All other non-decimal digit values in the field are ignored. A maximum of 31 digits can be provided. When more than 31 digits are found in the field, the leftmost digits will be ignored.
Back to top
View user's profile Send private message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 275
Location: Mumbai

PostPosted: Mon Apr 08, 2019 9:30 am
Reply with quote

Thank you very much sergeyken. I will give try with this solution
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Fri Apr 12, 2019 11:45 pm
Reply with quote

chandan.inst wrote:
Thank you very much sergeyken. I will give try with this solution

I noticed that parameter ENDBEFR=BLANKS might give an unexpected problem with some input data....
Now I recommend to replace it with ENDBEFR=C' '
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Compare two files with a key and writ... SYNCSORT 3
Search our Forums:

Back to Top