Page History
This example is an extension of the previous one. It shows the same details but it also shows the skills in a Visual LANSA list view.
In this example you can see how to access a subfile/browselist:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #VF_AC010) Height(569) Layoutmanager(#MAIN_LAYOUT) Width(776)
* ================================================================================
...
* Simple Field and Group Definitions
* ================================================================================
Group_By Name(#XG_HEAD) Fields(#EMPNO #SURNAME #GIVENAME #ADDRESS1 #ADDRESS2 #ADDRESS3 #POSTCODE #PHONEHME #DEPTMENT #SECTION)
...
* Body and Button arrangement panels
...
Define_Com Class(#PRIM_PANL) Name(#BUTTON_PANEL) Displayposition(2) Height(569) Hint(*MTXTDF_DET1) Layoutmanager(#BUTTON_FLOW) Left(688) Parent(#COM_OWNER) Tabposition(3) Tabstop(False) Top(0) Width(88)
Define_Com Class(#PRIM_PANL) Name(#BODY_HEAD) Displayposition(1) Height(569) Hint(*MTXTDF_DET1) Layoutmanager(#BODY_HEAD_FLOW) Left(0) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(0) Verticalscroll(True) Width(688)
...
* Attachment and flow layout managers
...
Define_Com Class(#PRIM_ATLM) Name(#MAIN_LAYOUT)
Define_Com Class(#PRIM_FWLM) Name(#BUTTON_FLOW) Direction(TopToBottom) Flowoperation(Center) Marginbottom(4) Marginleft(4) Marginright(4) Margintop(4) Spacing(4) Spacingitems(4)
...
Define_Com Class(#PRIM_FWLM) Name(#BODY_HEAD_FLOW) Direction(TopToBottom) Marginbottom(4) Marginleft(4) Marginright(4) Margintop(4) Spacing(4) Spacingitems(4)
...
Define_Com Class(#PRIM_FWLI) Name(#FWLI_EMPNO) Manage(#EMPNO) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_SURNAME) Manage(#SURNAME) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_GIVENAME) Manage(#GIVENAME) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_ADDRESS1) Manage(#ADDRESS1) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_ADDRESS2) Manage(#ADDRESS2) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_ADDRESS3) Manage(#ADDRESS3) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_POSTCODE) Manage(#POSTCODE) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_PHONEHME) Manage(#PHONEHME) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_SAVE_BUTTON) Manage(#SAVE_BUTTON) Parent(#BUTTON_FLOW)
...
* The save button
...
Define_Com Class(#PRIM_PHBN) Name(#SAVE_BUTTON) Caption(*MTXTDF_SAVE) Displayposition(1) Left(4) Parent(#BUTTON_PANEL) Tabposition(1) Top(4)
...
* Collection for detail fields
...
Define_Com Class(#Prim_ACol<#prim_evef>) Name(#PanelFields)
...
* Fields in the head area
...
Define_Com Class(#EMPNO.Visual) Displayposition(1) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(1) Top(4) Usepicklist(False) Width(209)
Define_Com Class(#SURNAME.Visual) Displayposition(2) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(2) Top(27) Usepicklist(False) Width(324)
Define_Com Class(#GIVENAME.Visual) Displayposition(3) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(3) Top(50) Usepicklist(False) Width(324)
Define_Com Class(#ADDRESS1.Visual) Displayposition(4) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(4) Top(73) Usepicklist(False) Width(363)
Define_Com Class(#ADDRESS2.Visual) Displayposition(5) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(5) Top(96) Usepicklist(False) Width(363)
Define_Com Class(#ADDRESS3.Visual) Displayposition(6) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(6) Top(119) Usepicklist(False) Width(363)
Define_Com Class(#POSTCODE.Visual) Displayposition(7) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(7) Top(142) Usepicklist(False) Width(216)
Define_Com Class(#PHONEHME.Visual) Displayposition(8) Height(19) Hint(*MTXTDF_DET1) Left(4) Parent(#BODY_HEAD) Tabposition(8) Top(165) Usepicklist(False) Width(286)
Define_Com Class(#PRIM_ATLM) Name(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_1) Attachment(Center) Parent(#ATLM_1)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_2) Attachment(Center) Manage(#BODY_HEAD) Parent(#MAIN_LAYOUT)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_3) Attachment(Right) Manage(#BUTTON_PANEL) Parent(#MAIN_LAYOUT)
...
Define_Com Class(#vf_sy122) Name(#myscreen_wrapper) Displayposition(3) Height(569) Parent(#COM_OWNER) Visible(False) Width(688)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_4) Attachment(Center) Parent(#MAIN_LAYOUT)
Define_Com Class(#PRIM_ATLI) Name(#ATLI_6) Attachment(Center) Manage(#myscreen_wrapper) Parent(#MAIN_LAYOUT)
...
Define_Com Class(#PRIM_LTVW) Name(#skills) Componentversion(2) Displayposition(9) Fullrowselect(True) Height(229) Left(4) Parent(#BODY_HEAD) Showsortarrow(True) Tabposition(9) Top(188) Width(485)
Define_Com Class(#PRIM_FWLI) Name(#FWLI_1) Manage(#skills) Parent(#BODY_HEAD_FLOW)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_2) Displayposition(2) Parent(#skills) Source(#SKILCODE) Width(17)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_3) Captiontype(ColumnHeadings) Displayposition(3) Parent(#skills) Source(#SKILDESC) Width(32)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_4) Captiontype(ColumnHeadings) Displayposition(4) Parent(#skills) Source(#COMMENT) Width(24)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_5) Displayposition(5) Parent(#skills) Source(#GRADE) Width(8) Widthtype(Characters)
Define_Com Class(#PRIM_LVCL) Name(#LVCL_1) Caption('Acquired') Captiontype(Caption) Displayposition(1) Parent(#skills) Source(#VF_ELTXTS) Width(18) Widthtype(Fixed)
...
* --------------------------------------------------------------------------------
* Handle Initialization
* --------------------------------------------------------------------------------
...
Mthroutine Name(uInitialize) Options(*REDEFINE)
Define_Com Class(#Prim_evef) Name(#FormField) Reference(*dynamic)
...
Invoke Method(#Com_Ancestor.uInitialize)
...
For Each(#Control) In(#Body_Head.ComponentControls)
If_Ref Com(#Control) Is(*INSTANCE_OF #prim_evef)
Set_Ref Com(#FormField) To(*dynamic #Control)
Invoke Method(#PanelFields.Insert) Item(#FormField)
Endif
Endfor
...
* Set the uCommand wrapper property.
Set Com(#myscreen_wrapper) Ucommand(#com_owner)
Endroutine
...
* --------------------------------------------------------------------------------
* Handle Command Execution
* --------------------------------------------------------------------------------
...
Mthroutine Name(uExecute) Options(*REDEFINE)
...
Invoke Method(#Com_Ancestor.uExecute)
...
* The user has selected an Employee from the instance list. MakeRampAvailable will make sure the connection is in order and then signal back with the appropiate action
Invoke Method(#myscreen_wrapper.MakeRampAvailable) Foraction(ShowDetails)
...
Set Com(#Save_Button) Enabled(False)
...
Endroutine
...
* ================================================================================
* Event Handlers
* ================================================================================
...
* RAMP has signalled it's available. What we do will depend on the #ForAction specified in the MakeRampAvailable method invocation.
Evtroutine Handling(#myscreen_wrapper.RampAvailable) Foraction(#ForAction) Nextaction(#NextAction)
...
Case (#ForAction)
...
When Value_Is('= ShowDetails')
...
* Navigate to a Destination that was previously named EmployeeDetailsAndSkills using newlook Designer. Use the ReturnScreen parameter to verify we are in the expected screen
* once the navigation has completed
Invoke Method(#myscreen_wrapper.navigatetoscreen) Name('EmployeeDetailsAndSkills') Returnscreen(#vf_eltxtl)
...
* If the current screen is the expected one, get the values of the 5250 screen fields into the fields in this component and the skills into the skills list view
...
If (#vf_eltxtl = 'EmployeeDetailsAndSkills')
...
#myscreen_wrapper.sendkey( #myscreen_wrapper.KeyF21 )
...
Invoke Method(#avListManager.GetCurrentInstance) Akey3(#EMPNO)
#myscreen_wrapper.getvalue From('uSurname') Value(#surname.value)
#myscreen_wrapper.getvalue From('uGivename') Value(#givename.value)
#myscreen_wrapper.getvalue From('uAddress1') Value(#address1.value)
#myscreen_wrapper.getvalue From('uAddress2') Value(#address2.value)
#myscreen_wrapper.getvalue From('uAddress3') Value(#address3.value)
#myscreen_wrapper.getvalue From('uHomePhone') Value(#phonehme.value)
#myscreen_wrapper.getvalue From('uPostcode') Value(#POSTCODE.value)
...
#com_owner.uGetSkills Gridname('uSkillsGrid')
Endif
...
When Value_Is('= UpdateDetails')
...
#myscreen_wrapper.setvalue Infield('uSurname') Value(#surname.value)
#myscreen_wrapper.setvalue Infield('uGivename') Value(#givename.value)
#myscreen_wrapper.setvalue Infield('uAddress1') Value(#address1.value)
#myscreen_wrapper.setvalue Infield('uAddress2') Value(#address2.value)
#myscreen_wrapper.setvalue Infield('uAddress3') Value(#address3.value)
#myscreen_wrapper.setvalue Infield('uHomePhone') Value(#phonehme.value)
#myscreen_wrapper.setvalue Infield('uPostcode') Value(#POSTCODE.value)
#myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyEnter) Returnscreen(#vf_eltxtl)
...
* Update the instance list using the "quick update" method
Use Builtin(BConcat) With_Args(#GiveName #SurName) To_Get(#FullName)
Invoke Method(#avListManager.UpdateListEntryData) Akey1(#Deptment) Akey2(#Section) Akey3(#Empno) Visualid2(#FullName) Acolumn1(#Phonehme) Acolumn2(#Address1) Ncolumn1(#PostCode) Businessobjecttype(EMPLOYEES)
- Disable the save button again
Set Com(#SAVE_BUTTON) Enabled(False)
- Drop the framework lock as no updates are outstanding now
Set Com(#avFrameworkManager) Ulocked(FALSE)
Otherwise
Use Builtin(message_box_show) With_Args(ok ok info *component ('Unknown ForAction>>' + #ForAction.Value + '<<'))
Endcase
Set Com(#myscreen_wrapper) Visible(False)
Endroutine
- Traverse the skills subfile/browselist by column name
Mthroutine Name(uGetSkills)
Define_Map For(*input) Class(#vf_eltxtl) Name(#GridName)
Define_Map For(*input) Class(#vf_eltxtl) Name(#nxtpage) Mandatory('+')
Define Field(#colcount) Type(*dec) Length(2) Decimals(0)
Define Field(#rowcount) Type(*dec) Length(4) Decimals(0)
Define Field(#column) Type(*dec) Length(2) Decimals(0) Default(0)
Define Field(#row) Type(*dec) Length(2) Decimals(0) Default(0)
Define Field(#colname) Type(*char) Length(50)
Define Field(#headrows) Type(*dec) Length(2) Decimals(0) Default(0)
Clr_List Named(#skills)
Dowhile (#nxtpage *NE '')
- Get the total number of subfile rows
#myscreen_wrapper.getvalue From(#GridName.value + ".RowCount") Value(#rowcount) - Get the total number of subfile heading rows
#myscreen_wrapper.getvalue From(#GridName.value + ".HeadRows") Value(#headrows)
- Subtract one because the row collection is zero based.
#rowcount -= 1
Begin_Loop Using(#row) From(#headrows) To(#rowcount)
- get the number of subfile colums
#myscreen_wrapper.getvalue From(#GridName.value + ".Columns.Count") Value(#colcount)
Begin_Loop Using(#column) To(#colcount) - get the column name. Use a method to make the code easier to read
#com_owner.uGetColName Ugridname(#GridName.value) Ucolnumber(#column) Ucolname(#colname)
- for the appropiate column, get the cell value
Case (#colname)
When Value_Is(= 'DateSklAcquired')
#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#vf_eltxts)
When Value_Is(= 'SkillCode')
#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#skilcode)
When Value_Is(= 'SkillDescription')
#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#skildesc)
When Value_Is(= 'Comment')
#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#comment)
When Value_Is(= 'Grade')
#com_owner.uGetCellValue Ugridname(#GridName.value) Ucolnumber(#column) Urownumber(#row) Ucellvalue(#grade)
Endcase
End_Loop
- Sometimes newlook treats rows without data as valid rows so add only the ones where at least one field has data
If_Null (#skilcode #skildesc #comment #grade)
Else
Add_Entry To_List(#skills)
Endif
End_Loop
- If there is another page, page down
#myscreen_wrapper.getvalue From(#GridName.value + ".Marker") Value(#nxtpage.value)
If (#nxtpage.value *NE '')
#myscreen_wrapper.sendkey Key(#myscreen_wrapper.KeyPageDown)
Endif
Endwhile
Endroutine
Mthroutine Name(uGetColName)
Define_Map For(*input) Class(#vf_eltxtl) Name(#uGridName)
Define_Map For(*input) Class(#vf_elnum) Name(#uColNumber)
Define_Map For(*output) Class(#vf_eltxtl) Name(#uColName)
- The column collection is zero based but Begin Loop must start at minimum of 1.
#ucolnumber -= 1
#myscreen_wrapper.getvalue From(#uGridName.value + ".Columns(" + #uColNumber.asstring + ").Name") Value(#ucolname.value)
Endroutine
Mthroutine Name(uGetCellValue)
Define_Map For(*input) Class(#vf_eltxtl) Name(#uGridName)
Define_Map For(*input) Class(#vf_elnum) Name(#uColNumber)
Define_Map For(*input) Class(#vf_elnum) Name(#uRowNumber)
Define_Map For(*output) Class(#vf_eltxtl) Name(#uCellvalue)
- The column collection is zero based but Begin Loop must start at minimum of 1.
#ucolnumber -= 1
#myscreen_wrapper.getvalue From(#uGridName.value + ".Columns(" + #uColNumber.asstring + ").Cells(" + #uRowNumber.asstring + ").Text") Value(#ucellvalue.value)
Endroutine
- Listen to messages from RAMP and the 5250 application
Evtroutine Handling(#myscreen_wrapper.RampMessage) Umessagetype(#MsgType) Umessagetext(#MsgText)
Case (#msgtype.value)
When Value_Is('= VF_ERROR') - Fatal messages reported by Ramp (e.g. Navigation request failed, etc). If in design mode, show the underlying newlook screen. Otherwise, make the error message
- appear in a message box on top of the command
If (#usystem.iDesignMode = true)
Set Com(#myscreen_wrapper) Visible(True)
Else
Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)
#com_owner.avshowmessages
Endif
- Messages sent by the IBM i application or unknown form was encountered
When Value_Is('= VF_INFO' '= VF_UNKNOWN_FORM')
Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)
- Failure to initialize RAMP. Could occur for mainly one of two reasons
When Value_Is('= VF_INIT_ERROR')
Message Msgid(dcm9899) Msgf(dc@m01) Msgdta(#msgtext.value)
#com_owner.avshowmessages
When Value_Is('= VF_WAITCONNECTION')
Otherwise
Use Builtin(message_box_show) With_Args(ok ok info *Component ('Unknown message type ' + #MsgType + 'encountered'))
Endcase
Endroutine
- --------------------------------------------------------------------------------
- Handle changes in any of the fields on the panel
- --------------------------------------------------------------------------------
Evtroutine Handling(#PanelFields<>.Changed)
- Enable the save button
Set Com(#SAVE_BUTTON) Enabled(True)
- Lock the framework and set a message for the user
Use Builtin(bconcat) With_Args('Changes made to employee' #GiveName #Surname 'have not been saved yet.' 'Do you want to save them before continuing?') To_Get(#sysvar$av)
Set Com(#avFrameworkManager) Ulocked(USER) Ulockedmessage(#sysvar$av)
Endroutine
- --------------------------------------------------------------------------------
- Enter key pressed
- --------------------------------------------------------------------------------
Evtroutine Handling(#PanelFields<>.KeyPress) Options(*NOCLEARMESSAGES *NOCLEARERRORS) Keycode(#KeyCode)
If Cond('#KeyCode.Value = Enter')
- If there no changes have been made issue message and ignore enter
If Cond('#SAVE_BUTTON.Enabled *EQ True')
Invoke Method(#Com_Owner.Save)
Else
- Issue 'There are no changes to save' message
Use Builtin(Message_box_show) With_Args(ok ok Info *Component *MTXTDF_NO_SAVE)
Endif
Endif
Endroutine
- --------------------------------------------------------------------------------
- Handle the save button
- --------------------------------------------------------------------------------
Evtroutine Handling(#SAVE_BUTTON.Click)
- Call the Save method
Invoke Method(#Com_Owner.Save)
Endroutine
- --------------------------------------------------------------------------------
- Handle Save
- --------------------------------------------------------------------------------
Mthroutine Name(Save)
- Update data base
Invoke Method(#myscreen_wrapper.MakeRampAvailable) Foraction(UpdateDetails)
- If update completed okay
Endroutine
- --------------------------------------------------------------------------------
- Handle Termination
- --------------------------------------------------------------------------------
Mthroutine Name(uTerminate) Options(*REDEFINE)
- Clean up the colelction of fields on the panel
Invoke Method(#PanelFields.RemoveAll)
- Do any termination defined in the ancestor
Invoke Method(#Com_Ancestor.uTerminate)
Endroutine
End_Com
