Using Macro Expressions on Parsing or Composing a Flat File
For parsing and composing flat files there is a set of counters and related macros available that provide extended features.
Type | Parse | Compose | Description | ID |
---|---|---|---|---|
automatic counters | Eight automatic counters that can be accessed via their IDs |
| ||
automatic line counters | Two automatic line counters that can be accessed via their IDs LINE |
| ||
custom counters | Unlimited custom counters that can be accessed via their IDs |
|
You cannot access these counters directly but only via the macro expressions listed in the table below. Macro expressions referring to one of the counters can be specified on flat file records and on flat file properties (see also Defining a Flat File Data Structure) in the stereotype attributes parseMacro and composeMacro.
When parsing/composing the first record, all counters have the initial value of 0.
Automatic counters automatically increase with each processed record.
Custom counters have to be increased manually using the IncreaseCounter() macro (see below).
The counters can be handled using the following macros:
Macro | Available on | Available | Description | Example |
---|---|---|---|---|
ResetCounter( | Record |
| Reset the counter |
|
IncreaseCounter( | Record |
| Increases the counter |
|
GetCounter( | Property |
| Read the value of a counter and store it to the current attribute. |
|
VerifyCounter( | Property |
| Compare the value of a counter with the current attribute. This macro will throw an exception if the values are not equal. |
|
For GetCounter() and VerifyCounter() only attributes of type Integer are supported.
Example
The Flat File adapter example shows the usage of an automatic counter to provide a line number to the data records during the composing process. Refer to Defining a Flat File Data Structure for more details on the example flat file.
Property line stores the number of the product line by using
GetCounter(AUTO0)
.With every Header record, the counter gets reset to 0 by using
ResetCounter(AUTO0)
. This way the header record will not be counted.
The picture below shows the composing process for the example with emphasis on macro execution.
FlatFileAdapter_ProductExport_Example
Click here to download a simple example model that shows the usage of the Flat File adapter in Scheer PAS Designer.
Related Pages: