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
 

 

converting Gregorian date to Integer of date - Error

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

New User


Joined: 08 Apr 2005
Posts: 23
Location: india

PostPosted: Fri Apr 24, 2009 11:22 am    Post subject: converting Gregorian date to Integer of date - Error
Reply with quote

Hi

I am trying to convert a Gregorian date to integer date using this statement.

Code:
COMPUTE WS-INTEGER-DT = FUNCTION INTEGER-OF-DATE(WS-GREGORIAN-DATE).

The datatypes are
Code:
WS-GREGORIAN-DATE  PIC 9(08)    **its in YYYYMMDD format
WS-INTEGER-DT           PIC S9(09)  usage comp

I am getting the compilation error
Function argument "WS-GREGORIAN-DATE" did not have the correct type for function "INTEGER-OF-DATE". The statement was discarded.

Please advice.

Thanks

Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj
Back to top
View user's profile Send private message

Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Apr 24, 2009 12:01 pm    Post subject:
Reply with quote

Hi,

Check this link on INTEGER-OF-DATE.
Back to top
View user's profile Send private message
hernikiten

New User


Joined: 08 Apr 2005
Posts: 23
Location: india

PostPosted: Fri Apr 24, 2009 5:54 pm    Post subject: Reply to: converting Gregorian date to Integer of date - Err
Reply with quote

I am conforming to the same data type. Still getting the same error.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Apr 24, 2009 6:08 pm    Post subject:
Reply with quote

The COBOL Language Reference says
Quote:
7.1.18 INTEGER-OF-DATE

The INTEGER-OF-DATE function converts a date in the Gregorian calendar from standard date form (YYYYMMDD) to integer date form.

The function type is integer.

The function result is a seven-digit integer with a range from 1 to 3,067,671.
Now just how exactly do you think a 7-digit integer (which implies USAGE DISPLAY) will fit into a COMP field? Your problem isn't the argument doesn't conform -- your output variable doesn't conform.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Fri Apr 24, 2009 6:37 pm    Post subject:
Reply with quote

Okay, now that I've had a chance to get on the mainframe and test, I find it takes the COMP field just fine. Another day, another thing learned.
Code:
           05  WS-GREGORIAN-DATE       PIC 9(08) VALUE 20090424.
           05  WS-INTEGER-DT           PIC S9(09)  USAGE COMP .
           05  WS-INT-DT               PIC S9(09).
      /
       PROCEDURE DIVISION.
       S1000-MAIN       SECTION.
           COMPUTE WS-INTEGER-DT = FUNCTION
                   INTEGER-OF-DATE (WS-GREGORIAN-DATE) .
           COMPUTE WS-INT-DT     = FUNCTION
                   INTEGER-OF-DATE (WS-GREGORIAN-DATE) .
           DISPLAY 'WS-INTEGER-DT = ' WS-INTEGER-DT.
           DISPLAY 'WS-INT-DT     = ' WS-INT-DT.
produces
Code:
 WS-INTEGER-DT = 0000149133
 WS-INT-DT     = 00014913C
so if you're getting a compile error you are doing something wrong in your program. What does the full declaration for the variables look like (01 right on down)?
Back to top
View user's profile Send private message
hernikiten

New User


Joined: 08 Apr 2005
Posts: 23
Location: india

PostPosted: Tue Apr 28, 2009 5:46 am    Post subject: Reply to: converting Gregorian date to Integer of date - Err
Reply with quote

It was happening due to sublevels in gregorian date.
01 Gregorian
02 greg-yyyy pic 9(04)
02 greg-mm pic 9(02)
02 greg-dd pic 9(02)

It must be an elementary item. To use a group variable ON SIZE ERROR clause is required.
Sorry didn't mention it earlier.n
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8117
Location: East Dubuque, Illinois, USA

PostPosted: Tue Apr 28, 2009 8:07 am    Post subject:
Reply with quote

Well, I'm glad you got it resolved.

Hopefully, this is a lesson -- do not ever post your interpretation of what's going on -- if you'd posted the actual variables involved instead of saying WS-GREGORIAN-DATE was an elementary item, we probably could have solved it much quicker. Definitely with less confusion!
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 How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm


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