Add Operation Logic to the invkRevJ.cbl Program

Walks you through the process of analyzing the code in the generated invkRevJ.cbl program, and adding operation logic to the program.

The generated invkRevJ.cbl program should provide the functionality that is required to invoke the reverse service. Any JSON application that uses a linkable interface, including invkRevJ.cbl, is required to do the following:

  • Populate the request structure.
  • PUT that data into a CONTAINER named DFHJSON-DATA.
  • PUT the name of the JSONTRANSFRM resource used to transform the COBOL request data to JSON into a CONTAINER named DFHJSON-TRANSFRM.
  • LINK to DFHJSON, which includes:
    • Locating the appropriate JSBIND file by using the JSONTRANSFRM resource named in the DFHJSON-TRANSFRM CONTAINER.
    • Transforming the content of the DFHJSON-DATA CONTAINER into JSON using the JSBIND file and placing it into the DFHJSON-JSON CONTAINER.
  • SEND the request and RECEIVE the response, which includes:
    • Using WEB OPEN to open a connection to the server hosting the service.
    • Using WEB CONVERSE to SEND the request to the server and RECEIVE the response. This is done by supplying the request message via the DFHJSON CONTAINER and receiving the response message into the same CONTAINER.
    • Using WEB CLOSE to close the connection to the server.
  • PUT the name of the JSONTRANSFRM resource used to transform the JSON response message to COBOL into a CONTAINER named DFHJSON-TRANSFRM.
  • LINK to DFHJSON, which repeats the same procedure as before.
  • Populates the response structure by GETting the content of the DFHJSON-DATA CONTAINER.

Add code

To provide the program with an input and direct the output to your terminal, you must edit the code.

  1. On the Solution Explorer, double-click invkRevJ.cbl to open it in the COBOL editor.
  2. Browse through the code, noting each block of code that corresponds to the JSON application linkable interface requirements.
  3. In the procedure division, ws-op-1 section, replace the comment (******* ...) at line 44 with the following move statement:
    move 'esaelPeMesreveR'      to myString
  4. After the exec cics get container command for DFHJSON-DATA, replace the comment (******* ...) with the following code to send the reversed string back to the terminal:
     exec cics send text
          from(reversedString)
          freekb
     end-exec
  5. Save the program and exit the editor.

Build the invkRevJCICSClientApp project

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

Move the invkRevJ.dll file

Because the invkRevJ.dll file is generated to the ReverseJSON project's invkRevJCICSClientApp\bin\x86\Debug directory, but the output path is set to the ReverseJSON project's loadlib directory, you need to move the file from invkRevJCICSClientApp\bin\x86\Debug directory to the project's loadlib directory so that Enterprise Server finds the correct file.

  1. Using Windows File Explorer or at a command prompt, change to the ReverseJSON project directory.
  2. Copy or move the invkRevJ.dll file from the invkRevJCICSClientApp\bin\x86\Debug directory to the loadlib directory.