Flat File TPA
If the first record in a flat file contains data that identifies the partner, then you can use it to select a guideline and profile.
Data | Delimited data; fixed length data with or without record terminators, NCPDP data. First record contains identifying data. |
Programs | Instream validation |
Selects | Validation guideline, validation profile |
Overview of Flat File TPA with Instream programs | |
---|---|
|
Validating |
Invoking TPA, identifying lookup file |
PARTNERAUTOMATIONFLAT in For details, refer Activating Flat File TPA |
Lookup file format |
CSV file containing selection criteria, guideline, and APF. For details, refer Lookup File for Flat File TPA |
What it selects |
Validation guideline Validation profile |
Command line |
Omit the -g parameter on the validation command line. For details, refer Validation Command Line |
Changes at |
First record in the file. |
Data formats |
Flat file in any of these formats:
|
Unmatched files |
Validation stops with return code 140 |
The Flat File Guideline
To get a flat file guideline, you can:
-
Import an existing copybook or CSV layout
-
Create a guideline from within Standards Editor
Please see TIB_fsp-instream_n.n.n_FlatFilesAtForesight.pdf for details.
In the table below, identify the line that describes the file format and then include the corresponding information in Standard Editor’s File > Properties.
Data File Format |
Record Size |
Record Key Size Record Key Start |
Record Delimiter |
Field Delimiter |
Sub-Field Delimiter |
---|---|---|---|---|---|
Fixed Length All records are the same length No delimiters between fields |
✓ |
✓ |
|
|
|
Fixed Length Fields with Record Delimiter Each field is the same length Records are different lengths because some have additional fields |
|
✓ |
✓ |
|
|
Delimited Each field has a delimiter Each record has a delimiter |
|
|
✓ |
✓ Keyboard character or hexadecimal (if comma is delimiter, use hex X2C) |
Not currently supported |
Example: Fixed Length
Each record is 80 bytes.
Each record starts with a 4-byte key.
Example: Fixed Length Fields with Record Delimiter
Record lengths may vary and end with an exclamation mark.
Each record starts with a 4-byte key.
Field lengths may vary and are delimited with an asterisk.
Example: Delimited
Record and field length may vary.
Records and fields have delimiters.
The first field is assumed to be the record key.
Copy this guideline from EDISIM’s User Files\Public Guidelines directory to Instream’s Database directory.
Activating Flat File TPA
To activate flat file TPA:
-
Go to Instream’s bin directory and edit $dir.ini (Windows) or fsdir.ini (UNIX).
-
Go to the UserTables section and add or update a PARTNERAUTOMATIONFLAT line:
[UserTables]
:UserTable = "C:\Foresight\InStream\Bin\CMS_UserTable.txt"
:PARTNERAUTOMATION = "C:\Foresight\InStream\Bin\TI_demo.csv"
PARTNERAUTOMATIONFLAT = "C:\Foresight\InStream\Bin\MyFlatFilePartAuto.csv"
-
If the line starts with a colon ( : ), remove the colon.
-
Adjust the path to point to the directory containing your lookup file (described below).
-
If you are not using other types of Trading Partner Automation also, be sure that there is a colon at the front of any other partner automation lines in this section.
Lookup File for Flat File TPA
Editing Tools for a Lookup file
-
Use a text editor like Notepad
-
Do not use a spreadsheet program to edit your lookup file. It may delete leading zeros, reformat numbers, and otherwise cause havoc with the content
Lookup File Big Steps
To set up your lookup table with a text editor:
-
Go to Instream’s DemoData\FFTPAdemo directory and copy MyFlatPartnerAutomation.csv to the PARTNERAUTOMATIONFLAT filename and path that you specified in
$dir.ini
orfsdir.ini
. -
Use a text editor to add a line for each scenario for which you want to specify a guideline, profile file, or output directory, as explained below.
-
Save as a text file.
Lookup File Format
The lookup table is a plain text file containing rows of comma-separated values.
The top line in the file contains labels of your choice. These are for your convenience and are ignored by TPA.
TPA starts with row 2 and uses the position of each item to determine its meaning.
Columns in Lookup File | |
---|---|
Column |
Notes |
FileType |
Required. Describes the type of flat file. Format for fixed length files F<reclength recorddelim> Where: F< > Literal text reclength Number of bytes in each record. If they vary, use the number of bytes in the first record. recorddelim Separator between records in hexadecimal, if it is not a newline. Examples:
Format for delimited files D<fielddelim recorddelim> Where: D< > Literal text fielddelim Separator between fields in hexadecimal. recorddelim Separator between records in hexadecimal. Precede hex values with 0x. Example: |
Field1
|
Required. First selection criteria. Specify data that causes this row’s guideline and/or APF to be used. Format for fixed length files (F in first column) <start length label value> Where: < > Literal text start Starting position of data. If set to -1 the field will not be used as search criteria for matching, but the value defined in the field will be returned to the caller application. length Number of characters in data (do not include trailing spaces) label Text of your choice to identify the data. Not used by TPA. Recommendation: call this one key as shown in the example below, since one and only one label must be key on each line. value Value to find at that location. If this contains spaces, include them, but enclose them in single quotes. Example 1: Example 2: Example 3: Format for delimited files (D in first column) <fieldposition label value> Where: < > Literal text fieldposition Field position in the record. If set to -1 the field will not be used as search criteria for matching, but the value defined in the field will be returned to the caller application. label Text of your choice to identify the data. Not used by TPA. Recommendation: call this one key as shown in the example below, since one label must be key on each line. value Value to find in that field. If this contains spaces, include them, but enclose them in single quotes. Example 1: Example 2: Example 3: |
Field2 … Field10
|
Optional additional selection criteria. Use the same format as Field1. If multiple selection criteria are used, then all must match for this guideline and/or APF to be used. |
Guideline Name |
Required. Do not include the file extension .STD. |
Profile File |
Optional; Instream validation APF file. Defaults to the Bin directory if you don’t specify a full path. If you specify a path, enclose it in double quotes if it contains spaces. If it does not contain spaces, omit the quotes. Do not end with a backslash. |
How Instream Matches:
-
If only one row matches the selection criteria, that row is used.
-
If more than one row matches:
-
The row that matches the most criteria will be used.
-
If they match the same number of criteria, the first matching row will be used.
-
-
If no match is found, the validation fails with return code 140. Unlike for EDI, it is not possible to have “best fit” guessing for flat file guideline selection, since flat files are not based on published standards. Consider whether you could use a fairly generic row at the end to pick a basic guideline that would work.
Example Lookup File
FileType,field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,Guideline,Apf F<46>,<15 5 field1 LB926>,<25 7 field2 WILSON>,,,,,,,,,VetFFtags1, F<46>,<15 5 field1 LB926>,<-1 7 field2 ‘HLTH CO’>,,,,,,,,,VetFFtags1, D<0x2A 0x21>,<3 field1 LB926>,,,,,,,,,,VETDELIM1, D<0x2A 0x21>,<3 field1 BJ612>,,,,,,,,,,VETDELIM2,Lenient.apf F<46>,<15 5 field1 BJ612>,<25 10 field2 MACDERMAND>,,,,,,,,,VetFFtags1,Lenient.apf F<75>,<2 2 key 00>,,,,,,,,,,NCPDP5,
Explanation
First line |
Headings. Ignored by Instream. |
Second line |
When validating, Instream should use guideline VetFFtags1 if the data contains both of these: Positions 15-19 Positions 25-30 |
Third line |
When validating, Instream should use guideline VetFFtags1 if the data contains both of these. (Note use of single quote in sample line around value with space [‘HLTH CO’]): Positions 15-19 Positions 25-30 |
Fourth line |
When validating, Instream should use the guideline VETDELIM1 if the third field contains |
Fifth line | When validating, Instream should use the guideline VETDELIM2 and profile Lenient.apf if the third field contains BJ612 . (Note the use of <0x2A 0x21> means the file has delimited fields separated by asterisks (hex equivalent is 2A) and records terminated by exclamation marks (hex equivalent is 21). |
Sixth line |
When validating, Instream should use guideline VetFFtabs1 and profile Lenient.apf if: Positions 15-19 Positions 25-34 |
Seventh line | NCPDP example that selects the standard NCPDP5. |
Sample Flat File Validation Output
The top of the detail results file will show TPA in GEN messages before it processes the first segment:
VER 2.0 STRT 010002 103/04/11 11:16:56Analysis requested on file C:\Foresight\InStream\DemoData\\FFTPAdemo\SpacetestFixed1_nospaces.txt, 526 bytes long GEN 015075 1 0Message file loaded : C:\Foresight\InStream\bin\FSBRERRS.TXT GEN 015004 1 0Partner Automation Table Loaded C:\Foresight\
InStream\DemoData\FFTPAdemo\MyFixedFileLookup.csv GEN 015006 1 0Guideline Selected using Criteria: (15 5 LB926,,,,,,,,,,) GEN 015040 1 0Loaded Profile from C:\Foresight\InStream\Bin\$fsdeflt.apf GEN 117021 1 0Document type(2), Message reference(HEAD) STRUS 1|HEAD|0|1|0 CSEG 1HEAD0000000001LB926 WILSON 201001101412 GEN 111001 1 0Loaded Transaction Set HEAD from Standard VetFixed1 () GEN 111215 1 1Start Transaction Set HEAD. STRUS 2|NAME|0|1|48 EDTL 5||1|PETS|SPEC|2||0|2|10600|3| EMSG 5Value "PARAKEET " is an invalid '"Species" (SPEC)' for PETS02 (D.E. SPEC) at col. 15 EDAT 5PARAKEET ESEG 5PETSJENNY PARAKEET BLUE STRUE 7|NAME|0|1|260|0:0:0:1:0:0:0|0:1:0:0:0:0:0:0:0|PETS STRUS 7|NAME|0|2|261 STRUE 13|NAME|0|2|509|0:0:0:0:0:0:0|0:0:0:0:0:0:0:0:0|PETS CSEG 13TRLR0000000001 STRUE 13|HEAD|0|0|526|0:2:0:1:0:0:0|1:2:0:0:0:0:0:0:0|TRLR SVRTY 0 8 0 1 0 0 0 ETYPE 13 7 2 0 0 0 0 0 0 0 END 1310006 103/04/11 11:16:57Analysis of file C:\Foresight\InStream\DemoData\\FFTPAdemo\VetCustomerFile.txt complete
Flat File TPA Demos
Please go to Instream’s DemoData\FFTPAdemo directory. Directions are in _readme_FFTPA.txt.