Closed oblomov-dev closed 9 months ago
Did you try to rename
DATA value TYPE p LENGTH 10 DECIMALS 3.
I remember that to_abap
does the job if there is (canonical/or customized) name mapping, see https://github.com/sbcgua/ajson?tab=readme-ov-file#converting-to-abap-structure
yes same problem also with renamed variable:
DATA(lv_test) = `{` &&
` "string": "my string",` &&
` "value": "1.3333"` &&
`}`.
DATA r TYPE REF TO zif_abapgit_ajson.
r = zcl_abapgit_ajson=>parse( lv_test ).
r = r->slice( `/value` ).
TRY.
DATA value TYPE p LENGTH 10 DECIMALS 3.
r->to_abap(
IMPORTING
ev_container = value
).
CATCH cx_root INTO DATA(x).
"Unexpected timestamp format
DATA(lv_error) = x->get_text( ).
"workaround
value = r->mt_json_tree[ 1 ]-value.
ENDTRY.
The if comparing to packed should also check for ABAP timestamp data element(s) or matching number of digits and decimals. Only then call to_timestamp.
Try #180
thank you for quickly fixing this! works on my side now! and i was able to replace the workaround with https://github.com/abap2UI5/abap2UI5/pull/985
At the frontend i get a value typed as string, but i need to map it to an abap variable typed with p. Is this possible or is the exception intended?
I think the problem is here: https://github.com/sbcgua/ajson/blob/f1f6f230e5bd67955c5176b7410d1bfcfab3d030/src/core/zcl_ajson.clas.locals_imp.abap#L990
But not sure how to extend it, because there is no chance to differentiate between type p and timestampl.
Originally found this issue here and work with the workaround from above at the moment: https://github.com/abap2UI5/abap2UI5/issues/975
Thank you for your help!