https://github.com/sbcgua/text2tab
TAB-delimited text parser for ABAP
https://github.com/sbcgua/text2tab
abap abap-data-parser hacktoberfest parsing text-parser
Last synced: 2 months ago
JSON representation
TAB-delimited text parser for ABAP
- Host: GitHub
- URL: https://github.com/sbcgua/text2tab
- Owner: sbcgua
- License: mit
- Created: 2016-08-13T09:37:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T07:25:52.000Z (11 months ago)
- Last Synced: 2025-01-30T22:51:36.474Z (11 months ago)
- Topics: abap, abap-data-parser, hacktoberfest, parsing, text-parser
- Language: ABAP
- Homepage:
- Size: 282 KB
- Stars: 24
- Watchers: 6
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- abap-florilegium - text2tab - delimited text parser for ABAP | `text` (Categories / 🗒️ eMail & Document Processing)
README
# ABAP text2tab parser and serializer (ex. Abap data parser)


TAB-delimited text parser and serializer for ABAP
- [Documentation](https://sbcgua.github.io/text2tab) (or also [here](./docsite/docs))
- [Blog articles](https://sbcgua.github.io/text2tab/blog)
- [Change log](./changelog.txt)
## Synopsis
Text2tab is an utility to **parse** TAB-delimited text into an internal table of an arbitrary flat structure.
- supports "non-strict" mode which allows to skip fields in the source data (for the case when only certain fields are being loaded).
- supports "header" specification as the first line in the text - in this case field order in the text may differ from the internal abap structure field order.
- supports loading into a structure (the first data line of the text is parsed).
- supports *type-less* parsing, when the data is not checked against existing structure but dynamically create as a table with string fields.
- supports specifying date and amount formats
- supports on-the-fly field name remapping (e.g. field `FOO` in the parsed text move to `BAR` component of the target internal table)
- supports "deep" parsing - filling structure or table components in the target data container
- supports "corresponding" parsing - filling only those fields which are in target structure. Kind of opposite to "non-strict" feature above.
And vice versa - **serialize** flat table or structure to text.
- support specifying date and amount formats, and line-break symbol
The package also contains 2 **examples** (see [examples](./src/examples) sub-package):
- `ZTEXT2TAB_EXAMPLE` - simple parsing code
- `ZTEXT2TAB_BACKUP_EXAMPLE` - example of DB table backup with serializer
## Documentation
Please find the [complete documentation](https://sbcgua.github.io/text2tab/docs) at our github pages site. The documentation includes infromation about installation, examples of usages and library API.
## Example of usage
Source text file (CRLF as a line delimiter, TAB as a field delimiter)
```text
NAME BIRTHDATE
Alex 01.01.1990
John 02.02.1995
Lara 03.03.2000
```
Simple parsing code
```abap
types:
begin of my_table_type,
name type char10,
birthdate type datum,
end of my_table_type.
data lt_container type my_table_type.
zcl_text2tab_parser=>create( lt_container )->parse(
exporting
i_data = my_get_some_raw_text_data( )
importing
e_container = lt_container ).
```
... or a more complex one ...
```abap
types:
begin of my_table_type,
name type char10,
city type char40, " <<< New field, but the text still contains just 2 !
birthdate type datum,
end of my_table_type.
...
zcl_text2tab_parser=>create(
i_pattern = lt_container " table or structure
i_amount_format = ' .' " specify thousand and decimal delimiters
)->parse(
exporting
i_data = my_get_some_raw_text_data( )
i_strict = abap_false " text may contain not all fields (city field will be skipped)
i_has_head = abap_true " headers in the first line of the text
importing
e_container = lt_container ). " table or structure (first data line from text)
```
## License
The code is licensed under MIT License. Please see the [LICENSE](/LICENSE) for details.