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.
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.
Thanks, I will try it.
How exactly do you want QTP to behave if a value read in is not a valid date?
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.