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 AUTO0 .. AUTO7.
AUTO0 .. AUTO7
automatic line counters
Two automatic line counters that can be accessed via their IDs LINE0 and LINE1.
LINE0, LINE1
custom counters
Unlimited custom counters that can be accessed via their IDs CUSTOM0 .. CUSTOMx.
CUSTOM0 .. CUSTOMx
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 for
Description
Example
ResetCounter(ID[, Value])
Record Property
AUTO CUSTOM
Reset the counter ID to 0 or a given Value.
ResetCounter(AUTO0)
ResetCounter(AUTO0, 1)
IncreaseCounter(ID)
Record Property
AUTO CUSTOM
Increases the counter ID by 1.
IncreaseCounter(CUSTOM2)
GetCounter(ID)
Property
AUTO LINE CUSTOM
Read the value of a counter and store it to the current attribute.
GetCounter(LINE0)
VerifyCounter(ID)
Property
AUTO LINE CUSTOM
Compare the value of a counter with the current attribute. This macro will throw an exception if the values are not equal.
VerifyCounter(CUSTOM0)
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.
On this Page:
FlatFileAdapter_ProductExport_Example
Click the icon to download a simple example model that shows the usage of the Flat File adapter in Scheer PASDesigner.