Solved

checking date value with CL

Posted on 2006-06-23
3
723 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
rpg d specs 5 131
vmware on IBM X3960 with HA - Idiots Guide 8 129
IBM 840 flash storage Array 3 192
NW0002A in PSCOMMON doesn't exist 2 23
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
We asked our MSP customer base what their favorite tools were and how they help them serve clients. We focused our questions on favorite tools in the following categories: >PSA tools >RMM tools >Alert management tools >Communication tools and Mo…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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