Page 1 of 1

Add value to outrec field

PostPosted: Fri May 28, 2010 7:00 pm
by richagoyal
hi ,
i am trying to add value to my field. It is a CSV file and while converting to non csv i am using parse and using add . but in my o/p it is appending that many digits to input value rather than adding value.

input file :
1,2,3.4567,3
1,2,4.1274,4
1,2,5.5628,5

required o/p
1,2,3.457,3
1,2,4.127,4
1,2,5.563,5

I want to add x.xxxa = x.xxxa +.0001 if a >= 5
can any body help me in this ?

Re: Add value to outrec field

PostPosted: Fri May 28, 2010 10:12 pm
by Frank Yaeger
Your file appears to have each field in the same position in each record. Is that always the case? Are fields 1, 3 and 4 always 1 character? is field2 always x.xxxx? Or can you have other variations (e.g. xx.xxxx). If you can have other variations, indicate what variations you can have and show an example.

What is the RECFM and LRECL of your input file?

It looks like you're just trying to round up field 3 - is that correct?

Re: Add value to outrec field

PostPosted: Mon Jun 14, 2010 3:02 pm
by richagoyal
hi ,

Fields 1 , 3,4 are not always 1 character . field2 is of length 10 byte comp with v999 so it is always xx.xxx . record format of input is VB .

INREC IFTHEN=(WHEN=(5,3,CH,EQ,C'001'),
PARSE=(%01=(ENDBEFR=C',',FIXLEN=3),
%02=(ENDBEFR=C'-',FIXLEN=4),
%03=(ENDBEFR=C'-',FIXLEN=2),
%04=(ENDBEFR=C',',FIXLEN=2),
%05=(ENDBEFR=C',',FIXLEN=19)),
BUILD=(1,4,%01,%02,%03,%04,%05,1336C' ')),
IFTHEN=(WHEN=(5,3,CH,EQ,C'002'),
PARSE=(%10=(ENDBEFR=C',',FIXLEN=3),
%11=(ENDBEFR=C',',FIXLEN=8),
%70=(ENDBEFR=C',',FIXLEN=10),
%12=(ENDBEFR=C',',FIXLEN=10),
%13=(ENDBEFR=C',',FIXLEN=10),
%14=(ENDBEFR=C',',FIXLEN=19),
%15=(ENDBEFR=C',',FIXLEN=19),
%16=(ENDBEFR=C',',FIXLEN=40),
%17=(ENDBEFR=C',',FIXLEN=19),
%18=(ENDBEFR=C',',FIXLEN=19),
%19=(ENDBEFR=C',',FIXLEN=10)),
BUILD=(1,4,%10,%11,%12,%13,
%14,SFF,TO=PD,LENGTH=10,
%15,SFF,TO=PD,LENGTH=10,
%16,
%17,SFF,TO=PD,LENGTH=10,
%18,SFF,TO=PD,LENGTH=10,
%19,SFF,TO=PD,LENGTH=5))

even if 1 , 2,3 field is of more than 1 character i am able to manage by defining its length , but not able to round off field2 (%19).

Re: Add value to outrec field

PostPosted: Wed Jun 16, 2010 2:05 am
by Frank Yaeger
What does field2 have to do with %19?

DFSORT only does integer arithmetic, so to round up a x.xxxx value, you would use UFF to remove the decimal point, then add 5, then divide by 10, and reformat the result as x.xxx

For example:

3.4567 -> (34567 + 5) / 10 = 3457 -> 3.457

Re: Add value to outrec field

PostPosted: Wed Jun 16, 2010 9:49 am
by richagoyal
Thanx Frank it worked !

%19 was for fields 3 not for field2 . Sorry it was typo !

Re: Add value to outrec field

PostPosted: Wed Jun 16, 2010 10:33 pm
by Frank Yaeger
Ok. Glad I could help.