Skip to main content

[archive] output simple xml file

  • September 30, 2008
  • 15 replies
  • 0 views

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?

15 replies

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Attached is a sample that I found. It is not a polished application but it shows how to create and write all the parts of the XML file using C$XML. This sample is provided without warrantee.

The program was generated from an AcuBench project. Let me know if you want the .psf and other pieces.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Attached is a sample that I found. It is not a polished application but it shows how to create and write all the parts of the XML file using C$XML. This sample is provided without warrantee.

The program was generated from an AcuBench project. Let me know if you want the .psf and other pieces.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Attached is a sample that I found. It is not a polished application but it shows how to create and write all the parts of the XML file using C$XML. This sample is provided without warrantee.

The program was generated from an AcuBench project. Let me know if you want the .psf and other pieces.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Thats great, thanks very much. Unfortunately C$XML doesn't do writes in version 6.1.1, only reads. Is there anyway to accomplish this without using C$XML?

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
You may be able to achieve what you need with AcuXML

AcuXML enables the Runtime to create an XML file from a standard COBOL file definition. See the AcuCOBOL-GT User's Guide, Section 6.11.3 and onward for the documentation on AcuXML. In a nutshell, compile with -Fx to generate an extended file descriptor (XFD) then set the Runtime configuration "filename_host XML".

Note that not all COBOL files translate well into XML and not all XML files translate well into COBOL files. This is a very basic interface but it is worth a try.

I highly recommend that you upgrade so you can take advantage of the more powerful C$XML library routine.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
I tried like crazy to get this to work, but all I ended up getting was a plain sequential file with no xml tags... I must be doing something wrong. post of the code maybe somethign jumps out at someone.


**** The Select

       SELECT OPTIONAL XML-FILE
                  ASSIGN TO RANDOM, "/tmp/test.xml"
                  ORGANIZATION IS LINE SEQUENTIAL
                  ACCESS MODE IS SEQUENTIAL
                  FILE STATUS IS XML-STAT.

***** The FD

      $XFD FILE=xmlfile
       FD  XML-FILE LABEL RECORDS ARE STANDARD.
       01  XML-RECORD.
           03 XML-FIELD-1          PIC 9(8).
           03 XML-FIELD-2          PIC X(40).


***** Main code
       A000-MAIN SECTION.
       A000-START-PROGRAM.
           SET ENVIRONMENT "PROG-NAME" TO "XMLWRITE".
           SET ENVIRONMENT "xmlfile_HOST"         TO "XML".
           SET ENVIRONMENT "4GL_COLUMN_CASE"      TO "UNCHANGED".
           OPEN OUTPUT XML-FILE.
           MOVE 98765432        TO XML-FIELD-1.
           MOVE "Testing 1 2 3" TO XML-FIELD-2.
           WRITE XML-RECORD.
           CLOSE XML-FILE.
       A000-EXIT.
           GOBACK.


**** Generated XFD file
# xmlfile.xfd - generated by ACUCOBOL-GT v6.1.0 ECN-3311
# Generated Tue Sep 30 13:59:27 2008

# [Identification Section]
XFD,05,XML-FILE,XMLFILE,04
0000000048,0000000048,000
# [Key Section]
# [Condition Section]
000
# [Field Section]
0002,00002,00003,00003
0000000000,0000000048,16,0000000048, 00,000,999,01,XML-RECORD
0000000000,0000000008,01,0000000008, 00,000,000,03,XML-FIELD-1
0000000008,0000000040,16,0000000040, 00,000,000,03,XML-FIELD-2


