Step 2. Create the Reverse Command
VFW120 – Using Hidden Commands
1. Create a new
:iiiVFW41
Reverse Hidden Command.
2. Replace its code with the following:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #VF_AC020)
* ==============================================================================
* Simple Field and Group Definitions
* ==============================================================================
Define Field(#REVSD) Reffld(#VF_ELBOOL)
Def_Cond Name(*REVSD) Cond('#REVSD *EQ TRUE')
* ==============================================================================
* Handle Command Execution
* ==============================================================================
Mthroutine Name(uExecute) Options(*REDEFINE)
* Do any execution logic defined in the ancestor
Invoke Method(#Com_Ancestor.uExecute)
* Get the Employee number of the current instance
Invoke Method(#avListManager.GetCurrentInstance) Akey1(#EMPNO) Acolumn3(#REVSD)
* Fetch information from the main file to fill in the header fields on the form
Fetch Fields(#SURNAME #GIVENAME) From_File(PSLMST) With_Key(#EMPNO)
* Put the names together in the reverse order
If Cond(*REVSD)
* Put the names together Given name first
Change Field(#UF_VisID2) To(#GIVENAME)
Use Builtin(BConcat) With_Args(#UF_VisID2 #SURNAME) To_Get(#UF_VisID2)
* Set the reversed flag
Change Field(#REVSD) To(FALSE)
Else
* Put the names together Surname first
Change Field(#UF_VisID2) To(#SURNAME)
Use Builtin(BConcat) With_Args(#UF_VisID2 #GIVENAME) To_Get(#UF_VisID2)
* Set the reversed flag
Change Field(#REVSD) To(TRUE)
Endif
* Update the name (Visual ID 2) to the instance list
Invoke Method(#avListManager.UpdateListEntryData) Akey1(#EMPNO) Visualid2(#UF_VisID2) Acolumn3(#REVSD)
Endroutine
End_Com
3. Compile your reusable part and review the code:
a. All hidden commands must have an ancestor of VF_AC020.
b. The
method, retrieves and for the current instance list entry. Note that you may need to change this column number if your instance list already uses it to hold a different value.c. Fetches surname and givename for this employee number.
d. Tests the value of the condition *REVSD which is checks if the value returned from AColumn3 is TRUE.
e. Depending on *REVSD, VisualID2 is updated, with Surname first or Given Name first.
f. Updates the current list entry, columns VisualID2 and AColumn3.