Solved

checking date value with CL

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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
c# call as400 program with integer parameters 5 592
rpg d specs 5 118
IBMi message: Cannot automatically select virtual device 2 225
Pointer not set for location referenced. 12 178
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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