Form S_152FB: HTML Browser Demonstration B

LANSA

Form S_152FB: HTML Browser Demonstration B
Name: S_152FB

Description: The following RDMLX form is a demonstration of techniques for interfacing LANSA applications with an HTML browser.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM HEIGHT(75) WIDTH(270);
;
Define #OutFile RefFld(#SysVar$av);
DEFINE_COM CLASS(#S_152RHT) NAME(#DOC) DISPLAYPOSITION(3) PARENT(#COM_OWNER) TABSTOP(False) VISIBLE(False);
DEFINE_COM CLASS(#EMPNO.Visual) NAME(#EMPNO) DISPLAYPOSITION(1) LEFT(8) MARGINLEFT(100) PARENT(#COM_OWNER) TABPOSITION(3) TOP(2) WIDTH(169);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#BTN_FETCH) BUTTONDEFAULT(True) CAPTION('Fetch') DISPLAYPOSITION(2) LEFT(180) PARENT(#COM_OWNER) TABPOSITION(2) TOP(1);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(4) HEIGHT(22) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(26) WIDTH(262);
;
Define #Caption RefFld(#SysVar$AV);
Define #AlpVal RefFld(#SysVar$Av);
Define #NumVal RefFld(#Std_NumL);
Define #Row RefFld(#Std_Num);
Define #Decimals RefFld(#Std_Num);
;
* =============================================================================== ;
;
EVTROUTINE handling(#com_owner.Initialize);
;
SET #com_owner caption(*component_desc);
;
Use TConcat (*Temp_Dir *Component '.htm') (#OutFile) ;
;
ENDROUTINE ;
;
* ================================================================================;
;
EVTROUTINE HANDLING(#BTN_FETCH.Click);
;
* Fetch the employee details ;
;
Fetch *All From_File(PslMst) With_Key(#EmpNo);
;
* If not found issue message and finish ;
;
If_Status Is_Not(*Okay) ;
Message 'Requested employee could not be located';
Return ;
Endif ;
;
* Define the styles we want to use ;
;
Invoke #Doc.DefineStyle Named(Caption) Italic(True) ;
Invoke #Doc.DefineStyle Named(AlphaValue) Alignment(Left) ;
Invoke #Doc.DefineStyle Named(NumericValue) Alignment(Left) ;
;
* Define the HTML tables and their cells ;
;
Invoke #Doc.DefineTable WithName(Emp) Order(1) Border(0) Frame(void) Rules(none) PctWidth(50) SpaceAft(1) WithTitle('Employee Details') RuleBef(1) ;
Invoke #Doc.DefineTableCell InTable(Emp) WithName(Cap) Order(1) CellStyle(Caption) ;
Invoke #Doc.DefineTableCell InTable(Emp) WithName(Val) Order(2) ;
;
Invoke #Doc.DefineTable WithName(Skill) Order(2) Border(0) Frame(void) Rules(none) WithTitle('Skills Associated with this Employee') TitleStyle(Caption) PctWidth(50) RuleBef(1) ;
Invoke #Doc.DefineTableCell InTable(Skill) WithName(Code) ColHdg1('Code') HdgStyle(Caption) Order(1) CellStyle(AlphaValue) ;
Invoke #Doc.DefineTableCell InTable(SKill) WithName(Description) ColHdg1('Description') HdgStyle(Caption) Order(2) CellStyle(AlphaValue) ;
;
* Get the department and section details ;
;
Change (#DeptDesc #SecDesc) '''Not Found''';
Fetch (#DeptDesc) From_File(DepTab) With_Key(#DeptMent) Keep_Last(50);
Fetch (#SecDesc) From_File(SecTab) With_Key(#DeptMent #Section) Keep_Last(50);
;
* Insert the details into the flat employee table ;
;
Change #Row 0 ;
Execute InsAlp ('Employee Number' #EmpNo);
Execute InsAlp ('First Name' #GiveName);
Execute InsAlp ('Last Name' #SurName);
Execute InsAlp ('Address' #Address1);
Execute InsAlp (' ' #Address2);
Execute InsAlp (' ' #Address3);
Execute InsNum ('Zip Code' #PostCode 0);
Execute InsAlp ('Home Phone Number' #PhoneHme);
Execute InsAlp ('Business Phone Number' #PhoneBus);
Execute InsAlp ('Department' #DeptDesc);
Execute InsAlp ('Section' #SecDesc);
Execute InsNum ('Yearly Salary' #Salary 2);
Execute InsNum ('Monthly Salary' #MnthSal 2);
;
* Now Insert the Skill Details;
;
Change #Row 0 ;
Select (#SkilCode) From_File(PslSkl) With_Key(#EmpNo);
Change #Row '#Row + 1' ;
Fetch (#SkilDesc) From_File(SklTab) With_Key(#SkilCode) Keep_Last(50);
Invoke #Doc.SetTableCell InTable(Skill) WithName(Code) Rownum(#Row) Type(alpha) Alphavalue(#SkilCode) ;
Invoke #Doc.SetTableCell InTable(Skill) WithName(Description) Rownum(#Row) Type(alpha) Alphavalue(#SkilDesc) ;
EndSelect ;
;
* Save, Close and Show the result ;
;
Invoke #Doc.Save InFile(#OutFile);
;
Invoke #Doc.Close;
;
Invoke #Doc.Show InFile(#OutFile);
;
* Finished ;
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine InsAlp ((#Caption *Received)(#AlpVal *Received));
;
If '(#AlpVal = *blanks) and (#Caption = *Blanks)';
Return ;
Endif ;
;
Change #Row '#Row + 1';
Invoke #Doc.SetTableCell InTable(Emp) withName(Cap) Rownum(#Row) Type(alpha) Alphavalue(#Caption) ;
Invoke #Doc.SetTableCell InTable(Emp) withName(Val) Rownum(#Row) Type(alpha) Alphavalue(#AlpVal) CellStyle(AlphaValue);
;
EndRoutine ;
;
* ================================================================================;
;
SubRoutine InsNum ((#Caption *Received)(#NumVal *Received)(#Decimals *Received));
;
Change #Row '#Row + 1';
Invoke #Doc.SetTableCell InTable(Emp) withName(Cap) Rownum(#Row) Type(alpha) Alphavalue(#Caption) ;
Invoke #Doc.SetTableCell InTable(Emp) withName(Val) Rownum(#Row) Type(numeric) Decimals(#Decimals) Numvalue(#NumVal) CellStyle(NumericValue);
;
EndRoutine ;
;
END_COM ;