[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
I tried like crazy to get this to work, but all I ended up getting was a plain sequential file with no xml tags... I must be doing something wrong. post of the code maybe somethign jumps out at someone.


**** The Select

       SELECT OPTIONAL XML-FILE
                  ASSIGN TO RANDOM, "/tmp/test.xml"
                  ORGANIZATION IS LINE SEQUENTIAL
                  ACCESS MODE IS SEQUENTIAL
                  FILE STATUS IS XML-STAT.

***** The FD

      $XFD FILE=xmlfile
       FD  XML-FILE LABEL RECORDS ARE STANDARD.
       01  XML-RECORD.
           03 XML-FIELD-1          PIC 9(8).
           03 XML-FIELD-2          PIC X(40).


***** Main code
       A000-MAIN SECTION.
       A000-START-PROGRAM.
           SET ENVIRONMENT "PROG-NAME" TO "XMLWRITE".
           SET ENVIRONMENT "xmlfile_HOST"         TO "XML".
           SET ENVIRONMENT "4GL_COLUMN_CASE"      TO "UNCHANGED".
           OPEN OUTPUT XML-FILE.
           MOVE 98765432        TO XML-FIELD-1.
           MOVE "Testing 1 2 3" TO XML-FIELD-2.
           WRITE XML-RECORD.
           CLOSE XML-FILE.
       A000-EXIT.
           GOBACK.


**** Generated XFD file
# xmlfile.xfd - generated by ACUCOBOL-GT v6.1.0 ECN-3311
# Generated Tue Sep 30 13:59:27 2008

# [Identification Section]
XFD,05,XML-FILE,XMLFILE,04
0000000048,0000000048,000
# [Key Section]
# [Condition Section]
000
# [Field Section]
0002,00002,00003,00003
0000000000,0000000048,16,0000000048, 00,000,999,01,XML-RECORD
0000000000,0000000008,01,0000000008, 00,000,000,03,XML-FIELD-1
0000000008,0000000040,16,0000000040, 00,000,000,03,XML-FIELD-2


[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
I tried like crazy to get this to work, but all I ended up getting was a plain sequential file with no xml tags... I must be doing something wrong. post of the code maybe somethign jumps out at someone.


**** The Select

       SELECT OPTIONAL XML-FILE
                  ASSIGN TO RANDOM, "/tmp/test.xml"
                  ORGANIZATION IS LINE SEQUENTIAL
                  ACCESS MODE IS SEQUENTIAL
                  FILE STATUS IS XML-STAT.

***** The FD

      $XFD FILE=xmlfile
       FD  XML-FILE LABEL RECORDS ARE STANDARD.
       01  XML-RECORD.
           03 XML-FIELD-1          PIC 9(8).
           03 XML-FIELD-2          PIC X(40).


***** Main code
       A000-MAIN SECTION.
       A000-START-PROGRAM.
           SET ENVIRONMENT "PROG-NAME" TO "XMLWRITE".
           SET ENVIRONMENT "xmlfile_HOST"         TO "XML".
           SET ENVIRONMENT "4GL_COLUMN_CASE"      TO "UNCHANGED".
           OPEN OUTPUT XML-FILE.
           MOVE 98765432        TO XML-FIELD-1.
           MOVE "Testing 1 2 3" TO XML-FIELD-2.
           WRITE XML-RECORD.
           CLOSE XML-FILE.
       A000-EXIT.
           GOBACK.


**** Generated XFD file
# xmlfile.xfd - generated by ACUCOBOL-GT v6.1.0 ECN-3311
# Generated Tue Sep 30 13:59:27 2008

# [Identification Section]
XFD,05,XML-FILE,XMLFILE,04
0000000048,0000000048,000
# [Key Section]
# [Condition Section]
000
# [Field Section]
0002,00002,00003,00003
0000000000,0000000048,16,0000000048, 00,000,999,01,XML-RECORD
0000000000,0000000008,01,0000000008, 00,000,000,03,XML-FIELD-1
0000000008,0000000040,16,0000000040, 00,000,000,03,XML-FIELD-2


[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
The _HOST specification must use the disk name of the file.

So this:

SET ENVIRONMENT "xmlfile_HOST" TO "XML".

Should be this:

SET ENVIRONMENT "test_HOST" TO "XML".

Alternately, you could set the default host:

SET ENVIRONMENT "DEFAULT_HOST" TO "XML".

Beware, though, as the Runtime will then treat all files as xml.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Thanks Doug, I appreciate your time with this.

I got a little further but now I just get a 9D,2 status when I open output the file. Is there something else that needs to be installed? I'm running this with 6.1.1 runtime on a SCO unix server at version 3.2v5.0.7...

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
9D,2 means the XFD has been corrupted.

Replace it with a newly generated one (compile with -Fa) and the program should run without error.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
9D,2 means the XFD has been corrupted.

Replace it with a newly generated one (compile with -Fa) and the program should run without error.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
9D,2 means the XFD has been corrupted.

Replace it with a newly generated one (compile with -Fa) and the program should run without error.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
Gave that a go and still same error... where does the xfd file need to be located in the FILE-PREFIX path or the CODE-PREFIX path? I'm thinking it just can't find it... currently sitting in the same directory as my code.

[Migrated content. Thread originally posted on 29 September 2008]

Does anyone have a sample program that outputs some simple data in XML format?
You would probably be getting a different error (9D,03) if the runtime couldn't find the XFD.

Knowledge base article 25287,
http://supportline.microfocus.com/mf_kb_display.asp?kbnumber=25287 ,
has instructions for executing your program with a trace. You should do that then examine the trace file for clues.

If the cause is not apparent and you have a current support contract you can open a Support Incident and submit the program and trace file.