getting century codes using cobol



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

getting century codes using cobol

Postby prabhu_s » Fri Aug 01, 2008 10:40 am

Can you suggest me a logic to get century codes based on years.
For eg:
if it is 1989,

century code '19' should be moved.

if the year is 2024,

century code '20' should be moved...
prabhu_s
 
Posts: 3
Joined: Fri Aug 01, 2008 10:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: getting century codes using cobol

 

Re: getting century codes using cobol

Postby jayind » Fri Aug 01, 2008 11:40 am

Hi Prabhu,

You need to give more information on which one needs to be moved where? Your question is incomplete..
My understanding from your question is, You have year '89' in one field which you want to add century to make it as 1989. If this is what you are looking then after the Y2K, every system has one subroutine written which will be called using the year part that returns century also. Search for CCYY in your cobol programs library you may find the routine.. If not check with your peers..there is a cutoff year before which it would be treated the century as '20' and after which the century would be treated as '19'. For example, if the cutoff year in your system is '40' then year <=40 for which the century would be treated as 20 and if the year >40 then the century would be treated as 19. in your example if the year is 89 which is > 40 and hence century 19 would be added and it will become 1989 similary for year 24 since it is < 40 the century 20 would be added and hence it will become 2024. This logic already exists and your need to pass year as parameter which will return the century part.
Hope you got the logic now.

If you are looking to seperate year and century which is stored in a variable then
01 VAR1 PIC X(4) VALUE '1989'.
01 VAR2 REDEFINES VAR1.
05 VAR2-CC PIC X(2).
05 VAR2-YY PIC X(2).
Now you have CC in first variable and YY in the second variable..
Since your question is incomplete I have answered solutions to both my assumptions
Hope this info helps..

Regards,
jayind
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: getting century codes using cobol

Postby prabhu_s » Fri Aug 01, 2008 12:44 pm

the file has a year in format of ddmmyy and i have to convert them to ddmmyyyy.
i.e. for example if the date is 080708 it has to be 08072008 if it is for year 2008.
and if the date is 080798 and the year is 2098 it has to be 08072098.

Let me know if it is not clear...
prabhu_s
 
Posts: 3
Joined: Fri Aug 01, 2008 10:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: getting century codes using cobol

Postby jayind » Fri Aug 01, 2008 12:56 pm

Prabhu,

I have already provided you the solution.. you need to find the date routine that your system or your peer developers are using... if it is for your testing purpose and not for production, you can use the logic that I mentioned <=40 or >40.

Regards,
jayind
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: getting century codes using cobol

Postby prabhu_s » Fri Aug 01, 2008 1:19 pm

ok thanks for the help.....
prabhu_s
 
Posts: 3
Joined: Fri Aug 01, 2008 10:25 am
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post