Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Compare fields with decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
chandan.inst

Active User


Joined: 03 Nov 2005
Posts: 273
Location: Mumbai

PostPosted: Thu Apr 04, 2019 5:29 pm    Post subject: Compare fields with decimal
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

Senior Member


Joined: 21 Sep 2010
Posts: 2271
Location: NY,USA

PostPosted: Fri Apr 05, 2019 1:33 am    Post subject:
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. http://ibmmainframes.com/about38466.html
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 566
Location: Maryland

PostPosted: Fri Apr 05, 2019 10:25 pm    Post subject:
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

Senior Member


Joined: 14 Mar 2007
Posts: 10626
Location: italy

PostPosted: Fri Apr 05, 2019 11:09 pm    Post subject: Reply to: Compare fields with decimal
Reply with quote

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

Active Member


Joined: 29 Apr 2008
Posts: 566
Location: Maryland

PostPosted: Fri Apr 05, 2019 11:30 pm    Post subject: Re: Reply to: Compare fields with decimal
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: 273
Location: Mumbai

PostPosted: Mon Apr 08, 2019 9:30 am    Post subject:
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

Active Member


Joined: 29 Apr 2008
Posts: 566
Location: Maryland

PostPosted: Fri Apr 12, 2019 11:45 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Formatting bit fields IanWorthington DFSORT/ICETOOL 9 Thu Sep 19, 2019 6:14 pm
This topic is locked: you cannot edit posts or make replies. Compare two files logic in COBOL Nishant Singhal COBOL Programming 4 Sun Aug 25, 2019 2:25 am
No new posts Compare duplicate records in same file pshongal DFSORT/ICETOOL 3 Fri Aug 09, 2019 9:37 am
No new posts Convert Numeric to Packed decimal and... anand1204 DFSORT/ICETOOL 5 Thu Aug 08, 2019 3:53 am
No new posts Training on numeric fields data formats sergeyken SYNCSORT 12 Thu Aug 01, 2019 8:15 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us