Cobol Programs to implement endpoint

Copybooks:

working-storage

wsjson.cpy - contains variables used by endpoints, to format json, and for CRUD functions

procedure division

json.cpy - contains routines to format json, and also to handle file errors (similar to allerr.cpy but returning the file error to the calling program in json).

 

 

In Program:

  1. set GRAPHICAL-SCREEN-SW = “Y” even though we aren’t using graphical screens; this suppresses the character based displays that still exist in some programs

  2. set AUTOMATED-RUN = “Y” - this tells any called programs not to try to display messages to a non-existent window

  3. use WSJSON.CPY in working storage, and JSON.CPY in the procedure division

  4. routine PRINT-RECORD builds one record and exports it to json; it calls paragraph GENERATE-RECORD-JSON, which is where you put the specific fields to be returned and format them, if necessary

  5. if you are returning two types of data, as with get_po, where we return the header data for the PO and then an array of the lines, we do the header data in a separate paragraph, and use GENERATE-RECORD-JSON to generate the repeating data in the array.

  6. You need to put the “[“ and “]” characters to indicate the beginning and end of array data manually

  7. paragraphs ADD-RECORD and ADD-NUMERIC-RECORD are used to add data to the output string

  8. paragraphs ADD-LAST-RECORD is used for the final output in a json string

  9.