How to create CRUD non DC1 API?
The example programs can be found in the QSAMPLES source file and they are delivered together with Aperio. CRUD operations are performed over file FILE01.
DSRE02 - black box program for validation incoming data and maintaining the file.
EXAMPLE030 getting a list of records
EXAMPLE031 getting one record
EXAMPLE032 adding new record
EXAMPLE033 record update
EXAMPLE034 record deletion
Black box program
Data structure for the parameter list for DSRE02 is based on file DSLE02. Database fields in DSLE02 (ones that correspond to fields from FILE01) should be defined with ALWNULL keyword, so the program can check if the value is passed (null indicator off).
*ALWNULL(USRCTL) must be specified on the H-Spec of all programs, to process or define null capable fields.
Modes to call DSRE02 program:
- ADD
- UPDATE
- GET
- DELETE
- CLRNULLOFF Clear parameters, set null indicators for null capable fields to off
- CLRNULLON Clear parameters, set null indicators for null capable fields to on
Depending on modes DSRE02 program returns record’s data and proper return code. Return codes:
- ’ ’ - no errors
- ‘NF’ - no record was found
- ‘ER’ - errors appeared
- ‘EV’ - errors during validation
Call stack entry parameter is used for message handling and is set in the calling program. Description of procedures used for message handling can be found here:
How to set message file in Aperio
Example:
How to send messages in Aperio
Example:
API programs
- Aperio documentation tags should be added at the beginning of the program:
- First call DSRE02 with mode CLRNULLON to clear data structure and set null indicators.
- Then get the parameters and set off corresponding null indicators. If a parameter is absent in the AIP call, its null indicator remains on.
- Then set mode and call DSRE02 again. If any error appears, gather error messages using Aperio procedure respAddPgmMessages, else prepare response data.
How to receive messages in Aperio
- To implement sorting of the list of records (EXAMPLE025) add “order by” fields to the compile-time array.
The details about procedures used for implementing sorting are describe in FAQ: How to implement sorting