This section contains an overview of how to implement Spool2XML in InterFormNG2 for a single report.
1.Select (and/or create) another library for the converted printer files than the library, that contains your normal printer files. You should NOT use the IFORMNG2 library for any of your own objects including the converted printer files. We can create such a library with the command, CRTLIB PRTF_HIGH, but you can freely select the library name.
2.Next you need to convert the printer file for your choice into the new library with the command, IFORMNG2/CVTPRTFXML.
3.Now you should have a new printer file in the TOFILE library setup in the command.
4.Now change the library list of a print job and insert the new library above the library, that contains the normal printer file. Then you should request a print out like normal. Now you should see, that the contents of the generated spooled file looks like an XML file like below:
<RECH>
<FILESET>SAMPLE </FILESET><!-- FILE SET -->
</RECH>
<REC0>
<LETTER1>F</LETTER1><!-- FIRST LETTER OF FILE SET -->
</REC0>
<REC1>
<LETTER1>F</LETTER1>
<FMTNVN>FORM1 </FMTNVN><!-- Format name -->
The structure of the contents is build up of two kind of nodes:
a) There are nodes, that indicate a format. These are the nodes, where the start tag is on a different line than the end tag. In the example above the <RECH>, <RECH0> and <RECH1> nodes all refers to a format, while the other nodes refer to fields within the open format.
The XML contents is different compared to the normal print out in these ways:
•No positioning is kept. There is always one field or format reference per line.
•No text constants are included - only variable data.
5.Now you need to setup an output queue to be monitored by IFORMNG2. This is setup in order to convert the XML spooled file into a real XML file (e.g. in the IFS), that can be processed in InterFormNG2. This is setup via option 1. Work with monitored output queues on the IFORMNG2/IFORMNG2 menu. You need to ensure, that the XML spooled file is generated on (or moved to) a monitored output queue. Initially you can setup the output queue to call the IFORMNG2/XML_INBOX program to create the XML files in the IFS inside the directory, /IFormNG2/InterFormNG-shell/user/inbox, but you can copy the source of this program to your own library and here change the program to move the XML files to another directory. Later you can consider to call a workflow via the IFORMNG2/NG2CMD command as shown in the demo source, XML_NG2CMD inside IFORMNG2/APISRC.
6.In the setup in 1. Work with monitored output queues it is suggested to hold (or delete) the input spooled files after processing in order to make it clear, if a spooled file has been processed or not.
7.When you have confirmed, that the XML file is generated in the IFS whenever an XML spooled file arrives on the monitored output queue, then you can focus on the tree structure of the XML file, which is setup as the fragment option on either the monitored output queue or on the converted printer file in option 2. Work with XML definitions. Here you should consider the option 3=Treebuilder to eliminate all duplicates. The tree structure however only includes nodes of the selected tree. 3=Treebuilder can only be setup on the XML definition.
8.The final part of Spool2XML is to ensure, that you setup the right structure of the parent/child relationships for all the formats. In short it is a good idea to first identity the main format (the format, that contains the document number) and then set all of the other formats to be children of this main format. You can add multiple levels e.g. having multiple header record formats, a main detail format and e.g. multiple sub-detail formats within the main detail format.
9.You should probably iterate a few times until you get the right setup: Setup the XML definition, process an XML spooled file and repeat until the structure of the XML file is good.
10.The header of the XML file looks like this and it contains various information about the original spooled file:
These nodes are explained in the section, Jobinformation subtree.
Now we can continue to process the XML files in InterFormNG2.