There are two copybooks that handle the basic Browse, Read, Add, Edit and Delete functions - api-read.cpy and ws-api.cpy.
In “api-read”, there is one entry point, “read-functions”, which accepts inputs for the function type (only options are R, E, A, D), the value of the primary key (used for the edit, add, and delete functions), which key to use (optional, used for the read function), and the values for the first and last key values (again, for the read). If only the first-key is specified, with no last-key, then only one record will be returned.
In the main program for the file to be maintained:
include WSAPI.CPY copybook in working storage, and the READ-API.CPY in the procedure section.
The main section of the program will be very simple:
move menu-number to ws-menu-value - menu-number is the value of the permissions table for the appropriate option in Rx-Universe
perform READ-functionsthe specific program will contain paragraphs specific to the file:
open-files
close-files
start-file (which should use the appropriate key and first/last key values)
read-record (which should use the appropriate key and first/last key values)
read-next-record
write-record
rewrite-record
remove-record (for deleting)
process-label-array - unique to each file, populates the record with values from the API argument file
validate-record
generate-record-json - creates the response, which will be different for each file because of the different record contents