To read a Multi schema Positional file we will use tFileInutMSPositional component, this component gives ability to read multiple schema based on certain columns value.
We are using Invoice file which has Invoice Header & invoice Details records in single file.
Invoice Header records start with “H” alphabet.
Invoice Details records start with “T’ alphabet.
follow the steps to read these multi schema records.
- Create a job and add tFileinputMSPositional component.
- Configure tFileinputMSPositional component with.
- provide file Name.
- row separator as per your file defaulted to “n”
- “Header Filed Position” this is the most important filed by which component will distinguish records whether it is header or detail. in our case first letter of row which is “H” for header and “T” for detail. so we will add value as “0-1” that means start of record to 1 character long.
- In “Records” section add two rows name it as “header” for Header records and “details” for Details record.
- once you add row it will ask you for schema add Header schema like below.
- Create details schema as follows.
- Now add pattern for “header” as “1,8,6,8,3”.
- Add pattern for details as “1,8,1,6,1,1,*”.
- now our configuration completed.
- Add two tLogRow component and from settings tab select “mode>Table”
- Connect first tLogRow to the tFileInputMSPositional using “Header” link.
- Connect Second tLogRow to the tFileInputMSPositional using “Detail” link.
- Synch tLogRow columns.
Execute the job. It will show you below output.
In this post i will describe you how to read/process multi schema delimited file using tFileInutMSDelimited component.
here is our sample input data which has header records then its trailer records.
Invoice Header record start with “H” alphabet and Invoice Detail/trailer record start with “T” Alphabet.
we will use tFileInutMSDelimited component to parse these records. so create a job and drag and drop tFileInutMSDelimited component and then double click on it, it will show you another screen for metadata creation.
select our source file, then select column separator & row separator, once that is done then flow the below steps.
- In preview window select first column which has “H” and “T” values.
- In Schema grid click on add button and provide following values.
- Click on “OK” you will one record created with provided values.
- Click on fetch Codes button, it fetch all the visible codes from mention file and creates schema based on column delimiter.
- Our configuration looks like below image.
- Now go to the component setting tab and click on first schema which may look like row_A_1 click on it.
- it will show you schema with default column names.
- modify column name as follows.
- We are done with Header schema now do the same thing with Trailer schema and modify column names.
- Add tLogRow and connect to the tFileInputMSDelimited component using “row_A_1” schema.
- Do the Same thing for “row_B_1” schema.
- Now Execute the job your output will be like this.
you can achieve same thing using other ways, but trust me this is the most simple way.