Page 1 of 1

9's complement date transformations

Posted: Mon Jan 24, 2005 9:54 am
by srikie
Hi,
Can any one throw some light on 9's complement date transformations, so as to what it is and why it is necessary and also can some one give me links to material which explains what level 88 and all those levels in the cobol copy book mean.
I am using Data Stage MVS.
Thanks
Srikie

Posted: Mon Jan 24, 2005 10:09 am
by Sainath.Srinivasan
Srikie,

In cobol, 88 levels are for validation purpose.

In other words, if you have something like,

01 FULL-RECORD.
05 MY-NUMBER PIC X.
88 VALID-CAP-CHAR 'A' THRU 'Z'.
88 VALID-LOW-CHAR 'a' THRU 'z'.
88 VALID-NUM-CHAR '0' THRU '9'.

Then in your Procedure division, you can check whether the MY-NUMBER has a valid char. by checking either as

IF (MY-NUMBER >= 'A' AND MY-NUMBER <= 'Z') OR
(MY-NUMBER >= 'a' AND MY-NUMBER <= 'z') OR
(MY-NUMBER >= '0' AND MY-NUMBER <= '9')
[Then]
PERFORM MY-PARA.

Alternatively, you can check as

IF VALID-CAP-CHAR OR VALID-LOW-CHAR OR VALID-NUM-CHAR
[Then]
PERFORM MY-PARA.

Answer to second question,

A COBOL copy book is like a library to dll. It is a bit of code that you can include (like an #include in c/c++) to bring the code in that page into your program. It is generally used for your DATA DIVISION file section or PROCEDURE DIVISION logic that must be common.

Posted: Mon Jan 24, 2005 10:20 am
by Sainath.Srinivasan
By-the-way, 9's complement is the '9s filled fully in the number column' - 'current value in the column'.

So, if you have a field defined as PIC 9(4) and pass value '1234', your 9's complement for it will be
9999 -
1234
------
8764 --> 9's complement
------

Posted: Mon Jan 24, 2005 10:52 am
by srikie
Well thanks for very informative response but can you also tell me why do they use the 9's complement version for the date in mainframes and also what does '8764' mean i mean does that mean 87 year and 64 something in this example. Sorry to bother you with such basic questions but I am a rookie so.........