Robert de M Contributor.

File Status in XML - why is it defined as comp?

In all examples (that I've found) in MF documentation about XML syntax extension to COBOL the variable for file-status is in the select (with organization is xml) is defined as s9(9) comp.

Here's a fun trick, stack the xml and procob precompilers, in your procob config file have comp5=yes which is recommended. Procob will worry that your file-status might be used as a host variable and will change it to comp-5. Now if you're using lvl 88 definitions to check your status, eg. 

           88 end-of-file-xml value -7.

    88 not-well-formed-xml value -9.

This will work in Net Express but fail in Visual Cobol.

Back to the question then - why is the status variable defined as pic s9(9) comp in examples? Is something like pic s9(4) comp-5 considered harmful? If yes - why, if no - documentation should be changed to reflect the fact that this may cause unexpected results in some configurations.


1 Reply
Micro Focus Expert
Micro Focus Expert

Re: File Status in XML - why is it defined as comp?

In the rules for the XML I-O Select statement in both Net Express and Visual COBOL it states the following where Data-name-5 is the xml-status:

"Data-name-5 must be declared in the data division as a PIC S9(9) (any usage) and holds the file status for the last I/O operation".

So it can be comp, comp-5, usage display, etc. It just needs to be a signed numeric data item large enough to hold the returned file status.

If you save the post preprocessed source using the o parameter:
     $set preprocess(prexml) o(foo.pp) warn endp

Then you can see the actual source that is compiled.

The definition for the returned file status from the XML I-O statements is:
    05  PREXML--XD-STATUS--0001      PIC S9(9) comp-5

And then this is just moved to whatever you declare as your status code assigned to the XML-STATUS clause.

When you state that it fails in Visual COBOL, what exactly do you mean?


The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.