View previous topic :: View next topic
|
Author |
Message |
raj_mainframe08
New User
Joined: 11 Sep 2007 Posts: 65 Location: Gurgaon
|
|
|
|
I have writte the following sample code i COBOL
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. TEST.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-DATE-S PIC S9(8) VALUE ZEROES.
01 WS-DATE-X PIC X(8) VALUE '20080101'.
01 WS-DATE-N PIC 9(8) VALUE ZEROES.
PROCEDURE DIVISION.
MOVE WS-DATE-X TO WS-DATE-N.
MOVE WS-DATE-N TO WS-DATE-S.
DISPLAY 'WS-DATE-X: ' WS-DATE-X.
DISPLAY 'WS-DATE-S: ' WS-DATE-S.
DISPLAY 'WS-DATE-N: ' WS-DATE-N.
STOP RUN.
|
And the Output in the SPOOL is as follow:
Code: |
WS-DATE-X: 20080101
WS-DATE-S: 2008010A
WS-DATE-N: 20080101
|
I want to know why WS-DATE-S is being displayed as 2008010A and not 20080101. Am i moving in a wrong manner. Please note that i want to keep the PIC Clause of WS-DATE-S as S9(8) only and i want to display it correctly. [/code] |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
It is displaying correctly, ws-date-s is a signed field when an unsigned value is moved to it a positive sign will be assumed. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The COBOL Language Reference states that a signed USAGE DISPLAY numeric field has the sign overlaid on the high order bits of the last byte of the field; a positive value is C and negative D. The character 'A' in the collating sequence is C1 which is interpreted as a 01 with a plus sign (C0) overlaid on it. You are not moving in a wrong manner; COBOL is behaving exactly as the manual documents.
Quote: |
Please note that i want to keep the PIC Clause of WS-DATE-S as S9(8) only and i want to display it correctly. |
You pays your money, you takes your pick -- keep the S on the PIC clause and you're going to see letters (or special symbols) for the last character of the displayed data, or leave off the S and see numbers in that character. Those are your choices -- nothing else is supported by COBOL. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Quote: |
keep the S on the PIC clause and you're going to see letters (or special symbols) for the last character of the displayed data, or leave off the S and see numbers in that character |
It seems to me this discussion occurs at least once a week. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Craq: this and FTP issues ... a never ending cycle? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
And how to run only step 5 and 6 of a 10-step job. . . |
|
Back to top |
|
|
|