In this step you will create a server module for the xTasks table.
1. In the File menu, choose New -> Server Module.
2. Do not specify a table for the server module.
3. In the Source tab of the server module, replace the Begin_Com and End_Com statements with the code below.
* server module definition
* the SessionIdentifier
property lets server modules interact with each other, and provides a boundary
so that sets of server modules can execute discretely.
Begin_Com
Role(*EXTENDS #PRIM_SRVM)
SessionIdentifier('EO1SESSION')
* create a list and a
group for columns in xTask
Def_List Name(#List) Fields(#xTaskId #xTaskName
#xTaskDescription #xTaskLastModified) Type(*WORKING) Entrys(*MAX)
Group_By
Name(#Fields) Fields(#xTaskId #xTaskName #xTaskDescription #xTaskReason
#xTaskPriority #xTaskOwner #xTaskStatus #xTaskCreated
#xTaskLastModified)
* fill list with data from
xTask
Srvroutine Name(Find) Session(*REQUIRED)
List_Map For(*OUTPUT)
List(#List)
Select Fields(#List) From_File(xtask) Io_Error(*NEXT)
Val_Error(*NEXT)
Add_Entry To_List(#List)
Endselect
Endroutine
*
get details for a task
Srvroutine Name(Read) Session(*REQUIRED)
Field_Map
For(*INPUT) Field(#xTaskId)
Group_Map For(*OUTPUT) Group(#Fields)
Fetch
Fields(#Fields) From_File(xtask) With_Key(#xTaskId) Io_Error(*NEXT)
Val_Error(*NEXT)
Endroutine
* save changes to a task
Srvroutine
Name(Save) Session(*REQUIRED)
Group_Map For(*INPUT)
Group(#Fields)
Field_Map For(*OUTPUT) Field(#STD_CODE)
Parameter_Name(ReturnCode)
Update Fields(#Fields) In_File(xtask)
With_Key(#xTaskId) Io_Error(*NEXT) Val_Error(*NEXT)
If_Status
Is(*NORECORD)
Insert Fields(#Fields) To_File(xtask) Io_Error(*NEXT)
Val_Error(*NEXT)
Endif
If_Status Is(*OKAY)
#STD_CODE :=
"OK"
Else
#STD_CODE := "ER"
Endif
Endroutine
* save a
task
Srvroutine Name(Delete) Session(*REQUIRED)
Field_Map For(*INPUT)
Field(#xTaskId)
Delete From_File(xtask) With_Key(#xTaskId) Io_Error(*NEXT)
Val_Error(*NEXT)
Endroutine
End_Com
4. Compile the server module.