Solved

checking date value with CL

Posted on 2006-06-23
3
709 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
  • 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 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now