Exception handling of CONVERSION_EXITS in /UI2/CL_JSON #15
Replies: 3 comments 2 replies
-
Hi Jens, Thanks for the report. Yes, I see your point, but the correction I can offer here is limited. I can not propagate any exception but only CX_SY_MOVE_CAST_ERROR, and may pass your exception in the "previous" attribute. Still need a correction. You may try it with your own copy of the class (you can download Z_UI2_JSON from GitHub) and modify the code you pasted to this one: IF lv_convexit IS NOT INITIAL.
TRY .
CALL FUNCTION lv_convexit
EXPORTING
input = sdummy
IMPORTING
output = data
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS NOT INITIAL.
CLEAR data.
ENDIF.
RETURN.
CATCH cx_root INTO lo_exp.
CLEAR data.
IF mv_strict_mode EQ abap_true.
RAISE EXCEPTION TYPE cx_sy_move_cast_error EXPORTING previous = lo_exp.
ELSE.
RETURN.
ENDIF.
ENDTRY.
ENDIF. Here you can find how to generally allow passing exceptions through: Please, check if this suggestion will help you. If yes, I will integrate it into the next patch note. BR, Alexey. |
Beta Was this translation helpful? Give feedback.
-
Hi Alexey, The suggestion works for me. Please include it in the next patch. Thanks and regards |
Beta Was this translation helpful? Give feedback.
-
Hi Jens, I have already added the correction in the development version. The correction will be included in note 3615316 (not yet released). Details can be found on version history page. Release data I do not know yet: normally, I try to collect some fixes together, while the process of cross-release testing and corrections is quite time-consuming, but I will try to release it in July. BR, Alexey. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We deserialize JSON objects into ABAP structures. The house number field is defined in a JSON integer. However, there are market partners who send the field as a string and also send non-numeric characters in the house number.
To intercept this, I have placed a conversion exit on the house number field of the ABAP target structure. The conversion exit is run through and an exception is thrown.
Unfortunately, in the RESTORE_TYPE method of the /UI2/CL_JSON class, the exception is not passed on after the conversion exit is called, but only the target field is cleared:
This behavior does not make sense using conversion exits as there is no possibility to perform a real check for the JSON.
It would be desirable to pass the exception to the top or to have an optional parameter that passes the error message to the top in case of exceptions in the conversion exit
Beta Was this translation helpful? Give feedback.
All reactions