View previous topic :: View next topic
Author
Message
chandan.inst Active User Joined: 03 Nov 2005Posts: 275 Location: Mumbai
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
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
is getting considered less than
when my fields are like
and
its working fine.
I tried to search on forum but no luck
Any inputs on this will be really appreciated
Thanks,
Chandan
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3053 Location: NYC,USA
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
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2023 Location: USA
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
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
doesn' t syncosrt support the SFF format like dfsort does ?
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2023 Location: USA
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
chandan.inst Active User Joined: 03 Nov 2005Posts: 275 Location: Mumbai
Thank you very much sergeyken. I will give try with this solution
Back to top
sergeyken Senior Member Joined: 29 Apr 2008Posts: 2023 Location: USA
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
Please enable JavaScript!