Function SET176B
********** COMMENT(=======================================================);
********** COMMENT(Copyright .....: (C) = LANSA SET Team = , 19);
********** COMMENT(92);
********** COMMENT(Process .......: SET_176);
********** COMMENT(Function ......: SET176B);
********** COMMENT(Type ..........: SETORD File Level Trigger);
********** COMMENT(Created by ....: SETUSER);
********** COMMENT(Created on ....: 24/05/00 at 16:25:57);
********** COMMENT(Description ...: Trigger on File SETORD);
********** COMMENT(=======================================================);
FUNCTION OPTIONS(*DIRECT *NOMESSAGES *LIGHTUSAGE) RCV_LIST(#TRIG_LIST ) TRIGGER(*FILE SETORD);
********** COMMENT(=======================================================);
********** COMMENT(Working fields, lists and groups);
********** COMMENT(=======================================================);
********** COMMENT(At entry #TRIG_LIST will contain 0,1 or 2);
********** COMMENT(entries representing current and previous);
********** COMMENT(record images of file SETORD. Refer to the);
********** COMMENT(Technical Guide for details and examples.);
********** COMMENT(Do NOT define any fields in this list. They);
********** COMMENT(are automatically included by the compiler.);
DEF_LIST NAME(#TRIG_LIST) TYPE(*WORKING) ENTRYS(0000002);
********** COMMENT(Character fields to allow for concatenation.);
DEFINE FIELD(#CHR_OAMT) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#DIFF) REFFLD(#S_176OAMT);
DEFINE FIELD(#CHR_ORNO) TYPE(*CHAR) LENGTH(007);
DEFINE FIELD(#CHR_CRED) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#CHR_LIMI) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#CHR_DIFF) TYPE(*CHAR) LENGTH(009);
********** COMMENT(=======================================================);
********** COMMENT(Function Mainline : SET176B);
********** COMMENT(=======================================================);
********** COMMENT(Assume a "good" return initially);
CHANGE FIELD(#TRIG_RETC) TO(OK);
********** COMMENT();
CASE OF_FIELD(#TRIG_OPER);
********** COMMENT(Handle an after insert event);
WHEN VALUE_IS('= AFTINS');
EXECUTE SUBROUTINE(SEND_EMAIL);
********** COMMENT(Handle an event not catered for);
OTHERWISE;
ABORT MSGTXT('File SETORD trigger function invalidly invoked/ used.');
ENDCASE;
********** COMMENT(Return control to the invoker);
RETURN;
********** COMMENT();
SUBROUTINE NAME(SEND_EMAIL);
********** COMMENT();
GET_ENTRY NUMBER(1) FROM_LIST(#TRIG_LIST);
FETCH FIELDS(*ALL) FROM_FILE(SETCUS) WITH_KEY(#S_176CCOD);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176CRED) TO_GET(#CHR_CRED);
SUBSTRING FIELD(#S_176ORNO 1) INTO_FIELD(#CHR_ORNO 1);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176LIMI) TO_GET(#CHR_LIMI);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176OAMT) TO_GET(#CHR_OAMT);
CHANGE FIELD(#DIFF) TO('#s_176cred - #s_176limi');
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#DIFF) TO_GET(#CHR_DIFF);
********** COMMENT();
USE BUILTIN(MAIL_START);
********** COMMENT();
CHANGE FIELD(#S_EMORG) TO('[email protected]');
USE BUILTIN(MAIL_ADD_ORIGINATOR) WITH_ARGS(#S_EMORG #S_EMORG);
********** COMMENT();
USE BUILTIN(MAIL_ADD_RECIPIENT) WITH_ARGS(TO *S_176CREDITMGREMAIL *S_176CREDITMGREMAIL);
********** COMMENT();
USE BUILTIN(BCONCAT) WITH_ARGS(#S_176CNAM 'EXCEEDED CREDIT LIMIT') TO_GET(#S_EMSBJ);
USE BUILTIN(MAIL_SET_SUBJECT) WITH_ARGS(#S_EMSBJ);
********** COMMENT();
EXECUTE SUBROUTINE(ADD_TEXT);
********** COMMENT();
USE BUILTIN(MAIL_SET_OPTION) WITH_ARGS(IMPORTANCE HIGH);
********** COMMENT();
USE BUILTIN(MAIL_SEND);
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(ADD_TEXT);
********** COMMENT();
********** COMMENT();
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS('HI,');
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
USE BUILTIN(BCONCAT) WITH_ARGS(#S_176CNAM 'has placed an order (number' #CHR_ORNO ') that totals' #CHR_OAMT) TO_GET(#S_EMLINE);
USE BUILTIN(BCONCAT) WITH_ARGS(#S_EMLINE 'dollars.') TO_GET(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
USE BUILTIN(BCONCAT) WITH_ARGS('This has exceeded their credit limit of' #CHR_LIMI 'dollars by' #CHR_DIFF 'dollars.') TO_GET(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
********** COMMENT();
EXECUTE SUBROUTINE(PARTIA_URL);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(APPROVED APPROVE);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(HELD HOLD);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(REVIEW REVIEW);
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(COMPLE_URL) PARMS((#S_176STAT *RECEIVED) (#STAT_WORD *RECEIVED));
********** COMMENT();
DEFINE FIELD(#STAT_TEXT) REFFLD(#S_EMLINE);
DEFINE FIELD(#STAT_WORD) REFFLD(#S_176STAT);
********** COMMENT();
CASE OF_FIELD(#S_176STAT);
WHEN VALUE_IS('= APPROVED');
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'this order for shipment, click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
WHEN VALUE_IS('= HELD');
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'this order until further checks are made' 'click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
OTHERWISE;
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'the details of this order click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
ENDCASE;
USE BUILTIN(TCONCAT) WITH_ARGS(#STAT_TEXT #S_176STAT) TO_GET(#STAT_TEXT);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#STAT_TEXT);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(PARTIA_URL);
********** COMMENT();
USE BUILTIN(TCONCAT) WITH_ARGS(*S_URLPORT *S_FIXEDURLPART 'SET_176+SET176D+' *PARTITION '+') TO_GET(#S_EMLINE);
********** COMMENT();
IF COND('*language *ne *blank');
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE *LANGUAGE '+funcparms+chr_orno%28A0070%29:' #CHR_ORNO '+s_176ccod%28A0050%29:') TO_GET(#S_EMLINE);
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE #S_176CCOD) TO_GET(#S_EMLINE);
ELSE;
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE 'funcparms+chr_orno%28A0070%29:' #CHR_ORNO '+s_176ccod%28A0050%29:' #S_176CCOD) TO_GET(#S_EMLINE);
ENDIF;
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE '+S_176STAT%28A0100%29:') TO_GET(#S_EMLINE);
********** COMMENT();
ENDROUTINE;
********** COMMENT(=======================================================);
********** COMMENT(Copyright .....: (C) = LANSA SET Team = , 19);
********** COMMENT(92);
********** COMMENT(Process .......: SET_176);
********** COMMENT(Function ......: SET176B);
********** COMMENT(Type ..........: SETORD File Level Trigger);
********** COMMENT(Created by ....: SETUSER);
********** COMMENT(Created on ....: 24/05/00 at 16:25:57);
********** COMMENT(Description ...: Trigger on File SETORD);
********** COMMENT(=======================================================);
FUNCTION OPTIONS(*DIRECT *NOMESSAGES *LIGHTUSAGE) RCV_LIST(#TRIG_LIST ) TRIGGER(*FILE SETORD);
********** COMMENT(=======================================================);
********** COMMENT(Working fields, lists and groups);
********** COMMENT(=======================================================);
********** COMMENT(At entry #TRIG_LIST will contain 0,1 or 2);
********** COMMENT(entries representing current and previous);
********** COMMENT(record images of file SETORD. Refer to the);
********** COMMENT(Technical Guide for details and examples.);
********** COMMENT(Do NOT define any fields in this list. They);
********** COMMENT(are automatically included by the compiler.);
DEF_LIST NAME(#TRIG_LIST) TYPE(*WORKING) ENTRYS(0000002);
********** COMMENT(Character fields to allow for concatenation.);
DEFINE FIELD(#CHR_OAMT) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#DIFF) REFFLD(#S_176OAMT);
DEFINE FIELD(#CHR_ORNO) TYPE(*CHAR) LENGTH(007);
DEFINE FIELD(#CHR_CRED) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#CHR_LIMI) TYPE(*CHAR) LENGTH(009);
DEFINE FIELD(#CHR_DIFF) TYPE(*CHAR) LENGTH(009);
********** COMMENT(=======================================================);
********** COMMENT(Function Mainline : SET176B);
********** COMMENT(=======================================================);
********** COMMENT(Assume a "good" return initially);
CHANGE FIELD(#TRIG_RETC) TO(OK);
********** COMMENT();
CASE OF_FIELD(#TRIG_OPER);
********** COMMENT(Handle an after insert event);
WHEN VALUE_IS('= AFTINS');
EXECUTE SUBROUTINE(SEND_EMAIL);
********** COMMENT(Handle an event not catered for);
OTHERWISE;
ABORT MSGTXT('File SETORD trigger function invalidly invoked/ used.');
ENDCASE;
********** COMMENT(Return control to the invoker);
RETURN;
********** COMMENT();
SUBROUTINE NAME(SEND_EMAIL);
********** COMMENT();
GET_ENTRY NUMBER(1) FROM_LIST(#TRIG_LIST);
FETCH FIELDS(*ALL) FROM_FILE(SETCUS) WITH_KEY(#S_176CCOD);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176CRED) TO_GET(#CHR_CRED);
SUBSTRING FIELD(#S_176ORNO 1) INTO_FIELD(#CHR_ORNO 1);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176LIMI) TO_GET(#CHR_LIMI);
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#S_176OAMT) TO_GET(#CHR_OAMT);
CHANGE FIELD(#DIFF) TO('#s_176cred - #s_176limi');
USE BUILTIN(NUMERIC_STRING) WITH_ARGS(#DIFF) TO_GET(#CHR_DIFF);
********** COMMENT();
USE BUILTIN(MAIL_START);
********** COMMENT();
CHANGE FIELD(#S_EMORG) TO('[email protected]');
USE BUILTIN(MAIL_ADD_ORIGINATOR) WITH_ARGS(#S_EMORG #S_EMORG);
********** COMMENT();
USE BUILTIN(MAIL_ADD_RECIPIENT) WITH_ARGS(TO *S_176CREDITMGREMAIL *S_176CREDITMGREMAIL);
********** COMMENT();
USE BUILTIN(BCONCAT) WITH_ARGS(#S_176CNAM 'EXCEEDED CREDIT LIMIT') TO_GET(#S_EMSBJ);
USE BUILTIN(MAIL_SET_SUBJECT) WITH_ARGS(#S_EMSBJ);
********** COMMENT();
EXECUTE SUBROUTINE(ADD_TEXT);
********** COMMENT();
USE BUILTIN(MAIL_SET_OPTION) WITH_ARGS(IMPORTANCE HIGH);
********** COMMENT();
USE BUILTIN(MAIL_SEND);
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(ADD_TEXT);
********** COMMENT();
********** COMMENT();
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS('HI,');
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
USE BUILTIN(BCONCAT) WITH_ARGS(#S_176CNAM 'has placed an order (number' #CHR_ORNO ') that totals' #CHR_OAMT) TO_GET(#S_EMLINE);
USE BUILTIN(BCONCAT) WITH_ARGS(#S_EMLINE 'dollars.') TO_GET(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
USE BUILTIN(BCONCAT) WITH_ARGS('This has exceeded their credit limit of' #CHR_LIMI 'dollars by' #CHR_DIFF 'dollars.') TO_GET(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#S_EMLINE);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
********** COMMENT();
EXECUTE SUBROUTINE(PARTIA_URL);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(APPROVED APPROVE);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(HELD HOLD);
EXECUTE SUBROUTINE(COMPLE_URL) WITH_PARMS(REVIEW REVIEW);
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(COMPLE_URL) PARMS((#S_176STAT *RECEIVED) (#STAT_WORD *RECEIVED));
********** COMMENT();
DEFINE FIELD(#STAT_TEXT) REFFLD(#S_EMLINE);
DEFINE FIELD(#STAT_WORD) REFFLD(#S_176STAT);
********** COMMENT();
CASE OF_FIELD(#S_176STAT);
WHEN VALUE_IS('= APPROVED');
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'this order for shipment, click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
WHEN VALUE_IS('= HELD');
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'this order until further checks are made' 'click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
OTHERWISE;
USE BUILTIN(BCONCAT) WITH_ARGS('To' #STAT_WORD 'the details of this order click here -->' #S_EMLINE) TO_GET(#STAT_TEXT);
ENDCASE;
USE BUILTIN(TCONCAT) WITH_ARGS(#STAT_TEXT #S_176STAT) TO_GET(#STAT_TEXT);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(#STAT_TEXT);
USE BUILTIN(MAIL_ADD_TEXT) WITH_ARGS(*BLANK);
********** COMMENT();
ENDROUTINE;
********** COMMENT();
SUBROUTINE NAME(PARTIA_URL);
********** COMMENT();
USE BUILTIN(TCONCAT) WITH_ARGS(*S_URLPORT *S_FIXEDURLPART 'SET_176+SET176D+' *PARTITION '+') TO_GET(#S_EMLINE);
********** COMMENT();
IF COND('*language *ne *blank');
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE *LANGUAGE '+funcparms+chr_orno%28A0070%29:' #CHR_ORNO '+s_176ccod%28A0050%29:') TO_GET(#S_EMLINE);
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE #S_176CCOD) TO_GET(#S_EMLINE);
ELSE;
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE 'funcparms+chr_orno%28A0070%29:' #CHR_ORNO '+s_176ccod%28A0050%29:' #S_176CCOD) TO_GET(#S_EMLINE);
ENDIF;
USE BUILTIN(TCONCAT) WITH_ARGS(#S_EMLINE '+S_176STAT%28A0100%29:') TO_GET(#S_EMLINE);
********** COMMENT();
ENDROUTINE;