Developing Longview ImportSpecs, ExportSpecs, and external Maps
You can use an ImportSpec or ExportSpec document in Longview Application Framework to specify instructions for importing or exporting data to or from an external file in ASCII format. You can use Maps to specify instructions when the symbol names in your file do not match the symbol names in your Longview database.
This chapter contains information on these main topics:
Creating ImportSpecs
ImportSpecs stored as ASCII file and can be created and edited in any text editor. ImportSpecs support importing values up to nine decimal places (i.e. 1000.123456789).
The recommended file extension for ImportSpecs is .lvimp. For information on the functions used in an ExportSpec, see ImportSpec and ExportSpec Functions.
Sample ImportSpec for DataAreas
Syntax
DataSource TEXT, "DemoBuild\Data\Deferred Tax Setup\DeferredTaxSetup.txt", EXTERNAL, "{"
Set Acc, 1
Set Tim, 2
Set Ent, 3
Set Det, 4
Set Cur, 5
Set Seg, 6
Set Ele, 7
Set Con, 8
Set Val, 9
Define ACCOUNTS, Match, Acc
Define TIMEPER, Match, Tim
Define ENTITIES, Match, Ent
Define DETAILS, Match, Det
Define CURRENCY, Match, Cur
Define SEGMENTS, Match, Seg
Define ELEMENTS, Match, Ele
Define CONTROLS, Match, Con
ValueField Val
Sample source file and ImportSpec for DataTables
The following is an example of a source file that could be specified in an ImportSpec.
An ImportSpec for the above source file could look like this:
Creating ExportSpecs
ExportSpecs are stored as ASCII files and can be created and edited in any text editor. ExportSpecs support exporting values up to nine decimal places (i.e. 1000.123456789).
The recommended file extension for ExportSpecs is .lvexp. For information on the functions used in an ExportSpec, see ImportSpec and ExportSpec Functions.
Sample ExportSpec for DataAreas
Example: Code
DataTarget TEXT, "DemoBuild\Data\Deferred Tax Setup\DeferredTaxSetup.txt", EXTERNAL, "{"
Set Acc, 1
Set Tim, 2
Set Ent, 3
Set Det, 4
Set Cur, 5
Set Seg, 6
Set Ele, 7
Set Con, 8
Set Val, 9
Define ACCOUNTS, Match, Acc
Define TIMEPER, Match, Tim
Define ENTITIES, Match, Ent
Define DETAILS, Match, Det
Define CURRENCY, Match, Cur
Define SEGMENTS, Match, Seg
Define ELEMENTS, Match, Ele
Define CONTROLS, Match, Con
ValueField Val
Sample ExportSpec and target file for DataTables
Example: Code
DataTarget TEXT, "Salary Reporting\MiddleMgmtSalaries.txt", EXTERNAL, "{"
Set First, 1
Set Last, 2
Set ID, 3
Set Amount, 4
Set Job, 5
Define FirstName, MATCH, First
Define LastName, MATCH, Last
Define USERID, MATCH, ID
Define Salary, MATCH, Amount
Define Role, MATCH, Job
DecimalCharacter "."
The resulting target file could look like this:
Example
DataSource TEXT, "Salary Reporting\ExecutiveSalaries.txt", EXTERNAL, "{"
Set ID, 1
Set FNM, 2
Set LNM, 3
Set Job, 4
Set Amount, 6
Define USERID, MATCH, ID
Define FirstName, MATCH, FNM
Define LastName, MATCH, LNM
Define Role, MATCH, Job
Define Salary, MATCH, Amount
DecimalCharacter "REGIONAL"
Note: In this example, the developer chose to omit the fifth column (Employment Type) from the ImportSpec for the DataTable.
Creating external Maps
You can use Maps to specify instructions when the symbol names in your file do not match the symbol names in your Longview database.
External maps are maps that are not created in your Longview database. If you want to create an internal map, you can do so using the Mappings editor. For more information, see the “Mappings Editor Help”.
The recommended file extension for external Maps is .lvmap.
Understanding mappings methods and expressions
Maps contain instructions for importing data when the symbol names in your source file do not match the symbol names in the Longview database. A map contains a number of mappings, which specify methods for the way in which a source symbol should be mapped to a Longview database symbol using an expression.
You can create internal maps using the Mappings editor and external maps in Longview Application Framework.
For information on a creating a sample external map, see Sample External Map in the Longview Developer’s Guide.
You can use one of four methods in a mapping:
You can use all alphanumeric and ASCII characters in an expression except for double quotation marks ( ” ). The following are the rules for each method:
Exact
Use this method to match the expression value exactly. For example, use the EXACT method to map a single source symbol name to a Longview database symbol name exactly as indicated in the expression.
Note: Special characters are matched exactly when used in an expression for the Exact method.
- Internal syntax
- External syntax
Map Cash, EXACT, 10000
Map AccountsReceivable, EXACT, 20000
Wildcard
Use this method to match the expression field partially by including wildcards in an expression. This method is case sensitive. Use the question mark ( ? ) to specify any one character as wildcard. Use the asterisk ( * ) to specify zero or more characters as wildcards. For example, use the WILDCARD method to import source symbols beginning with certain characters to a Longview database symbol name.
- Internal syntax
- External syntax
Map Cash, WILDCARD, 1000?
Map AccountsReceivable, WILDCARD, 200*
Map AccountsPayable, WILDCARD, 211*0
Range
Use this method to match a range of values, separated by a hyphen. This method is case sensitive. For example, use the RANGE method when you have a range of source symbol names to import to a Longview database symbol name.
- Internal syntax
- External syntax
Map Cash, RANGE, 10000-10009
In
Use this method to match the expression value to one of several values. For example, use the IN method when you have a set of source symbol names to import to a Longview database symbol name. This method is case sensitive. You may also use the wildcard characters question mark (?) and asterisk (*) in the IN clause.
- Internal syntax
- External syntax
Map E12130, IN, “E12130,E11130, E11140, E12000”
Map E13100, IN, “E13*,E00000”
Map E11110, IN, “E11??0,E11111”
Sample External Map
Example code
Format STANDARD
DefineDimension ACCOUNTS
Map 10010, RANGE, "10011-10013"
Map 10021, EXACT, "A100"
Map 10030, WILDCARD, "10030??"
Map 10040, WILDCARD, "1004*"
Map 10040, WILDCARD, "*100"
Map 10000,IN, “10000,10005