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...
jayind wrote: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