z/OS DFSORT Application Programming Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Example 24

z/OS DFSORT Application Programming Guide
SC23-6878-00

  OPTION COPY
  OUTFIL REMOVECC,
   HEADER1=(C'<?xml version="1.0"?>',/,
     3:C'<booklist>'),
   BUILD=(5:C'<book>',/,
     7:1,20,JFY=(SHIFT=LEFT,LEAD=C'<title>',TRAIL=C'</title>',
       LENGTH=36),/,
     7:24,15,SQZ=(SHIFT=LEFT,LEAD=C'<author>',MID=C', ',
       TRAIL=C'</author>',LENGTH=33),/,
     5:C'</book>'),
   TRAILER1=(3:C'</booklist>')

This example illustrates how you can generate XML statements from FB input records containing fields in fixed positions.

The 40-byte FB input records might look like this:
Modern Poetry          Friedman    KR
Intro to Computers     Chatterjee  CL
Marketing              Maxwell     G

Note that the data has three character fields in fixed positions.

The 42-byte FB output records look like this:
<?xml version="1.0"?>
  <booklist>
    <book>
      <title>Modern Poetry</title>
      <author>Friedman, KR</author>
    </book>
    <book>
      <title>Intro to Computers</title>
      <author>Chatterjee, CL</author>
    </book>
    <book>
      <title>Marketing</title>
      <author>Maxwell, G</author>
    </book>
  </booklist>
We use OUTFIL HEADER1 to generate the xml and booklist starting tags that precede the set of tags for each record. We use OUTFIL BUILD to generate the set of tags for each record as follows:
  • A constant is used to generate the book starting tag.
  • JFY is used to generate the title tags and data from the first input field. LEAD generates the title starting tag before the input field from the record. TRAIL generates the title ending tag after the last nonblank character from the input field. JFY keeps embedded blanks between the first nonblank character and the last nonblank character of the input field. LENGTH ensures that the addition of the LEAD and TRAIL strings does not cause truncation by increasing the output length to 36 bytes (overriding the default of 20 bytes from the input field).
  • SQZ is used to generate the author tags and data from the second and third input fields. LEAD generates the author starting tag before the input field from the record. MID replaces the blanks between the second and third input fields with a comma and one blank. TRAIL generates the author ending tag after the last nonblank character from the input fields. LENGTH ensures that the addition of the LEAD, MID and TRAIL strings does not cause truncation by increasing the output length to 33 bytes (overriding the default of 15 bytes from the input field).

We use OUTFIL TRAILER1 to generate the booklist ending tag that follows the set of tags for each record.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014