Example of using XML output
XML is one of the languages of choice for representing structured data. There are many applications and frameworks supporting input data in the XML format. In this example we are going to extract JALCOMP difference data in the XML format, transfer it to a PC and produce a report in the PDF format.
First, let's run the utility to extract SMF data and format them as XML file. The following JCL was used for this purpose (the example uses SMF record type 222):
//*
//STEP1 EXEC PGM=IFASMFDP,REGION=0M
//DUMPIN DD DISP=SHR,DSN=SYS1.MANG
//DUMPOUT DD DSN=&&SMF,DISP=(,PASS),UNIT=SYSDA,
// SPACE=(CYL,(10,10),RLSE)
//SYSPRINT DD SYSOUT=*
INDD(DUMPIN,OPTIONS(DUMP))
OUTDD(DUMPOUT,TYPE(222))
//*
//STEP2 EXEC PGM=DTMFSMJ7,REGION=0M,TIME=1440,
// COND=(4,LE,STEP1),
// PARM=(‘F=XML’,
// ‘SMF=222’,
// ‘XML.HEADER=YES’,
// ‘XML.ENCODING=UTF-8’)
//SYSPRINT DD SYSOUT=*
//TMSMFIN DD DISP=(OLD,DELETE),DSN=&&SMF
//TMSMFXML DD DISP=(NEW,CATLG),DSN=EXAMPLE.XML,UNIT=SYSDA,
// SPACE=(CYL,(5,5),RLSE),
// DCB=(DSORG=PS,RECFM=VB,LRECL=512,BLKSIZE=27998)
This job runs the DTMFSMJ7 utility with the following parameters:
defines output format as XML
defines SMF record type number
requests generation of XML header
defines what encoding is going to be specified in the XML header. We chose UTF-8 because we are planning to transfer the output XML file to a PC for further processing.
The job completed with return code zero and the SYSPRINT data set contained the following messages:
Running on May 10,2017 at 10:24:20.
The following parameters were specified:
F=XML
SMF=222
XML.HEADER=YES
XML.ENC=UTF-8
Total number of SMF records processed: 1617
Number of no sub-type records: 2
Number of SMF record of type 222: 1615
... including SUB-type JAL_COMP records: 5
Total number of written records: 293
Processing has been successfully completed.
The SMF file had only 5 records of the type and sub-type we are interested in. It means that the JAL descriptor differences were reported for 5 jobs only. The size of the output XML file was 293 records. For a sample of XML output, please see member JCSMPXML in the TM install data set.
To convert the data to a PDF document we are going to use the xslt translation of our xml file to the xsl:fo directives. These directives will control the creation of the PDF file. Both the xslt translation and interpreting the xsl:fo directives can be performed by an open-source engine called FOP (See https://xmlgraphics.apache.org/fop for details).
For a sample of the xslt / xsl:fo code created specifically for the purpose of this example, please see member JCXLSTFO in the TM install data set.
Assuming our xml file is called test.xml and the xslt / xsl:fo code is in the file test.xsl we can run the FOP engine using the following command:
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #1.
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #2.
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #3.
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #4.
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #5.
May 08, 2017 9:49:41 AM org.apache.fop.events.LoggingEventListener
processEvent INFO: Rendered page #6.
The engine reads the test.xml file we generated using the DTMFSMJ7 utility, applies rules specified in the test.xsl file to it and produces a report in the PDF format, a sample of which can be seen as follows. This PDF report was produced based on the xml data extracted by the DTMFSMJ7 utility.