Writing out multiple records to a subfile from a single recor d

Pickering, John (NORBORD) PICKERIJ@norbord.com
Wed, 6 Jun 2001 12:45:15 -0400


If you use Qtp you can write multiple records easily. How about something
like the following ...

>access {dataset}

>define d_error_1 char*1 = "Y" if {error 1}
>define d_error_2 char*1 = "Y" if {error 2}
>define as many more as you need

>subfile errors if d_error_1 = "Y" include {whatever}
>subfile errors alias error_2 append if d_error_2 = "Y" &
>  include {same whatever}
>subfile {as many as there are errors}

Regards,
JWP

> -----Original Message-----
> From:	George_DeWolf@midhosp.org [SMTP:George_DeWolf@midhosp.org]
> Sent:	Wednesday, June 06, 2001 12:15 PM
> To:	powerh-l@lists.swau.edu
> Subject:	Writing out multiple records to a subfile from a single
> record
> 
> I am looking to generate multiple records from a single record in a
> subfile.
> Here is a simplified version of my program:
> 
> ACC {dataset}
> 
> DEF ERR-COND1 CHAR*1 = 'Y' IF {condition true}
> DEF ERR-COND2 CHAR*1 = 'Y' IF {condition true}
> DEF ERR-COND3 CHAR*1 = 'Y' IF {condition true}
> DEF ERR-COND4 CHAR*1 = 'Y' IF {condition true}
> DEF ERR-COND5 CHAR*1 = 'Y' IF {condition true}
> 
> Each one of these fields represent an error condition found when reading a
> single record for an account from the {dataset}.  What I would like to
> produce is a subfile (don't care if I use Quiz or QTP) which contains the
> account number and an error-code.  For example, if I read the record for
> account number 1234 from my dataset and find that the error condition
> flags
> 1, 3 and 5 are set to "Y", I would like my subfile to contain the
> following
> three records:
> 
> Acct #: 1234 Err Cd: 1
> Acct #: 1234 Err Cd: 3
> Acct #: 1234 Err Cd: 5
> 
> I could link from a one-record-per-account subfile (with one field for
> each
> error condition) to an indexed subfile which contains one record for each
> potential error condition and only write records when the count from the
> subfile equals the error condition number.  For example,
> 
> ACC {subfile} & 
>   LINK ("X") TO LINK-FLD OF *LINKSUB
> 
> DEF ERROR-CODE NUM*3 = KOUNT OF LINKSUB
> 
> SEL IF ERR-COND1 = 'Y' AND KOUNT = 1 OR & 
>        ERR-COND2 = 'Y' AND KOUNT = 2 OR & 
>        ERR-COND3 = 'Y' AND KOUNT = 3 OR & 
>        ERR-COND4 = 'Y' AND KOUNT = 4 OR & 
>        ERR-COND4 = 'Y' AND KOUNT = 5
> 
> REP SUM ACCT-NBR ERROR-CODE
> 
> Is there a better way?
> 
> 
>