Copybook To Code – With Pictures!!



Above is a logical diagram of CopybookToCode.  There are lots of things wrong with it, (besides the clashing colors): for example, how I overlaid CWS with zOS TCP/IP; I am sure IBMers in both camps would object.  Or how I represented the executable JavaScript code and the HTML files in HB.js.  So I will say it again: this is a logical diagram, not a technical diagram (Russ, don’t stress, it will be okay).  In my mind when I visualize how this stuff works, this is how I see it (notice how the Java box has sharp edges).  All I want to do here is communicate what parts are involved and the flow among them.

It all starts with the customer’s need to invoke a COMMAREA program or read a VSAM file or process any buffer described by a COBOL copybook.

  1. Customer downloads the COBOL copybook (or copybooks if the input COMMAREA is different from the output COMMAREA) from the host to their PC and navigates to the CopybookToCode web page (go ahead and click on it, you can’t hurt it).
  2. The request for the web page flows through our firewall and to a Microsoft IIS server that acts as a proxy and redirects the request to our mainframe.  The only thing the IIS system does is port translation from the standard HTTP port (80 or 443) to the port our CICS system is listening on.  The web page is actually served out of HB.js running inside CICS on our z/OS system.
  3. The customer selects the copy book from his file system and clicks Generate and then magic happens. (I really do think it is magic, how all of these disparate technologies and systems work quickly and reliably together. I’m amazed every day.  Of course I can also spend hours looking at a burning candle.)
  4. The HB.js JavaScript engine is invoked by CICS Web Support (CWS) and the compiled JavaScript CopybookToCode is loaded from the VSAM script repository and launched.
  5. The script pulls apart the POSTed html mime multi-part message into the various named value pairs and the uploaded files.
  6. It then creates a Channel with a Container that has the copybook.  The CB2XML Java program is invoked with the Channel and does its thing of generating XML that represents the copybook.
  7. CopybookToCode regains control and begins processing against the XML.  A 24 byte character string is generated in the JavaScript for each field describing all aspects of the field.  It turns out there are not all that many distinct COBOL data types (if you don’t consider the exotic types like XML).  Character, group (which I treat like character), binary, COMP-3 (packed decimal), zoned, float and double – everything else is pretty much a variation of one of these.  When supplied with the field name and any indexes, using the 24 byte string, I can calculate where a field is located in the buffer and how to retrieve/set it.  The 24 byte string contains:
    • 1 byte for the data type
    • 1 byte for signed
    • 1 byte for precision
    • 1 byte for scale
    • 4 bytes for length
    • 4 bytes for position (offset within group), the actual offset within the buffer has to be calculated based on occurs for this field and containing groups.
    • 4 bytes for OCCURS
    • 4 bytes for parent/group OCCURS
    • 4 byte pointer to the parent group
  8. After I make a pass over the XML I end up with a JavaScript reduction of the information that was contained in the XML.  I pass that to a simple JavaScript template creation service I wrote (inspired by mustache) to actually create the generated JavaScript.  This allows me to change the JavaScript that is generated by only changing the template – no code changes.
  9. The generated JavaScript is written to a CICS Temporary Storage Queue (TS Queue)
  10. The 1.1 and 2.0 WSDLs are also generated using the same JavaScript object and different templates and each are written to TS Queues.
  11. Lastly a web page is generated (using the template service) with embedded links that allow the customer to download any of the generated files from the TS Queues, XML, three different JavaScript copybook descriptions, the CB2XML generated XML and the WSDLs.  (This is the part that I am in the process of changing to a single zip with all the files that is automatically downloaded when generation is complete).

Okay, so the title was misleading, there is only one picture.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s