If you change the WS-START-DATE field to PIC 9(09) COMP, recompile and
rerun you will see the result is 53540. After passing the 32 bit
WS-START-DATE to the intrinsics the end result comes out the
same -- shows the current date correctly.
Although the intrinsics manual declares the CALENDAR date parm as a
16 bit signed value, the intrinsic really doesn't care if you make it
a 32 bit signed value. The intermediate results are different (-11996 or
53540) but the output from the ALMANAC intrinsic yields identical correct
dates...
Yes, I've never had any need to look at the intermediate results before.
I've used FLABELINFO and FFILEINFO many times to convert these dates
(create, mod, access, restore dates) into meaningful YYYYMMDD dates
without any problems.
Brian.
On Mon, 18 Oct 2004 17:12:20 -0700, Emerson, Tom
<[log in to unmask]> wrote:
>> -----Original Message-----
>> Behalf Of Brian Donaldson
>>
>> I have been using CALENDAR and ALMANAC intrinsics in Cobol programs
>> I wrote a quickie program to satisfy my own curiosity
>> WORKING-STORAGE SECTION.
>> 01 WS-YEAR-NUM PIC S9(04) COMP VALUE ZEROES.
>> 01 WS-MONTH-NUM PIC S9(04) COMP VALUE ZEROES.
>> 01 WS-START-DATE PIC 9(04) COMP VALUE ZEROES.
>>
>> CALL INTRINSIC "CALENDAR" GIVING WS-START-DATE.
>> CALL INTRINSIC "ALMANAC" USING WS-START-DATE,
>[...]
>> YEAR IS=>+0104<
>> MONTH IS=>+0010<
>> Add 1900 to the year and you get 2004. Fine.
>> The month is 10 (October). Fine.
>[...]
>> This works fine.....
>>
>> So what's the problem........??
>
>I suspect the "problem" is that you didn't make the mistake of looking
directly at the intermediate result held in the variable "WS-START-DATE" --
as others have mentioned, the ACTUAL value this contains is -11996, which
COBOL will mangle should you attempt to display it (truncating to 1996, and
possibly dropping the sign bit in the process)
>
>Sure enough, adding a display of WS-START-DATE between the two calls
results in this output:
>
>988/COREDEV/TEMPTE:cob85xlg.pub.sys junk1
>PAGE 0001 COBOL II/iX HP31500A.04.20 [85] Copyright Hewlett-Packard CO.
1987
>[snip...]
> 00029 te041018 003000 CALL INTRINSIC "CALENDAR" GIVING WS-START-DATE.
> 00035 te041018 003010
> 00036 te041018 003020 display "Intermediate result: " WS-START-DATE
> 00037 te041018 003030
> 00039 te041018 003100 CALL INTRINSIC "ALMANAC" USING WS-START-DATE,
>[snap...]
>END OF LINK
>
>Intermediate result: 1996
>YEAR IS=>+0104<
>MONTH IS=>+0010<
>DAY IS=>+0018<
>WEEKDAY IS=>+0002<
>
>END OF PROGRAM
>
>* To join/leave the list, search archives, change list settings, *
>* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|