Page 1 of 1

EVALUATE logic

PostPosted: Tue Feb 03, 2015 6:40 pm
by vinu78
Hi All,

I would like to convert the 4 digit Year to 2 digit ID as per the below mentioned rules

4 digit year           2 digit ID
2010 - 2019            A0 - A9
2020 - 2029            B0 - B9
2030 - 2039            C0 - C9
2040 - 2049            D0 - D9
2050 - 2059            E0 - E9


i.e., when year of construction comes as 2012, the 2 digit ID card should be A2. When 4 digit year comes as 2042, the 2 digit ID card should be D2.
I came with EVALUATE logic but it is coming too large. Can anyone please throw some COBOL logic to convert this 4 digit year to 2 digit ID card.
Or declaring all the values in internal table in COBOL module is the only solution.

Please help.

Thanks
Vinu

Re: EVALUATE logic

PostPosted: Tue Feb 03, 2015 6:54 pm
by prino
You should not be using 2-digit years, encoded or not, under any circumstances!

Or is your the outsourcing company you're working for preparing for another bonanza, when the above scheme fails?

Re: EVALUATE logic

PostPosted: Tue Feb 03, 2015 6:57 pm
by vinu78
Thanks Prino for the reply. The 2 digit ID is not the year, instead it is another ID number that is further used in our downstream process.

Rgds
Vinu

Re: EVALUATE logic

PostPosted: Tue Feb 03, 2015 9:49 pm
by steve-myers
In my opinion, Prino is correct. Compression of a year, to 2 characters is going to come back and bite your a** sooner or later. If this is a directive from a customer, this is a case where you should go back to your customer and start muttering Y2K again and again.

I'm seeing 2 digit years more and more. And if you think Y2K was bad, Y21K is going to be much worse! 2000, at least, was a leap year. 2100 is not.

Re: EVALUATE logic

PostPosted: Tue Feb 03, 2015 10:30 pm
by BillyBoyo
01  year-field.
    05  FILLER PIC X.
    05  year-subscript PIC 99.
    05  year-digit PIC X.


Use year-subscript as a subscript to a table of letters, A-Z.

01  ID-field.
    05  ID-alphabet-year PIC X.
    05  ID-digit PIC X.

MOVE alphabet-letter ( year-subscript ) TO ID-alphabet-year
MOVE year-digit to ID-digit


Will work for 269 years from 2010. Ensure not used for years less than 2010.

Re: EVALUATE logic

PostPosted: Wed Feb 04, 2015 12:15 am
by Mickeydusaor
Bill I will come back in 268 years and ask you.

Re: EVALUATE logic

PostPosted: Wed Feb 04, 2015 12:59 am
by prino
vinu78 wrote:Thanks Prino for the reply. The 2 digit ID is not the year, instead it is another ID number that is further used in our downstream process.

If it's just an ID, why the flipping 'ell does it come from the year? You're talking "sranje"!

Re: EVALUATE logic

PostPosted: Wed Feb 04, 2015 5:04 pm
by vinu78
Thanks for the info. I may have to go back to the customer and will convey this issue.
Once again thanks.

Rgds
Vinu