In this section you will implement the interface methods prototyped in IUpdatable.cls.

To add the interface methods:

  1. Add a variable definition for fRecordState and fServiceAdapater with the other variable definitions that appear after the opening CLASS statement. The variable definition appears in bold in the following example:
    CLASS openedge.tutorial.ui.purchaseOrderForm INHERITS Form IMPLEMENTS 
    IUpdatable  : 
        DEF PRIVATE VAR fRecordState AS CHARACTER NO-UNDO.	    
        DEF PRIVATE VAR components AS System.ComponentModel.IContainer.
        DEF PRIVATE VAR fServiceAdapter AS 
    openedge.tutorial.services.ServiceAdapter NO-UNDO.
  2. With purchaseOrderForm.cls open in the ABL Editor, replace the addRecord(), deleteRecord(), saveRecord(), and cancelUpdate() methods with the following code:
    METHOD PUBLIC VOID AddRecord():
            fServiceAdapter:addRecord
            (bindingSource1:Handle:get-buffer-handle('ePurchaseOrder')).
            fRecordState = 'ADD':u.
            btnSave:Enabled = TRUE.
            btnCancel:Enabled = TRUE.
    END METHOD.
    METHOD PUBLIC VOID DeleteRecord():
            fServiceAdapter:removeRecord
            (bindingSource1:Handle:get-buffer-handle('ePurchaseOrder')).
            fServiceAdapter:SaveData().
            bindingSource1:RefreshAll().        
    END METHOD.
    METHOD PUBLIC VOID SaveRecord():
            IF fRecordState NE '':u OR bindingSource1:RowModified THEN
            DO:
               IF bindingSource1:RowModified THEN
                bindingSource1:Assign().
                fServiceAdapter:SaveData().
                btnSave:Enabled = FALSE.
                btnCancel:Enabled = FALSE.
            END.        
    END METHOD.
    METHOD PUBLIC VOID CancelUpdate():
           fRecordState = '':u.
    	       fServiceAdapter:CancelUpdate
           (bindingSource1:Handle:get-buffer-handle('ePurchaseOrder')).
           bindingSource1:RefreshAll().
           btnSave:Enabled = FALSE.
           btnCancel:Enabled = FALSE.        
    END METHOD. 

    This step replaces the stub code for the interface methods defined in IUpdateable.cls. Stub code for interface methods is automatically generated. This allows class files that implement interfaces to compile even though you have not implemented the interface methods.