transpiler
transpiler copied to clipboard
Error with FIND IN TABLE, line
Find in string works, but find in table gives error
TYPES: BEGIN OF ty_submatch,
offset TYPE i,
length TYPE i,
END OF ty_submatch.
TYPES: BEGIN OF ty_match,
line TYPE i,
offset TYPE i,
length TYPE i,
submatches TYPE STANDARD TABLE OF ty_submatch WITH DEFAULT KEY,
END OF ty_match.
DATA lt_matches TYPE STANDARD TABLE OF ty_match WITH DEFAULT KEY.
DATA lt_words TYPE TABLE OF string.
APPEND 'hello' TO lt_words.
APPEND 'bar' TO lt_words.
APPEND 'world' TO lt_words.
FIND REGEX |bar| IN TABLE lt_words RESULTS lt_matches.
An error was thrown: TypeError: i.get is not a function
@mbtools try again, latest version
👍
No more error, but line in the result tab is not filled correctly.
TYPES: BEGIN OF ty_submatch,
offset TYPE i,
length TYPE i,
END OF ty_submatch.
TYPES: BEGIN OF ty_match,
line TYPE i,
offset TYPE i,
length TYPE i,
submatches TYPE STANDARD TABLE OF ty_submatch WITH DEFAULT KEY,
END OF ty_match.
DATA ls_submatch TYPE ty_submatch.
DATA ls_match TYPE ty_match.
DATA lt_matches TYPE STANDARD TABLE OF ty_match WITH DEFAULT KEY.
DATA lt_words TYPE TABLE OF string.
APPEND 'hello' TO lt_words.
APPEND '__bar__' TO lt_words.
APPEND 'world' TO lt_words.
FIND REGEX |(bar)| IN TABLE lt_words RESULTS lt_matches.
LOOP AT lt_matches INTO ls_match.
WRITE:
/ ls_match-line,
/ ls_match-offset,
/ ls_match-length,
/ lines( ls_match-submatches ).
LOOP AT ls_match-submatches INTO ls_submatch.
WRITE: /,
/ ls_submatch-offset,
/ ls_submatch-length.
ENDLOOP.
ENDLOOP.
Output:
0 " should be 2
2 " ok
3 " ok
1 " ok
2 " ok
3 " ok
just saw the todo https://github.com/abaplint/transpiler/blob/ea99f67c97a24f105cac8537e4dab88064bcde7e/packages/runtime/src/statements/find.ts#L113
heh 👍
https://github.com/abaplint/transpiler/pull/686/commits/c7557e2854bb52fcbfa0e5a10e454f640766e742
@mbtools try again
now line is filled properly but submatches table is empty instead of one record with offset 2 and lenght 3