Step 5 Update Employee Details

Visual LANSA

Step 5. Update Employee Details

FRM085 - Update from a Grid

In this step you will add Save and Close push buttons. You will code the Save button Click event to update the employee record (PSLMST) and update, delete and add skills to file PSLSKL from changes made to the SKILLS grid.

1.  Add two push buttons, inside the Details group box, below the SKILLS grid. Set up the buttons as follows:

Push Button

Property

Value

Save

Caption

Save

Name

SAVE

Close

Caption

Close

Name

CLOSE

 

     Your form should look like the following:

2.  Create a click event for the CLOSE button and add code to close the form. Your code should look like the following:

Evtroutine Handling(#CLOSE.Click)
#com_owner.closeForm
Endroutine
 

3.  In the Details Group Box, select the field EMPNO and change its ReadOnly property to true.

4.  Create a click event for the SAVE push button. Add code to update all fields in the file PSLMST. Check the I/O status and issue a message the status is not OK. Your code could look like the following

Evtroutine Handling(#SAVE.Click)
Update Fields(*all) In_File(pslmst) Val_Error(*next)
If_Status Is(*OKAY)

Else

Message Msgtxt(
'Error occured on Employee update')
Endif

Endroutine

 

     Note: The UPDATE statement has no With_Key() parameter. It is updating the 'last record read'. The LANSA cross update check will be applied, to prevent an update if the record changed since it was read.

5.  Compile and test your form. You should be able to update an employee. Validation errors will highlight fields and display messages in the Status Bar.