If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

validate a field contains date values

Started by CHUCK_LOWE, 26 Jul 2005 12:59:53 PM

Previous topic - Next topic

CHUCK_LOWE

I need to verify that a field I define contains valid date patterns.
In QTP

Request PARSE-FILE

ACC INFILE
;Temps 
DEF PROC-DATE CHAR*08 = INREC[46:8]

How do I verify that the data contained in PROC-DATE is a valid date.  Prefably in the YYYYMMDD format.  I don't want to DEFine a numeric as I don't want the QTP process to abort.

MFGF

Hi CHUCK_LOWE,

I would have suggested the easiest option here would have been to use an EDIT statement to validate that PROC-DATE contains a date, something along the lines of EDIT PROC-DATE DATE but you're not allowed to use an EDIT statement like this on defines or temporaries that are not populated by a PARM option.

Is it possible to define a dictionary structure for this record, where each field is described by an ELEMENT statement?Ã,  If so, and your ELEMENT was defined as (say) ELEMENT PROC-DATE CHARACTER 8, you could then do the following:

QTP
> Request PARSE-FILE ON EDIT ERRORS CONTINUE
>
> ACCESS INFILE
>
> EDIT PROC-DATE DATE

If it's not possible to create a record structure in the dictionary, the next best thing would be to create a subfile in QUIZ which separates out the data item for PROC-DATE.

QUIZ
> ACCESS INFILE
> DEFINE START_BIT CHAR*45 = INREC[1:45]
> DEFINE PROC-DATE CHAR*8 = INREC[46:8]
> REPORT SUMMARY START-BIT PROC-DATE
> SET SUBFILE NAME INFILE2 KEEP
> GO

Once you have this subfile, your QTP code might look something like this:

QTP
> REQUEST PARSE-FILE ON EDIT ERRORS REPORT
>
> ACCESS *INFILE2
>
> EDIT PROC-DATE DATE
etc

Hope this helps! :-)

Best regards,

MF.
Meep!

CHUCK_LOWE


Blue

How exactly do you want QTP to behave if a value read in is not a valid date?
Robert Edis
Principal
Robert Edis Consulting
Rotorua, New Zealand

jeffh

You could try defining a temp date field, ncon your field, if the result is 0 then not a valid date. Sorry do not have access to PH to test this.