Step 3. Create the Command Handler Logic
VFW054 – Edit Text in a Memo / Edit Box
The
command handler is an instance list command. These means it should begin by retrieving the instance list current entry, so that it can restore notes for this employee.1. Create an uExecute method routine with an Options(*redefine) parameter. This routine needs to do the following:
a. Invoke the ancestor uExecute method
b. Invoke the List Manager GetCurrentItem method to retrieve AKey1 (contains EMPNO)
c. Clear the Memo box
d. Select all iiiEmpNotes records for this EMPNO and iiiNteType = G
e. Add entries to Memo box
Your code should look like the following:
Mthroutine Name(uExecute) Options(*redefine)
#com_ancestor.uExecute
#avlistmanager.getCurrentInstance Akey1(#empno)
Clr_List Named(#MEMO_1)
#iiiNTETYP := G
Select Fields(#MEMO_1) From_File(iiiEmpNotes) With_Key(#empno #iiiNteType)
Add_Entry To_List(#MEMO_1)
Endselect
Endroutine
2. In this step you will add logic to handle the
button click event.The Memo box has a uExecute routine so that the memo box property is set to false, before clearing the Memo box. For example:
property, which your save logic can test to determine whether the notes data needs to be saved. Modify your#MEMO_1.modified := false
Remember you can find out more about any component's properties, event and methods by using the
.Create a Click event handling routine for the push button. Add logic to perform the following:
If the Memo box Modified property is true – perform
Change iiiNTETYPE to G
Delete all records from iiiEmpNotes for this employee and Note Type.
Read all items in the Memo box using SELECTLIST
Insert new records to iiiEmpNotes
Your code should look like the following:
Evtroutine Handling(#PHBN_SAVE.Click)
If (#MEMO_1.modified)
#iiiNteType := G
Delete From_File(iiiEmpNotes) With_Key(#empno #iiiNteType)
Selectlist Named(#MEMO_1)
Insert Fields(#iiiNTELNE #iiiNteType #iiiNTESQN #iiiLneCnt #empno) To_File(iiiEMPNOTE)
Endselect
Endif
Endroutine
3. Create a Click event handling routine for the button. Add logic to delete all entries for this employee with iiiNTETYPE = G.
Clear the memo box.
Your code should look like the following:
Evtroutine Handling(#PHBN_DLT.Click)
#iiiNteType := G
Delete From_File(iiiEmpNotes) With_Key(#empno #iiiNteType)
Clr_List Named(#MEMO_1)
Endroutine
4. Compile your component.
5. Execute the
and open the properties dialog for the business object.6. Select the iiiVFW08.
tab, select the action and define its as7.
the Framework as an end user.8. Test the
command handler.9. Using standard Windows shortcuts (Copy = Ctrl+C, Paste = Ctrl+V), copy text from a portion of the LANSA Online Guides and paste it into employee brief notes.