Solved

checking date value with CL

Posted on 2006-06-23
3
706 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 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

11 Experts available now in Live!

Get 1:1 Help Now