I need to find all active customers with certain type codes: CR RF SW WA. The customer could have all 4.
IF the customer has CR and RF and they are both inactive, I want this data.
IF the customer does not have CR or RF, and has either SW or WA or both, I want this data.
I hate posting my code because I know where I am at in the learning cycle, so it’s embarrassing, but here goes.
I was told to create the data structures, and I know there is an error because UTCSID ZONED(9);
UTLCID ZONED(9); were already defined.
**FREE
//************************************************** **************
dcl-f ut210ap disk(*ext) keyed; //customer location file
dcl-f ut220ap disk(*ext) keyed; //customer services file
dcl-f lmabrelf disk(*ext) keyed; //land file
dcl-f lm800ap disk (*ext) keyed; //generic codes file
dcl-f ut200ap disk (*ext) keyed; //customer master file
dcl-f rut4001ap disk(*ext) usage(*update:*output) keyed; //workfile
DCL-S SVC_CR CHAR(2);
DCL-S SVC_RF CHAR(2);
DCL-S CUST1 ZONED(9);
DCL-S CUST2 ZONED(9);
DCL-S CR_STATUS CHAR(1);
DCL-S RF_STATUS CHAR(1);
DCL-C CRCODE 'CR';
DCL-C RFCODE 'RF';
DCL-DS KEY800;
LMCDAP CHAR(2) INZ('UT');
LMCDTP CHAR(2) INZ('CP');
CODE9 CHAR(9);
END-DS;
DCL-DS KEYCR;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODECR CHAR(2) INZ('CR');
END-DS;
DCL-DS KEYRF;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODERF CHAR(2) INZ('RF');
END-DS;
DCL-DS KEYSW;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODESW CHAR(2) INZ('SW');
END-DS;
DCL-DS KEYWA;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODEWA CHAR(2) INZ('WA');
END-DS;
READ UT210AP;
DOW NOT %EOF(UT210AP);
//Active customers only
IF UTCLST = 'A';
//Commercial type codes
IF UTCSTP = 'AP' OR UTCSTP = 'B' OR UTCSTP = 'C'
OR UTCSTP = 'CT' OR UTCSTP = 'E' OR UTCSTP = 'F'
OR UTCSTP = 'G' OR UTCSTP = 'J';
CHAIN %KDS(KEYCR) UT220AP; //chained with CR constant
IF %FOUND(ut220ap);
SVC_CR = UTSVC;
CUST1 = UTCSID;
CR_STATUS = UTSSTS;
CLEAR SVC_RF;
CLEAR CUST2;
CLEAR RF_STATUS;
CHAIN %KDS(KEYRF) UT220AP; //chained with RF constant
IF %FOUND(ut220ap);
IF utsvc = 'RF';
SVC_RF = UTSVC;
CUST2 = UTCSID;
RF_STATUS = UTSSTS;
ENDIF;
CHAIN %KDS(KEYSW) UT220AP;
IF %FOUND(UT220AP);
CHAIN (UTCSID:UTLCID) RUT4001AP;
IF NOT %FOUND(RUT4001AP);
WRITE RUT4001AF;
ENDIF;
ENDIF;
//making sure both codes are for the same customer
IF CUST1 = CUST2 and CUST1 > 0 and
CR_STATUS = 'I' AND RF_STATUS = 'I';
//only want the data with Inactive on both codes
CHAIN UTLCID LMABRELF; //for address
IF %FOUND(LMABRELF);
CODE9 = UTCSTP;
CHAIN %kds(KEY800) LM800AP; //for Cust type Description
IF %FOUND(lm800ap);
CHAIN UTCSID UT200AP; //for customer name
IF %FOUND(ut200ap);
WRITE RUT4001AF;
CLEAR SVC_CR;
CLEAR SVC_RF;
CLEAR CUST1;
CLEAR CUST2;
CLEAR CR_STATUS;
CLEAR RF_STATUS;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
READ ut210ap;
ENDDO;
*INLR=*ON;
__________________________________________________ _________________
IF the customer has CR and RF and they are both inactive, I want this data.
IF the customer does not have CR or RF, and has either SW or WA or both, I want this data.
I hate posting my code because I know where I am at in the learning cycle, so it’s embarrassing, but here goes.
I was told to create the data structures, and I know there is an error because UTCSID ZONED(9);
UTLCID ZONED(9); were already defined.
**FREE
//************************************************** **************
dcl-f ut210ap disk(*ext) keyed; //customer location file
dcl-f ut220ap disk(*ext) keyed; //customer services file
dcl-f lmabrelf disk(*ext) keyed; //land file
dcl-f lm800ap disk (*ext) keyed; //generic codes file
dcl-f ut200ap disk (*ext) keyed; //customer master file
dcl-f rut4001ap disk(*ext) usage(*update:*output) keyed; //workfile
DCL-S SVC_CR CHAR(2);
DCL-S SVC_RF CHAR(2);
DCL-S CUST1 ZONED(9);
DCL-S CUST2 ZONED(9);
DCL-S CR_STATUS CHAR(1);
DCL-S RF_STATUS CHAR(1);
DCL-C CRCODE 'CR';
DCL-C RFCODE 'RF';
DCL-DS KEY800;
LMCDAP CHAR(2) INZ('UT');
LMCDTP CHAR(2) INZ('CP');
CODE9 CHAR(9);
END-DS;
DCL-DS KEYCR;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODECR CHAR(2) INZ('CR');
END-DS;
DCL-DS KEYRF;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODERF CHAR(2) INZ('RF');
END-DS;
DCL-DS KEYSW;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODESW CHAR(2) INZ('SW');
END-DS;
DCL-DS KEYWA;
UTCSID ZONED(9);
UTLCID ZONED(9);
CODEWA CHAR(2) INZ('WA');
END-DS;
READ UT210AP;
DOW NOT %EOF(UT210AP);
//Active customers only
IF UTCLST = 'A';
//Commercial type codes
IF UTCSTP = 'AP' OR UTCSTP = 'B' OR UTCSTP = 'C'
OR UTCSTP = 'CT' OR UTCSTP = 'E' OR UTCSTP = 'F'
OR UTCSTP = 'G' OR UTCSTP = 'J';
CHAIN %KDS(KEYCR) UT220AP; //chained with CR constant
IF %FOUND(ut220ap);
SVC_CR = UTSVC;
CUST1 = UTCSID;
CR_STATUS = UTSSTS;
CLEAR SVC_RF;
CLEAR CUST2;
CLEAR RF_STATUS;
CHAIN %KDS(KEYRF) UT220AP; //chained with RF constant
IF %FOUND(ut220ap);
IF utsvc = 'RF';
SVC_RF = UTSVC;
CUST2 = UTCSID;
RF_STATUS = UTSSTS;
ENDIF;
CHAIN %KDS(KEYSW) UT220AP;
IF %FOUND(UT220AP);
CHAIN (UTCSID:UTLCID) RUT4001AP;
IF NOT %FOUND(RUT4001AP);
WRITE RUT4001AF;
ENDIF;
ENDIF;
//making sure both codes are for the same customer
IF CUST1 = CUST2 and CUST1 > 0 and
CR_STATUS = 'I' AND RF_STATUS = 'I';
//only want the data with Inactive on both codes
CHAIN UTLCID LMABRELF; //for address
IF %FOUND(LMABRELF);
CODE9 = UTCSTP;
CHAIN %kds(KEY800) LM800AP; //for Cust type Description
IF %FOUND(lm800ap);
CHAIN UTCSID UT200AP; //for customer name
IF %FOUND(ut200ap);
WRITE RUT4001AF;
CLEAR SVC_CR;
CLEAR SVC_RF;
CLEAR CUST1;
CLEAR CUST2;
CLEAR CR_STATUS;
CLEAR RF_STATUS;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
ENDIF;
READ ut210ap;
ENDDO;
*INLR=*ON;
__________________________________________________ _________________
Comment