Customize Copybook

RESTConnector comes with a default tableBASE table called APICONFG, which stores configuration information of three built-in API types:

| API Type | Command | Function |
| API001   |    FK   | Get a single record |
| API002   |    FG   | Get multiple records using a generic key |
| API003   |    FG   | Get multiple records, returned as hexadecimal data |

Every copybook follows a common structure: a standard header (request fields like IN-APIKEY, IN-TABLE-NAME, IN-VTS-NAME, plus pagination fields IN-OFFSET and IN-LIMIT, and response and error fields like OUT-TOTAL-RECS, OUT-ERROR-CODE, etc.), followed by a data area (WS-ROW-DATA) that the API designer fills in to match the actual table layout. The data area differs by API type:

Single record (API001): WS-ROW-DATA is a single occurrence.

Multiple records (API002): WS-ROW-DATA OCCURS 100 TIMES — up to 100 records per call, with IN-OFFSET and IN-LIMIT controlling pagination.

Multiple hexadecimal records (API003): same repeating structure, with data returned as a raw hex field (CA-DATA).

Here are examples of COBOL copybook layouts for single and multiple record retrieval.

******************************************************************
*** TABLEBASE API INTERFACE COPYBOOK FOR SINGLE RECORD         ***
******************************************************************
    *
     01 WS-ROW-AREA.
       03 WS-ROW-HEADER.
    * API Common request - response area
         05 IN-API-KEY PIC X(9).
         05 IN-TABLE-NAME PIC X(8).
         05 IN-VTS-NAME PIC X(8).
         05 IN-OFFSET PIC S9(9) COMP.
         05 IN-LIMIT PIC S9(9) COMP.
         05 OUT-TOTAL-RECS PIC S9(8) COMP.
         05 OUT-RECS-THIS-CALL PIC S9(8) COMP.
         05 OUT-REC-SIZE PIC S9(8) COMP.
         05 OUT-ERROR-CODE PIC S9(8) COMP.
         05 OUT-ERROR-SUB-CODE PIC S9(8) COMP.
         05 OUT-RESPONSE-MESSAGE PIC X(80).
         05 OUT-FILLER PIC X(67).
     * API SPecific area
       03 WS-ROW-DATA.
         05 CA-DATA PIC X(32000). <- your data layout
******************************************************************
*** TABLEBASE API INTERFACE COPYBOOK FOR MULTIPLE RECORDS      ***
******************************************************************
    *
     01 WS-ROW-AREA.
       03 WS-ROW-HEADER.
    * API Common request - response area
         05 IN-API-KEY PIC X(9).
         05 IN-TABLE-NAME PIC X(8).
         05 IN-VTS-NAME PIC X(8).
         05 IN-OFFSET PIC S9(9) COMP.
         05 IN-LIMIT PIC S9(9) COMP.
         05 OUT-TOTAL-RECS PIC S9(8) COMP.
         05 OUT-RECS-THIS-CALL PIC S9(8) COMP.
         05 OUT-REC-SIZE PIC S9(8) COMP.
         05 OUT-ERROR-CODE PIC S9(8) COMP.
         05 OUT-ERROR-SUB-CODE PIC S9(8) COMP.
         05 OUT-RESPONSE-MESSAGE PIC X(80).
         05 OUT-FILLER PIC X(67).
     * API SPecific area
       03 WS-ROW-DATA OCCURS 100 TIMES.
         05 CA-DATA PIC X(32000). <- your data layout