IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Movement in PIC S Clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raj_mainframe08

New User


Joined: 11 Sep 2007
Posts: 65
Location: Gurgaon

PostPosted: Thu Dec 11, 2008 1:13 am
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Dec 11, 2008 1:31 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 11, 2008 1:51 am
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Dec 11, 2008 2:12 am
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Dec 11, 2008 2:19 am
Reply with quote

Craq: this and FTP issues ... a never ending cycle?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Dec 11, 2008 2:21 am
Reply with quote

And how to run only step 5 and 6 of a 10-step job. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
No new posts usage of CASE in WHERE clause DB2 10
No new posts Cobol redefines for Signed pictured c... COBOL Programming 4
Search our Forums:

Back to Top