The following scenario describes a two-component Job, which aims at reading data from an input file that contains contract numbers, customer references, and insurance numbers as shown below, and outputting the selected data (according to the data position) into an XML file.
Contract CustomerRef InsuranceNr 00001 8200 50330 00001 8201 50331 00002 8202 50332 00002 8203 50333
Drop a tFileInputPositional component from the Palette to the design workspace.
Drop a tFileOutputXML component as well. This file is meant to receive the references in a structured way.
Right-click the tFileInputPositional component and select Row > Main. Then drag it onto the tFileOutputXML component and release when the plug symbol shows up.
Double-click the tFileInputPositional component to show its Basic settings view and define its properties.
Define the Job Property type if needed. For this scenario, we use the built-in Property type.
As opposed to the Repository, this means that the Property type is set for this station only.
Fill in a path to the input file in the File Name field. This field is mandatory.
Define the Row separator identifying the end of a row if needed, by default, a carriage return.
If required, select the Use byte length as the cardinality check box to enable the support of double-byte character.
Define the Pattern to delimit fields in a row. The pattern is a series of length values corresponding to the values of your input files. The values should be entered between quotes, and separated by a comma. Make sure the values you enter match the schema defined.
Fill in the Header, Footer and Limit fields according to your input file structure and your need. In this scenario, we only need to skip the first row when reading the input file. To do this, fill the Header field with 1 and leave the other fields as they are.
Next to Schema, select Repository if the input schema is stored in the Repository. In this use case, we use a Built-In input schema to define the data to pass on to the tFileOutputXML component.
You can load and/or edit the schema via the Edit Schema function. For this schema, define three columns, respectively Contract, CustomerRef and InsuranceNr matching the structure of the input file. Then, click OK to close the [Schema] dialog box and propagate the changes.
Double-click tFileOutputXML to show its Basic settings view.
Enter the XML output file path.
Define the row tag that will wrap each row of data, in this use case ContractRef.
Click the three-dot button next to Edit schema to view the data structure, and click Sync columns to retrieve the data structure from the input component if needed.
Switch to the Advanced settings tab view to define other settings for the XML output.
Click the plus button to add a line in the Root tags table, and enter a root tag (or more) to wrap the XML output structure, in this case ContractsList.
Define parameters in the Output format table if needed. For example, select the As attribute check box for a column if you want to use its name and value as an attribute for the parent XML element, clear the Use schema column name check box for a column to reuse the column label from the input schema as the tag label. In this use case, we keep all the default output format settings as they are.
To group output rows according to the contract number, select the Use dynamic grouping check box, add a line in the Group by table, select Contract from the Column list field, and enter an attribute for it in the Attribute label field.
Leave all the other parameters as they are.
Press Ctrl+S to save your Job to ensure that all the configured parameters take effect.
Press F6 or click Run on the Run tab to execute the Job.
The file is read row by row based on the length values defined in the Pattern field and output as an XML file as defined in the output settings. You can open it using any standard XML editor.