Highlighted
Absent Member.
Absent Member.
718 views

How can I update a xml document with cobol? When I use this code I get file-status -10

       FILE SECTION.
       XD XML-STREAM.
       01 XML-REC       IDENTIFIED BY "envelope".
       02 body          IDENTIFIED BY "body".      
       03 FILLER        IDENTIFIED BY "werkgevers"
                        OCCURS 20 TIMES
                        COUNT IN werkgevers-COUNT.
       04 FILLER        IDENTIFIED BY "werkgever".
       05 FILLER        IDENTIFIED BY "identificatie".
       06 FILLER        IDENTIFIED BY "werkgeversnummer"
                        PIC X(4).
       05 FILLER        IDENTIFIED BY "salef".
       06 FILLER        IDENTIFIED BY "ingangsjaar"
                        pic x(4).
       06 FILLER        IDENTIFIED BY "ingangsmaand"
                        pic x(2).
       06 regel         IDENTIFIED BY "salefregel"
                        pic x(80).
       WORKING-STORAGE SECTION.
       01  XML-STATUS     PIC S9(9) COMP.
       01  WSNAAM         PIC X(050).
       PROCEDURE DIVISION.
           MOVE 'n1772170907m.xml' TO WSNAAM.
           OPEN i-o XML-STREAM.
           DISPLAY 'XML-STATUS: ' XML-STATUS.
           READ XML-STREAM
           DISPLAY 'XML-STATUS: ' XML-STATUS.
           REWrite XML-REC key body
           DISPLAY 'XML-STATUS: ' XML-STATUS.
           CLOSE XML-STREAM.
           DISPLAY 'XML-STATUS: ' XML-STATUS.
           .
           GOBACK.

XML-STATUS: +000000000
XML-STATUS: +000000001
XML-STATUS: +000000000
XML-STATUS: -000000010
Tags (3)
0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: How can I update a xml document with cobol? When I use this code I get file-status -10

A file status -10 on an xml file means:
10 The internal DOM representation is not written out to any XML stream and has been cleared after a READ statement or a CLOSE statement.

The docs for the REWRITE KEY state the following:

1. No stream I/O is performed by the REWRITE verb.
2. REWRITE KEY IS updates the in-memory representation of the elements and child elements associated with data-name-1. All other elements in the in-memory representation remain unchanged.
3. If the internal representation of the XML document is modified through the use of WRITE KEY, REWRITE KEY, or DELETE KEY, and the internal representation is cleared with either a CLOSE or READ (no key) statement, then the CLOSE or READ statement returns a status of -10, indicating the operation succeeded but no write was done.

This is telling you that the statement was successful but you haven't actually written the changes to disk yet since the REWRITE only changes the internal representation.

Use the WRITE statement without the KEY clause to actually update the file prior to closing it.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: How can I update a xml document with cobol? When I use this code I get file-status -10

Thank you Chris.
it is necessary to define all tags even if you only update a few tags.
0 Likes
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.