Step 3. Create a Relationship Handler to Load _Sections
VFW100 – Define a Parent/Child Instance List
In this step you will create a relationship handler that loads Sections into the instance list when a Department is expanded.
You could have loaded the all the Sections in the hidden filter code together with the Departments, but by using a relationship handler you can improve application performance by first only adding root or parent objects to the instance list and then dynamically adding the child objects.
1. In the Visual LANSA editor, create a new iiiVFPR01 – Framework Functions.
Do not open the Process in the editor.
Create a new
belonging to process iiiVFPR01.iiiVF01
_Sections Relationship Handler
a. No
is required.b. Enable for RDMLX.
c. Open the Function in the
.2. Replace the existing code in the function with this code that indicates that this function is a relationship handler:
FUNCTION OPTIONS(*DIRECT *LIGHTUSAGE) RCV_LIST(#VIS_LIST #PID_LIST #COL1_LIST #COL2_LIST #COL3_LIST #COL4_LIST #COL5_LIST #COL6_LIST #COL7_LIST #COL8_LIST #COL9_LIST #COLA_LIST)
INCLUDE PROCESS(*DIRECT) FUNCTION(VFREL1)
INCLUDE PROCESS(*DIRECT) FUNCTION(VFREL2)
The VFREL1 and VFREL2 functions which you have include the standard definitions for relationship builder functions.
3. Start your code after the included functions. Add code to clear all the keys and additional columns in the instance list:
EXECUTE SUBROUTINE(CLEARKEYS)
EXECUTE SUBROUTINE(CLEARCOLS)
The subroutines you call in the relationship handler are contained in the VFREL2 function.
4. Get the key value of the selected department:
#DEPTMENT := #SRC_AK1
5. Select the sections in the current department and set the values of the instance list entry:
SELECT FIELDS(*ALL) FROM_FILE(SECTAB) WITH_KEY(#DEPTMENT)
EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(1 #DEPTMENT)
EXECUTE SUBROUTINE(SETAKEY) WITH_PARMS(2 #SECTION)
EXECUTE SUBROUTINE(SETNCOL) WITH_PARMS(1 #SECPCODE)
EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(1 #SECADDR1)
EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(2 #SECADDR2)
EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(3 #SECADDR3)
EXECUTE SUBROUTINE(SETACOL) WITH_PARMS(4 #SECPHBUS)
EXECUTE SUBROUTINE(ADDTOLIST) WITH_PARMS('_SECTIONS' #SECDESC #SECTION)
ENDSELECT
IMPORTANT: Ensure the contains the correct name for your _Sections business object.
- The SETAKEY subroutine sets the alpha key values of the child instance list. The first parameter of the subroutine is the key position and the second parameter is the value of the key. There is also a SETNKEY subroutine to set a numeric key.
- The SETNCOL and SETACOL subroutines add additional columns for the child instance list entry.
- The subroutine adds the entry to the instance list. The first parameter of the subroutine is the child business object name, the second parameter is the column and the third parameter is the column.
Your code will now look like this:
6. Compile the function.
7. Open the Framework as Designer.
8. Display the
dialog of the _Departments business object.9. In the
tab select the _Sections business object.10. In the iiiVF01 for the relationship handler.
field, enter the function name
12. Close the _Departments properties dialog.
13.
the Framework.14. Select the _Departments business object in the iii HR application.
15. Expand a department in the instance list.
When you expand each department, the sections are loaded dynamically.
Note: The instance list displays the additional columns for _Sections which you defined in Step 1.