Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COMP-3 Date field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Jeya Raj

New User


Joined: 14 Jan 2007
Posts: 33
Location: USA

PostPosted: Tue Sep 22, 2009 11:31 pm    Post subject: COMP-3 Date field
Reply with quote

Hi,

I need to move x(10) format date(CCYY-MM-DD) to comp-3 date field like

table-date pic x(10) CCYY-MM-DD
copy-book-date PIC S9(07) COMP-3.


I moved the table-date to temp-date which is 9(8) (to remove the - from the table-date) and then moved the temp-date to copy-book-date.

MOVE table-date TO temp-date.

MOVE temp-date TO copy-book-date.

If the table-date is 2009-09-21 and after the move the temp-date is 20090921 and the copy-book-date is as 0090921C. Please let me know how can i get 20090921 in the copy-book-date?. Do i need to store as 1090921 in the copy-book-date?. if the first digit is 1 then the century means 20????


Thank you.
Back to top
View user's profile Send private message

Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Sep 22, 2009 11:48 pm    Post subject:
Reply with quote

Since copy-book-date is defined as internal decimal, the rightmost half-byte will always be reserved for a sign (+, -, or unsigned; that is C, D, or F). If you want an unsigned result, define it as a display, unsigned numeric field, PIC 9(8). See Language Reference manual for details.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10396
Location: italy

PostPosted: Tue Sep 22, 2009 11:49 pm    Post subject: Reply to: COMP-3 Date field
Reply with quote

S9(07) You are telling that the field will contain 7 digits ....
how do You expect it to be able to contain 8 ...

the best thing would be to review and understand the application design

if You really need to store a date in 7 digits the forum is not really a place to ask,
somebody in Your organization must have documented the issue and the conventions to be used
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Wed Sep 23, 2009 12:04 am    Post subject: Reply to: COMP-3 Date field
Reply with quote

Would converting this Gregorian format to Julian format (CCYYDDD) be an alternative?

Julian format would fit into 4-Bytes packed-decimal, without high-order truncation.

You would need 5-bytes packed-decimal for the full CCYYMMDD value and have a high-order 4-bit X'0'.

A binary-fullword is 4-bytes (PIC S9(09) COMP) and your CCYYMMDD Gregorian formatted-date will fit, regardless of the TRUNC option, but it will be stored in HEX. For example, decimal 20090922 would be stored in the fullword as X'0132902A'.

What version/release of COBOL are you using?

Bill
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 COMP Variables Mismatch gayu7 COBOL Programming 5 Wed Dec 20, 2017 5:06 pm
No new posts Moving a COMP-3 Variable to a Numeric... ajayachander COBOL Programming 2 Thu Dec 14, 2017 5:46 pm
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts CONDITIONAL USING COMP-2 WITH PROBLEMS. JOSUEGENTIL COBOL Programming 7 Wed Nov 08, 2017 11:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us