cancel
Showing results for 
Search instead for 
Did you mean: 

Success and Error messages in RAP validation logic

imihailovs
Explorer
0 Kudos
246

Dear experts,

I am wandering if it is possible to issue both success and error messages in one validation handler and return both successful records and failed records back to the frontend? 

I have a scenario where e.g. 4 entities are submitted for backend processing. Two of these entities are failed, two are processed successfully. If I add two of failed entities to FAILED / REPORTED changing parameter of a method - the frontend receives a results with two error messages. And to the frontend it looks like that the whole request failed.

Is there a way to pass both successful and failed records back to the frontend - for the simple reason that I'd like to show to application users that, hey, there are two successful "bookings" and two failed ones (with the attached error messages)?

Thanks in advance.

View Entire Topic
Oleg_Vokh
Product and Topic Expert
Product and Topic Expert

Hi @imihailovs 
if I understood the question correctly, try using the code to display messages below

 reported-zrswatovo = VALUE #(
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-success text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-error text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-warning text = 'Dummy message' ) )
  ( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-information text = 'Dummy message' ) )
).

 

Oleg_Vokh_0-1730980037394.png

BR,
Oleg

imihailovs
Explorer
0 Kudos
Hmm, not really what I am aiming for. The call to RAP service returns the same entity list back to the frontend, but with additional fields populated (newly created transaction IDs). So I am looking forward of finding a way how to pass both successful entities (with new fields populated) and failed entities - with error messages. Not sure if it is even possible.
VarunVarshney
Participant
0 Kudos
i am not sure if RAP supports this kind of feature right now as as soon as you fill failed structure system will fail that instance BO and other successfull entries might gets vansihed. so you can fill reported like above with message type like showed above by @Oleg . Also please keep us posted if you find something better on this