Add Operation Logic to BookREST

Guides you through the process of adding logic to the BookREST program to process GET and PUT requests, and then building the project in Visual Studio.

The generated skeleton program, BookREST.cbl, contains some basic functionality that is common to any CICS Web service that uses the Channel interface, such as:

  • It retrieves the type of request being made from the DFHHTTPMETHOD container, and evaluates it.
  • For a GET request, it populates the DFHWS-DATA container with the content of the response data structure (in film01.cpy).
  • For a PUT request, it populates the request data structure (in BookR01.cpy) with the contents of the DFHWS-DATA container.

Add operation logic

To provide the required operation logic, you must code it manually by editing the program.

  1. From the Solution Explorer, double-click BookREST.cbl to open it in the COBOL editor.
  2. Declare the following two variables in the working-storage section:
    01 ws-function                 pic x.
    01 ws-file-status              pic xx value "00".
  3. Scroll down to the when "GET" statement, and add the following lines between it and the move "DFHWS-DATA" to ls-container-name statement:
                   initialize lnk-b-details
                   move "1" to ws-function
                   move ls-uri-resid to lnk-b-stockno
                   call "book" using ws-function
                                     lnk-b-details
                                     ws-file-status
    Note: BookREST.cbl contains a comment line between the two statements. You can replace the comment line with this block of code.
  4. At the next commented line below an EXEC CICS GET statement, add the following lines to create a new record:
                   move "2" to ws-function
                   call "book" using ws-function
                                     lnk-b-details
                                     ws-file-status
  5. Near the bottom of the program, in the second move statement in the put-DFHRESPONSE paragraph, replace the ls-uri-resid variable with the ws-file-status variable.
  6. Click File > Save BookREST.cbl.
  7. Close the COBOL editor.

Build the BookREST project

  • From the Solution Explorer, right-click the BookREST project; then select Build.