Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Movement in PIC S Clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Movement in PIC S Clause
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    Post subject:
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: 8003
Location: Bellevue, IA

PostPosted: Thu Dec 11, 2008 1:51 am    Post subject:
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    Post subject:
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: 8003
Location: Bellevue, IA

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

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

Site Director


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

PostPosted: Thu Dec 11, 2008 2:21 am    Post subject: Reply to: Movement in PIC S Clause
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts [SQL0029] INTO clause missing from em... HABBIE DB2 2 Fri Sep 04, 2015 3:54 pm
No new posts 3-D Table with nested DEPENDING ON Cl... VivekKhanna COBOL Programming 5 Sat Aug 08, 2015 11:18 pm
No new posts Problem in Movement of Data amitc23 COBOL Programming 3 Fri Apr 10, 2015 6:33 pm
No new posts when=group clause: question about the... tuxama DFSORT/ICETOOL 2 Thu Mar 26, 2015 12:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us