Expression language for flat files

USE:

Int4 IFTT uses XPath expressions to extract specific values from XML files. Int4 IFTT uses our simple language (explicitly created for this purpose) for fetching values from flat file messages

PROCEDURE:

Following tags can be used in flat-file expressions:

  • CSV_COLUMN - in CSV file column number for further extraction 
  • CSV_SEPARATOR - optional separation character different than a comma
  • CSV_SKIP_HEADER - skips the first row in the CSV file
  • START_TAG - determine string as the starting point 
  • START_FROM - determine from which character after string defined in START_TAG derivation should start. The first character is 1 
  • LENGTH determine the length of string that will be saved
  • END_TAG - determine string, as the ending point
  • REGEX - match specific parts of the file using regular expression. 
    By default whole regular expression is matched and used for variable replacement. It is possible to use subgroups to extract/replace part of the expression. If there is a subgroup defined, it is used instead of the full result.See example 5 below.
    More information about regular expressions syntax in ABAP: https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenregular_expressions.htm


Each tag should be separated by &&

START_TAG or START_FROM are obligatory tags (unless REGEX is used)


Example 1: To derive string IFTT001 from the exemplary flat-file below, the following expression could be used: START_TAG(BGM+220+)&&START_FROM(1)&&LENGTH(7)

This expression can be used to extract values with no ending tag or extract only a part of the value.


UNA:+.? '
UNB+UNOA:3+000000000B:ZZ+0000000ECC:ZZ+20051107:1159+6002'
UNH+000000101+ORDERS:D:96A:UN:EAN008'
BGM+220+IFTT001+9'


Example 2:  To derive string IFTT002 from the exemplary flat-file below, the following expression could be usedSTART_TAG(BGM+220+)&&END_TAG(+)

In this case, the expression will work independently of the length of the values.

UNA:+.? '
UNB+UNOA:3+000000000B:ZZ+0000000ECC:ZZ+20051107:1159+6002'
UNH+000000101+ORDERS:D:96A:UN:EAN008'
BGM+220+IFTT002+9'


Example 3: To derive string IFTT003 from the exemplary flat-file below, the following expression could be used: START_FROM(9)&&LENGTH(7)

This expression can be used to extract values with no starting and ending tags or to extract only a part of the value. This statement is handy for handling very long strings.

UNA:+.? '
UNB+UNOA:3+000000000B:ZZ+0000000ECC:ZZ+20051107:1159+6002'
UNH+000000101+ORDERS:D:96A:UN:EAN008'
BGM+220+IFTT003+9'


Example 4: To derive string IFTT004 from the exemplary flat-file below, the following expression could be usedSTART_FROM(9)&&END_TAG(+9)

In this case, the expression will work independently of the length of the values, just starting from a specific point till the end tag.

UNA:+.? '
UNB+UNOA:3+000000000B:ZZ+0000000ECC:ZZ+20051107:1159+6002'
UNH+000000101+ORDERS:D:96A:UN:EAN008'
BGM+220+IFTT004+9'


Example 5: To derive string IFTT004 from the example flat-file below, the following expression could be usedREGEX(BGM\+220\+([A-Z0-9]+)\+9)

UNA:+.? '
UNB+UNOA:3+000000000B:ZZ+0000000ECC:ZZ+20051107:1159+6002'
UNH+000000101+ORDERS:D:96A:UN:EAN008'
BGM+220+IFTT004+9'

The expression used in this example uses subgroup to extract part of the matched string. Subgroups are defined using the ( ... ) operator. REGEX(BGM\+220\+([A-Z0-9]+)\+9)
Expression REGEX(BGM\+220\+[A-Z0-9]+\+9) without subgroup matches entire line: BGM+220+IFTT004+9'


Please note that the LENGTH tag works only combined with START_FROM.

It is possible to use multiple expressions for a single variable processor and join them with the || operator. All matching values are collected and saved to the same variable then.

© 2017 - 2022 Int4 AG All rights reserved