Message conversion example
The code in this example describes the conversion of an XML input message to COBOL and its COBOL response message to XML.
Below is an example of an XML message on input:
<INPUTMSG><in_ll>32</in_ll><in_zz>0</in_zz>
<in_trcd>IVTNO</in_trcd><in_cmd>DISPLAY</in_cmd>
<in_name1>LAST1</in_name1></INPUTMSG>
Below is an example of the same message after the XML data structure has been converted to the COBOL data structure required by the COBOL phone book application program:
IVTNO DISPLAY LAST1
IVTNO
starts
in the fifth byte. The first four bytes are used by IMS Connect, and there are five spaces following LAST1
.The first four bytes of the data structure message, known as LLZZ, will be filled by the XML adapter. The first two bytes, the LL part, will be filled with the length of the data structure message. The second two bytes, the ZZ part, will be filled with zeroes. The XML converter converts the XML message to the application-specific format by taking the value within each XML tag, and placing it in its corresponding field position. The converted message can then be processed by the COBOL application and it returns an output message in its specific data structure. The output message has to be converted to XML before it is returned back to the Client. Below is an example of an output message and the message after XML conversion.
Below is an example of the COBOL data structure of the reply message on output from the IMS data store:
ENTRY WAS DISPLAYED DISPLAY LAST1 FIRST1 8-111-1111D01/R010001
In the above example, the text on the first line of the output message begins at the fifth byte, after the four byte LLZZ field.
<cbl>
<out_ll> 093</out_ll><out_zz> 000</out_zz>
<out_msg>ENTRY WAS DISPLAYED</out_msg><out_cmd>DISPLAY</out_cmd>
<out_name1>LAST1</out_name1><out_name2>FIRST1</out_name2>
<out_extn>8-111-1111</out_extn><out_zip>D01/R01</out_zip>
<out_segno>0001</out_segno></cbl>
In the example above, the values following the opening XML tags <out_ll> and <out_zz> tags are from the first four bytes of the output COBOL data structure message.
For outbound messages from the IMS application, the conversion is performed in reverse. Each field in the application data structure is wrapped in its corresponding XML tags. This conversion from an XML to a COBOL application data structure message format, and vice versa, is performed by the COBOL XML converter called by the XML adapter.