Examples of the batch interface

Example 1. Import - all XML members on FMN.XMLINP to FMN.IMPORT.TEMPLATE

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
$$FILEM TPIMP DSNIN=FMN.XMLINP,
$$FILEM MEMBER=*,
$$FILEM DSNOUT=FMN.IMPORT.TEMPLATE,
$$FILEM REPLACE=YES
/*

Example 2. Import - same as example 1 except using default input and output ddnames. Note keywords INPUT, and OUTPUT can be used to point to different DD names.

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//DDIN  DD DISP=SHR,DSN=FMN.XMLINP
//DDOUT DD DISP=SHR,DSN=FMN.IMPORT.TEMPLATE
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
$$FILEM TPIMP MEMBER=*,REPLACE=YES
/*

Example 3. Import from XML that is inline in the jobstream into one member

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
$$FILEM TPIMP DSNOUT=FMN.TEMPLATE(CBL1),INPUT=*
<template lang="COBOL" type="BASE">
 <copybooks>
  <library>FMN.COBOL</library>
  <member name="COPY01"/>
  <member name="COPY02"/>
 </copybooks>
 <layout copybook="COPY01">
  <criteria type="ID">
   <exp><![CDATA[#2 = '01']]></exp>
  </criteria>
 </layout>
 <layout copybook="COPY02">
  <criteria type="ID">
   <exp><![CDATA[#2 = '02']]></exp>
  </criteria>
 </layout>
</template>
/*

Example 4. Export all template members in a PDS - Replace output members, ISPF statistics and only produce XML for copybook and criteria.

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
$$FILEM TPEXP DSNIN=FMN.IMPORT.TEMPLATE,
$$FILEM MEMBER=*,
$$FILEM DSNOUT=FMN.XMLOUT.NEW,
$$FILEM COPYCRIT=YES,
$$FILEM STATS=YES,
$$FILEM REPLACE=YES
/*

Example 5. Export same as example 4 except using default DD names for input and output. Keywords INPUT, and OUTPUT could also be used.

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//SYSPRINT DD SYSOUT=*
//DDIN  DD DISP=SHR,DSN=FMN.IMPORT.TEMPLATE
//DDOUT DD DISP=SHR,DSN=FMN.XMLOUT.NEW
//SYSIN DD *
$$FILEM TPEXP MEMBER=*,
$$FILEM COPYCRIT=YES,
$$FILEM STATS=YES,
$$FILEM REPLACE=YES
/*

Example 6. Export single member to producing XML output on SYSOUT

//FMBAT EXEC PGM=FILEMGR
//STEPLIB  DD DISP=SHR,DSN=HLQ.SFMNMOD1
//SYSPRINT DD SYSOUT=*
//XMLDD    DD SYSOUT=*
//SYSIN DD *
$$FILEM TPEXP DSNIN=FMN.TEMPLATE,MEMBER=COPY0102,COPYCRIT=YES,
$$FILEM OUTPUT=XMLDD
/*

Example 7. Run a compare job using XML dynamic templates specified in the JCL to perform column compares. This compares columns 1 to 5 input file with columns 8 to 12 of the output file, and columns 6 to 10 of the input file with columns 13 to 17 of the output file.

//FMBAT EXEC PGM=FILEMGR
//SYSPRINT DD SYSOUT=*
//DDOLD DD DISP=SHR,DSN=FMN.DATA(COMP1OLD)
//DDNEW DD DISP=SHR,DSN=FMN.DATA(COMP1NEW)
//TDOLD DD DATA
<template type="DYNAMIC">
 <layout>
  <symbol name="comp1" start="1" length="5" type="AN"/>
  <symbol name="comp2" start="6" length="5" type="AN"/>
 </layout>
</template>
/*
//TDNEW DD DATA
<template type="DYNAMIC">
 <layout>
  <symbol name="comp1" start="8"  length="5" type="AN"/>
  <symbol name="comp2" start="13" length="5" type="AN"/>
 </layout>
</template>
/*
//SYSIN DD *
$$FILEM DSM TYPE=FORMATTED,LIST=DELTA
/*

Example 8. Print sample file using XML dynamic template - multiple layouts and ID criteria.

//FMBAT EXEC PGM=FILEMGR
//SYSPRINT DD SYSOUT=*
//DDIN  DD DISP=SHR,DSN=hlq.SFMNSAM1(FMNCDATA)
//TDDIN DD DATA
<template type="DYNAMIC">
 <layout name="rec-type01">
  <symbol name="type" start="1" length="2" type="AN"/>
  <symbol name="name" start="3" length="20" type="AN"/>
  <symbol name="empno" start="23" length="2" type="BI"/>
  <symbol name="age"   start="25" length="2" type="BI"/>
  <symbol name="salary"  start="27" length="4" type="PD"/>
  <criteria type="ID">
    <exp><![CDATA[#type = '01']]></exp>
  </criteria>
 </layout>
 <layout name="rec-type02">
  <symbol name="type" start="1" length="2" type="AN"/>
  <symbol name="name" start="3" length="20" type="AN"/>
  <symbol name="title" start="23" length="14" type="AN"/>
  <symbol name="addr1" start="37" length="20" type="AN"/>
  <symbol name="addr2" start="57" length="20" type="AN"/>
  <symbol name="postcode" start="77" length="4" type="AN"/>
  <criteria type="ID">
    <exp><![CDATA[#type = '02']]></exp>
  </criteria>
 </layout>
</template>
/*
//SYSIN DD *
$$FILEM DSP FORMAT=SNGL
/*

Example 9. Run a Db2® import job that either creates or updates a Db2® template specifying new headings for fields. Note we have the XML inline - the input could come from a member.

//FMNDB2   EXEC PGM=FMNDB2,PARM=('SSID=ssss,SQID=userid')
//SYSPRINT DD SYSOUT=*
//SYSTERM  DD SYSOUT=*
$$FILEM TPIMP DSNOUT=hlq.TEMPLATE(EMPHD),
$$FILEM REPLACE=YES,
$$FILEM INPUT=*
<template type="DB2">
 <db2object>DSN8810.EMP</db2object>
 <layout>
  <symbol name="empno">
   <heading>Employee</heading>
  </symbol>
  <symbol name="FIRSTNME">
   <heading>First Name</heading>
  </symbol>
  <symbol name="MIDINIT">
   <heading>Middle</heading>
  </symbol>
  <symbol name="LASTNAME">
   <heading>Last Name</heading>
  </symbol>
  <symbol name="BIRTHDATE">
   <heading>Birth Date</heading>
  </symbol>
 </layout>
</template>