-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathztext2tab_example.prog.abap
More file actions
38 lines (31 loc) · 1.04 KB
/
ztext2tab_example.prog.abap
File metadata and controls
38 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
*&---------------------------------------------------------------------*
*& ABAP TEXT2TAB PARSER
*& project homepage: https://github.com/sbcgua/text2tab
*&---------------------------------------------------------------------*
report ztext2tab_example.
start-of-selection.
types:
begin of ty_my,
num type i,
word type char8,
end of ty_my,
tt_my type standard table of ty_my.
data lt_container type tt_my.
data lv_text type string.
lv_text = 'NUM\tWORD\n1\tHello\n2\tWorld'.
replace all occurrences of '\t' in lv_text with cl_abap_char_utilities=>horizontal_tab.
replace all occurrences of '\n' in lv_text with cl_abap_char_utilities=>cr_lf.
zcl_text2tab_parser=>create(
i_pattern = lt_container
i_amount_format = ''
)->parse(
exporting
i_data = lv_text
i_strict = abap_true
i_has_head = abap_true
importing
e_container = lt_container ).
field-symbols <i> like line of lt_container.
loop at lt_container assigning <i>.
write: / <i>-num, <i>-word.
endloop.