Form S_154FB: Domino Demonstration B

LANSA

Form S_154FB: Domino Demonstration B
Name: S_154FB

Description: The following RDMLX form is a demonstration of interfacing LANSA applications with Domino databases.
;
* ;
* Disclaimer: The following material is supplied as example material only. ;
* ---------------- No warranty concerning this material or its use in any way;
* whatsoever is expressed or implied. ;
* ;
;
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(267) LEFT(335) TOP(235) WIDTH(455);
;
DEFINE_COM CLASS(#SYSVAR$AV.Visual) NAME(#DOM_EMP_NAME) CAPTION('Domino Data Base Name') DISPLAYPOSITION(6) LABELTYPE(Caption) LEFT(8) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(6) TABSTOP(False) TOP(8) VISUALSTYLE(#VS_NOREAD) WIDTH(329);
;
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#DOM_OPEN) CAPTION('Open') DISPLAYPOSITION(2) LEFT(360) PARENT(#COM_OWNER) TABPOSITION(2) TOP(8);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#DOM_CLOSE) CAPTION('Close') DISPLAYPOSITION(3) LEFT(360) PARENT(#COM_OWNER) TABPOSITION(4) TOP(40);
;
DEFINE_COM CLASS(#S_154RDW) NAME(#DOM_EMP) PARENT(#COM_OWNER);
;
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(5) HEIGHT(22) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(5) TABSTOP(False) TOP(218) WIDTH(447);
DEFINE_COM CLASS(#PRIM_PGBR) NAME(#PROGBAR) DISPLAYPOSITION(1) HEIGHT(16) LEFT(257) PARENT(#STBR_1) TABPOSITION(1) TABSTOP(False) TOP(4) VISIBLE(False) WIDTH(171);
;
DEFINE_COM CLASS(#PRIM_PANL) NAME(#DETAILS) DISPLAYPOSITION(7) HEIGHT(126) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(7) TABSTOP(False) TOP(80) VISIBLE(False) VISUALSTYLE(#VS_NOREAD) WIDTH(441);
DEFINE_COM CLASS(#EMPNO.Visual) NAME(#EMPNO) DISPLAYPOSITION(4) LEFT(8) PARENT(#COM_OWNER) TABPOSITION(3) TOP(40) VISIBLE(False);
DEFINE_COM CLASS(#GIVENAME.Visual) NAME(#GIVENAME) DISPLAYPOSITION(1) LEFT(0) PARENT(#DETAILS) TABPOSITION(1) TOP(8) VISUALSTYLEOFPARENT(False);
DEFINE_COM CLASS(#SURNAME.Visual) NAME(#SURNAME) DISPLAYPOSITION(2) LEFT(0) PARENT(#DETAILS) TABPOSITION(2) TOP(38) VISUALSTYLEOFPARENT(False);
DEFINE_COM CLASS(#SALARY.Visual) NAME(#SALARY) DISPLAYPOSITION(3) LEFT(0) PARENT(#DETAILS) TABPOSITION(3) TOP(68) VISUALSTYLEOFPARENT(False) WIDTH(241);
DEFINE_COM CLASS(#POSTCODE.Visual) NAME(#POSTCODE) DISPLAYPOSITION(4) LEFT(0) PARENT(#DETAILS) TABPOSITION(4) TOP(96) VISUALSTYLEOFPARENT(False) WIDTH(201);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_UPDATE) CAPTION('&Update') DISPLAYPOSITION(5) LEFT(352) PARENT(#DETAILS) TABPOSITION(5) TOP(8);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_DELETE) CAPTION('&Delete') DISPLAYPOSITION(6) LEFT(352) PARENT(#DETAILS) TABPOSITION(6) TOP(40);
;
Define #EmpHandle RefFld(#Std_Num);
Def_Cond *Emp '#EmpHandle *ne 0';
Def_Cond *NoEmp '#EmpHandle = 0';
;
* =========================================================================================== ;
;
* Handle form initialization ;
;
EvtRoutine Handling(#Com_Owner.Initialize);
;
* Set initial invisibility;
;
Set #DOM_Open Enabled(True);
Set (#DOM_Close) Enabled(False);
Set (#EmpNo #Details) Visible(False);
;
* Define the names of the Domino databases to be used ;
* WARNING : These database names must be defined to Domino before executing this application ;
;
Set #Dom_EMP_Name Value(PSLMST_DEMO);
* ;
* Define the Domino equivalent of PSLMST;
* ;
Invoke #DOM_EMP.DefineItem SymName(Empno) DomName(EMPLOYEE_NUMBER) TYPE(Text) KeyNumber(1);
Invoke #DOM_EMP.DefineItem SymName(Surname) DomName(EMPLOYEE_SURNAME) TYPE(Text);
Invoke #DOM_EMP.DefineItem SymName(GiveName) DomName(EMPLOYEE_GIVEN_NAME) TYPE(Text);
Invoke #DOM_EMP.DefineItem SymName(Salary) DomName(EMPLOYEE_SALARY) TYPE(Number) Decimals(2);
Invoke #DOM_EMP.DefineItem SymName(Postcode) DomName(EMPLOYEE_ZIP_CODE) TYPE(Number) Decimals(0);
* ;
EndRoutine ;
;
* =========================================================================================== ;
;
* Handle error from Domino Interface ;
;
EvtRoutine Handling(#DOM_EMP.DominoErrorDetected);
USE BUILTIN(MESSAGE_BOX_SHOW) WITH_ARGS(OK OK WARNING *COMPONENT 'A domino related error was signalled');
EndRoutine ;
;
* =========================================================================================== ;
;
* Handle close of this form;
;
EvtRoutine Handling(#Com_Owner.Closing);
Invoke #DOM_EMP.Close;
Endroutine ;
;
* =========================================================================================== ;
;
* Handle an Open button request;
;
EVTROUTINE HANDLING(#DOM_OPEN.Click);
Invoke #DOM_EMP.Open WithName(#Dom_EMP_Name.Value);
Set #DOM_Open Enabled(False);
Set #DOM_Close Enabled(True);
Set #EmpNo Visible(True) Value(' ');
Set #Details Visible(False);
Message 'Open completed';
ENDROUTINE ;
;
* =========================================================================================== ;
;
* Handle a close button request;
;
EVTROUTINE HANDLING(#DOM_CLOSE.Click);
Invoke #DOM_EMP.Close;
Set #DOM_Open Enabled(True);
Set #DOM_Close Enabled(False);
Set (#EmpNo #Details) Visible(False);
Message 'Close completed';
ENDROUTINE ;
;
* =========================================================================================== ;
;
* Handle change of employee number by looking up Domino table;
;
EVTROUTINE HANDLING(#EMPNO.Changed) ;
;
Define #TEmpNo RefFld(#EmpNo);
Define #TEmpnoC5 *char 1 To_Overlay(#TEmpNo 5);
Define #TempCount RefFld(#Std_Num);
;
Change #TEmpNo #Empno;
;
* Don't bother looking up details unless last char of employee number has been typed in ;
;
If_Null #TEmpNoC5;
Set #Details Visible(False) ;
Return ;
Endif ;
;
* Look up the employee details in Domino;
;
Invoke #DOM_EMP.SetItem SymName(Empno) AlphaVal(#TEmpNo);
Invoke #DOM_EMP.Fetch NumberKeys(1) RetHandle(#EmpHandle);
;
* If no details were found ;
;
If *NoEmp;
Set #Details Visible(False) ;
Message 'Employee not found' ;
Return ;
Endif ;
;
* If details were found, map back their values ;
;
Invoke #DOM_EMP.GetItem SymName(Empno) AlphaVal(#EmpNo);
Invoke #DOM_EMP.GetItem SymName(Surname) AlphaVal(#SurName);
Invoke #DOM_EMP.GetItem SymName(GiveName) AlphaVal(#GiveName);
Invoke #DOM_EMP.GetItem SymName(Salary) NumericVal(#Salary);
Invoke #DOM_EMP.GetItem SymName(Postcode) NumericVal(#PostCode);
Set #Details Visible(True);
;
* Finished ;
;
ENDROUTINE ;
;
* =========================================================================================== ;
;
* Handle an update Request ;
;
EVTROUTINE HANDLING(#BTN_UPDATE.Click);
If *Emp;
Invoke #DOM_EMP.SetItem SymName(Surname) AlphaVal(#SurName);
Invoke #DOM_EMP.SetItem SymName(GiveName) AlphaVal(#GiveName);
Invoke #DOM_EMP.SetItem SymName(Salary) NumericVal(#Salary);
Invoke #DOM_EMP.SetItem SymName(Postcode) NumericVal(#PostCode);
Invoke #DOM_EMP.Update WithHandle(#EmpHandle) RetHandle(#EmpHandle);
If *NoEmp;
Set #Details Visible(False) ;
Message 'Employee not found. Employee details NOT updated.' ;
Else ;
Message 'Employee details updated' ;
Endif ;
Endif ;
ENDROUTINE ;
;
* =========================================================================================== ;
;
* Handle a Delete Request;
;
EVTROUTINE HANDLING(#BTN_DELETE.Click);
If *Emp;
Invoke #DOM_EMP.Delete WithHandle(#EmpHandle) RetHandle(#EmpHandle);
Set #Details Visible(False) ;
If *NoEmp;
Message 'Employee not found. Employee details NOT deleted by your request.' ;
Else ;
Message 'Employee details deleted' ;
Endif ;
Endif ;
ENDROUTINE ;
;
;
END_COM ;