Writing out multiple records to a subfile from a single record
George_DeWolf@midhosp.org
George_DeWolf@midhosp.org
Wed, 6 Jun 2001 12:15:26 -0400
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?