EVALUATE logic



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

EVALUATE logic

Postby vinu78 » Tue Feb 03, 2015 6:40 pm

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
vinu78
 
Posts: 29
Joined: Sat Sep 27, 2008 4:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: EVALUATE logic

Postby prino » Tue Feb 03, 2015 6:54 pm

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?
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: EVALUATE logic

Postby vinu78 » Tue Feb 03, 2015 6:57 pm

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
vinu78
 
Posts: 29
Joined: Sat Sep 27, 2008 4:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: EVALUATE logic

Postby steve-myers » Tue Feb 03, 2015 9:49 pm

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.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: EVALUATE logic

Postby BillyBoyo » Tue Feb 03, 2015 10:30 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: EVALUATE logic

Postby Mickeydusaor » Wed Feb 04, 2015 12:15 am

Bill I will come back in 268 years and ask you.
User avatar
Mickeydusaor
 
Posts: 29
Joined: Fri Feb 24, 2012 11:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: EVALUATE logic

Postby prino » Wed Feb 04, 2015 12:59 am

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"!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

Re: EVALUATE logic

Postby vinu78 » Wed Feb 04, 2015 5:04 pm

Thanks for the info. I may have to go back to the customer and will convey this issue.
Once again thanks.

Rgds
Vinu
vinu78
 
Posts: 29
Joined: Sat Sep 27, 2008 4:47 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post