sbcgua/text2tab
A library that parses TAB-delimited text into an internal table of any flat ABAP structure, with non-strict, header and type-less modes, and serialises tables back to text in configurable formats.
Turning tab-delimited text into a flat internal table normally means writing a parser for one specific structure. text2tab parses text into a table or structure of any flat type, in a non-strict mode that skips fields missing from the source, a header mode that lets the text's column order differ from the structure's own, and a type-less mode that builds a string-typed table dynamically when no structure is supplied at all. Date and amount formats and on-the-fly field name remapping are configurable on read. It serialises the same data back to TAB-delimited text, with its own date, amount and line-break format.
Facts
Where it sits
Who is behind it
In the atlas: maintains 5, contributes to 11@sbcguamaintainerJohannes GerbershagenContributes to this
In the atlas: maintains 1, contributes to 7@germanysourcesMatthias AignerContributes to this
In the atlas: contributes to 1@HuarghJXYSGX7CContributes to this
In the atlas: contributes to 2@JXYSGX7CLars HvamContributes to this
In the atlas: maintains 13, contributes to 92, wrote 1@larshpsshlapakContributes to this
In the atlas: contributes to 2@sshlapak5 contributors
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Turning typed data into JSON, CSV or protobuf and back
Loader of Excel-prepared ABAP unit test data, with stub generation
Download
README
quoted from sbcgua/text2tab under MIT, readABAP text2tab parser and serializer (ex. Abap data parser)
TAB-delimited text parser and serializer for ABAP
- Documentation (or also here)
- Blog articles
- Change log
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
FOOin the parsed text move toBARcomponent 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 sub-package):
ZTEXT2TAB_EXAMPLE- simple parsing codeZTEXT2TAB_BACKUP_EXAMPLE- example of DB table backup with serializer
Documentation
Please find the complete documentation 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)
NAME BIRTHDATE
Alex 01.01.1990
John 02.02.1995
Lara 03.03.2000
Simple parsing code
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 ...
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 for details.
History
Notes
First public release. Code works fine, unit tests coverage >90%.
Others providing
Compare all 12 on the Serialisation page →- ABAP JSON APIABAP JSON APIA JSON renderer and parser for ABAP built on the standard identity transformation, adding automatic camelCase conversion and support for polymorphic arrays.independent, abapJSON renderer and parser for ABAP with camelCase conversionfrom ABAP
- zcl_mdp_jsonzcl_mdp_jsonAn ABAP library that generates and parses JSON strings, documented in the repository's wiki rather than its README, which names no ABAP release or installation method.independent, abapABAP library generating and parsing JSON stringsfrom ABAP
- JSON2ABAPTypeJSON2ABAPTypeA generator that produces an ABAP type definition from a JSON structure, with the repository holding the code and pointing to a blog article and an SAP blog post for the rest.independent, abapGenerator of ABAP type definitions from JSON structuresfrom ABAP
- abap-protobufabap-protobufAn implementation of Protocol Buffers in ABAP, stating support for proto2 syntax only; its repository description names gRPC, which the README says nothing further about.independent, abapProtocol Buffers (proto2) implementation in ABAPfrom ABAP
- ZASISZASISThe ABAP String Interpreter: an ABAP component that reads named field values out of an unstructured string, such as a barcode or scanner payload, through regex RuleSets configured in a Fiori app and called from ABAP or over HTTP.independent, abapRegex RuleSets that read barcode strings into named fieldsfrom ABAP
- ABAP ArchitectABAP ArchitectAn Eclipse plug-in that generates ABAP type definitions and parsing code from a pasted JSON or XML sample and creates the matching DDIC objects in a connected system over ADT.independent, abapEclipse plug-in turning JSON or XML into ABAP types and DDIC objectsfrom ABAP
- ABAP to JSON serializer and deserializerABAP to JSON serializer and deserializerAn open-source Z* version of SAP's standard /UI2/CL_JSON class, which serialises ABAP data to JSON and reads it back, installed with abapGit and needing SAP_BASIS 7.31 or later.sap official, abapOpen-source Z* version of /UI2/CL_JSON for ABAP to JSONfrom ABAP
- ajsonajsonA JSON parser and serialiser for ABAP that parses into a flexible, unstructured node tree rather than a fixed target structure, converting to one only when asked through to_abap.independent, abapJSON parser and serialiser for ABAP with a node treefrom ABAP
- ABAP JSON Encoder/DecoderABAP JSON Encoder/DecoderA JSON encoder and decoder for ABAP, modelled on Go's encoding/json package, installed through abapGit with no other required package and documentation still marked under construction.independent, abapJSON encoder and decoder for ABAP, modelled on Go's encoding/jsonfrom ABAP
- ZwdCSVZwdCSVA CSV parser and generator for ABAP that follows RFC 4180, including line breaks embedded inside quoted fields, for strings and for files on the application server and the frontend.independent, abapRFC 4180 CSV parser and generator for ABAPfrom ABAP
- ABAP CSV ManagerABAP CSV ManagerA configurable CSV reader and writer for ABAP, with per-field format, validation and column-mapping options, reading into a flat or a dynamically typed internal table.independent, abapConfigurable CSV reader and writer for ABAPfrom ABAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
History in the atlas
- First seen.
For your agent
- Ref
artifact:sbcgua-text2tab- JSON
- /artifacts/sbcgua-text2tab.json
- MCP
- Connecting an agent