Step 1. Create the Called Function

1.  Create the following new fields in the Repository:

a.  iiiNewSalary, New Salary, Decimal, 11, 2 Edit Mask N

b.  iiiPercent – Percent Increase, Decimal, 3, 2, Edit Mask N

c.  iiiTotalSalary, should already exist. It was created in exercise FRM075.

2.  Check In the new fields and field iiiFullName to the IBM i server if you are using a Visual LANSA Slave Workstation

3.  Create a new process:


     Description: FRM Training.

     You do not need to open it in the editor. Functions belong to a Process, which provides a menu in 5250 style applications.

4.  Create a new function:

     Process: iiiPRO01.


     Description: Salary Review

     Template: No template selected

     RDMLX enabled (YES)

5.  Functions which receive and return a working list require a FUNCTION statement with a RCV_LIST() parameter. Define your FUNCTION statement as follows:

    Function Options(*DIRECT) Rcv_List(#Employees)


6.  Define a working list, named Employees, containing fields xEmployeeIdentification, iiiFullname, xDepartmentCode, xEmployeeSalary and iiiNewSalary. Entrys=*max. Counter = LISTCOUNT.

Def_List Name(#Employees) Fields(#xEmployeIdentification #iiiFullname #xDepartmentCode #xEmployeeSalary #iiiNewSalary) Counter(#Listcount) Type(*working) Entrys(*max)

7.  Define a GROUP_BY, EmployeeData, containing fields xEmployeeIdentification, xEmployeeSurname, xEmployeeGivenNames, xDepartmentCode and xEmployeeSalary.

8.  Your function logic should be based on the following:

Clear list Employees

Select EmployeeData from index xEmployeeByDepartment with key xDepartmentCode

Assign iiiFullname to xEmployeeSurname + ', ' + xEmployeeGivenNames

Assign iiiNewSalary to (xEmployeeSalary + (xEmployeeSalary * (iiiPercent / 100)))

Add entry to list Employees

End Select


     Your code should look like the following:

Function Options(*DIRECT) Rcv_List(#Employees)

Def_List Name(#Employees) Fields(#xEmployeeIdentification #iiiFullName #xDepartmentCode #xEmployeeSalary #iiiNewSalary) Counter(#listcount) Type(*WORKING) Entrys(*MAX)

Group_By Name(#EmployeeData) Fields(#xEmployeeIdentification #xEmployeeSurname #xEmployeeGivenNames #xDepartmentCode #xEmployeeSalary)

Clr_List Named(#Employees)

Select Fields(#EmployeeData) From_File(xEmployeeByDepartment) With_Key(#xDepartmentCode)

#iiiFullname := #xEmployeeSurname + ', ' + #xEmployeeGivenNames

#iiinewsalary := (#xEmployeeSalary + (#xEmployeeSalary * (#iiiPercent / 100)))

Add_Entry To_List(#Employees)



9. Compile your function

10. With the function open in the editor, use the Check In button on the Home ribbon to check in and compile the function to the IBM i Server.

     The process iiiPRO01 will be automatically checked in with the function and compiled.

     Review the Check In options dialog and ensure the Debug Enabled option is selected. Note that the Keep Locks checkbox retains your lock on the components. You could change it and check in again if necessary.

     You will learn more about Check In in exercise FRM110 - Check Out / In to IBM i.