2024 Mar 07 12:26 PM - edited 2024 Mar 07 12:31 PM
Hello experts,
Does anybody know if it is possible to stop behavior execution and return the error back to API caller from the FOR DETERMINE method? I am using this method to call a BAPI and change my currently processed entity with a transaction ID returned from the BAPI. However, if the BAPI fails for any reason - I would like to return the error message back to API caller. I have tried populating REPORTED itab, but that doesn't stop the execution and save is eventually executed.
I know that this is possible via FOR VALIDATE methods and with FAILED itab, however I need to use the MODIFY ENTITIES statement (to update currently processed entity) which I cannot use in FOR VALIDATE method (hard error).
Any suggestions
Hello experts,
Does anybody know if it is possible to stop behavior execution and return the error back to API caller from the FOR DETERMINE method? I am using this method to call a BAPI and change my currently processed entity with a transaction ID returned from the BAPI. However, if the BAPI fails for any reason - I would like to return the error message back to API caller. I have tried populating REPORTED itab, but that doesn't stop the execution and save is eventually executed.
I know that this is possible via FOR VALIDATE methods and with FAILED itab, however I need to use the MODIFY ENTITIES statement (to update currently processed entity) which I cannot use in FOR VALIDATE method (hard error).
Any suggestions
2024 Mar 07 12:55 PM
I think I somewhat figured it out.
First, in FOR DETERMINE method I store the message in %msg object of the reported structure, like so:
INSERT VALUE #( orderuuid = <fs_repair_order>-orderuuid
%create = if_abap_behv=>mk-on
%state_area = 'XYZ'
%msg = me->new_message_with_text( severity = CONV #( <fs_response>-type )
text = <fs_response>-message ) ) INTO TABLE reported-repairorder.Then in FOR VALIDATE ON SAVE, I read the entity in question like so:
READ ENTITIES OF zoem_i_repairorder IN LOCAL MODE
ENTITY repairorder
ALL FIELDS WITH CORRESPONDING #( keys )
RESULT DATA(lt_data)
REPORTED DATA(lt_reported_data).In this case, lt_reported_data will contain the entity with %msg content that I can analyze and, if any errors are present, populate the "failed" structure.
If anyone knows different (more correct way) of doing it - please let me know.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |