Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

checking date value with CL

Posted on 2006-06-23
3
Medium Priority
?
734 Views
Last Modified: 2012-06-21
  I have a CL program that accepts a character value as a date, '06/06/2006'.  Is there a way to check this value prior to using it in the DSPJRN command?  If I pass a bad date value I get a CPF0001 message when the command tries to execute, and I would like to trap a bad value prior to that.
   
   I tried using the CVTDAT command, hoping it would fail, but it didn't.  Any help appreciated.
0
Comment
Question by:dhenderson12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Expert Comment

by:tliotta
ID: 16973650
dhenderson12:

I'm not sure what you meant by "...hoping it would fail, but it didn't". If you supplied an invalid date, it should fail with CPF0555. If it didn't fail, then you should call IBM and get your CVTDAT command fixed.

However, it's probable that it simply wasn't executed quite right. Please supply a bit of code showing how you're using CVTDAT. We can probably help pinpoint the problem. We'll need any related variable DCLs and info on any MONMSG commands that might be associated.

Tom
0
 
LVL 13

Expert Comment

by:_b_h
ID: 16973682
dh:

That CPF0001 message is not the actual error; it is a generic 'Error found on DSPJRN command'.
Can you look at the job log and post the message(s) that occur before that. Are you getting something like this? CPD0082 "Value '06/06/2006' for parameter FROMTIME not a valid date"

Barry
0
 
LVL 13

Accepted Solution

by:
_b_h earned 1000 total points
ID: 16973787
Just for reference, here is some basic CL to check a date. Note that you can change the input and output date format on the Convert Date (CVTDAT) command to suit your needs; if you do, then the variable sizes may need to be changed as well.

PGM ( &DATEIN )                                                        
DCL &DATEIN     *CHAR   10                                              
DCL &DATEOUT    *CHAR   10                                              
             SNDPGMMSG  MSG('Input date: ' || &DATEIN)                  
             CVTDAT     DATE(&DATEIN) TOVAR(&DATEOUT) FROMFMT(*MDYY) +  
                          TOFMT(*MDYY) TOSEP('/')                      
             MONMSG (CPF0555) EXEC(DO)                                  
             SNDPGMMSG  MSG(&DATEIN *TCAT ' not valid')                
             GOTO ENDPGM                                                
             ENDDO                                                      
             SNDPGMMSG  MSG('Output date: ' || &DATEOUT)                
ENDPGM:                                                                
             ENDPGM                        

If the program is called CHKDATE in library BH, sample output would look like:
> call bh/chkdate '06/31/2006'
  Input date: 06/31/2006      
  06/31/2006 not valid        
> call bh/chkdate '06/06/2006'
  Input date: 06/06/2006      
  Output date: 06/06/2006      

If you have any questions, post back!
Barry                            
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question