Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Save srvroutine in the server module, xDepartmentsDataServer has the following logic:

     Srvroutine Name(Save)
     Group_Map For(*INPUT) Group(#xDepartments)
     Field_Map For(*OUTPUT) Field(#io£sts) Parameter_Name(Status) 

     *Look for an existing record
     Check_For In_File(xDepartments) With_Key(#xDepartmentCode)

...

     *Update the record if found, otherwise create a new one
     If_Status Is(*EQUALKEY)

   

...

      Update Fields(#xDepartments) In_File(xDepartments) With_Key(#xDepartmentCode)

 

...

        Else

 

...

        Insert Fields(#xDepartments) To_File(xDepartments)

 

...

        Endif

 

...

        Endroutine

The Check_For command has a number of other parameters which handle an error and messages. This simple example returns a status code into field IO$STS. As explained earlier, the parameter IO_Status(*status) defines this behavior.

...

1.  Execute your web page and fetch an existing record with a code of 100, 200, or 1000 for example. Change description and click Save. Fetch the same record to confirm the update.

...

     Your code should look like the following:

     . . .
     Evtroutine Handling(#FindDepartment.Completed)
     If (#IO£STS = OK)
     #xDepartmentCode.enabled := false
     Endif
     Endroutine
     . . .

4.  Change the Save method to set the field xDepartmentCode's Enabled property to True, if the record was saved.

     . . .
     Evtroutine Handling(#SaveDepartment.Completed)
     If (#IO£STS = OK)
     #xDepartments := *default
     #COM_OWNER.Errors( True )
     #xDepartmentCode.Enabled := true
     Else
     #COM_OWNER.Errors( False )
     Endif
     Endroutine
     . . .

5.  Compile and test your web page. Ensure that this change is working correctly.