COGNOiSe.com - The IBM Cognos Community

UNICOM Products => UNICOM PowerHouse => Topic started by: CHUCK_LOWE on 26 Jul 2005 12:59:53 PM

Title: validate a field contains date values
Post by: CHUCK_LOWE on 26 Jul 2005 12:59:53 PM
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.
Title: Re: validate a field contains date values
Post by: MFGF on 26 Jul 2005 02:16:46 PM
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.
Title: Re: validate a field contains date values
Post by: CHUCK_LOWE on 16 Aug 2005 10:05:20 AM
Thanks, I will try it.
Title: Re: validate a field contains date values
Post by: Blue on 01 Sep 2005 05:05:06 PM
How exactly do you want QTP to behave if a value read in is not a valid date?
Title: Re: validate a field contains date values
Post by: jeffh on 06 Oct 2005 08:37:58 AM
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.