Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using reserved cobol names in xml output

I am working on a project where I will read an xml file from disk that a cobol mainframe system has created. I want a specific naming struture in this xml file like this:

<Orders>
 <Order>
  <Data>
   ...
  </Data>
 </Order>
 <Order>
  <Data>
   ...
  </Data>
 </Order>
 <Order>
  <Data>
   ...
  </Data>
 </Order>
</Orders>

The issue I have learned with this naming structure from my cobol developer is that "Order" and "Data" are reserved names in cobol so he says they cannot be used. Is this really the case or could someone point us in a direction where our xml output can be anything we want when cobol is creating the xml file?

like image 827
Daniel Söderberg Avatar asked Mar 03 '23 18:03

Daniel Söderberg


1 Answers

IBM Enterprise COBOL has an XML GENERATE statement which is used to generate XML from COBOL data structures. The generated tag names are, by default, the names of the data items in the structure. The name of a data item cannot be a reserved COBOL word.

Since version 5 of IBM Enterprise COBOL there is a mechanism to generate tag names for data items that are not the name of the data item. It is the NAME phrase of the XML GENERATE statement.

A structure that looks like this...

01  WS-ORDERS.
    05  WS-ORDER OCCURS 2.
        10  WS-DATA    PIC X(4096).

...processed via XML GENERATE would normally result in...

<WS-ORDERS><WS-ORDER><WS-DATA>...</WS-DATA></WS-ORDER><WS-ORDER><WS-DATA>...</WS-DATA></WS-ORDER></WS-ORDERS>

...but using the NAME phrase...

XML GENERATE WS-BUFFER FROM WS-ORDERS
  NAME WS-ORDERS 'ORDERS'
       WS-ORDER  'ORDER'
       WS-DATA   'DATA'
END-XML

...should give you what you want. That's just freehand, but I think you can see the idea.

It's possible your COBOL compiler hasn't been upgraded to a version that supports the NAME phrase of XML GENERATE. The last such version is 4.2, which goes out of service on 30-Apr-2022.

like image 104
cschneid Avatar answered Mar 10 '23 23:03

cschneid