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
 

 

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: 10256
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: 2502
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 Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm


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