cancel
Showing results for 
Search instead for 
Did you mean: 

RAP - Custom CDS Entity, show message to customer on frontend, more tutorials ?

lkemr
Explorer

Hello Everyone,

I am writing this question as I could not find answer to this in any of the tutorials or documentation.

How can I show popup message or message container to customer on frontend via the if_rap_query_provider~select ? I am working on simple RAP List Report App with Custom CDS Entity. I don't need any behavior implementation as it is display only. The data is called via ABAP method in if_rap_query_provider~select and stored in internal table, then selected with offset and max rows implementation.

But sometimes I would like to throw some message to frontend. For example if some of the filter is initial or something else went wrong during the runtime.

Is it possible somehow? Did anyone managed to do that?

Also will there be some more tutorials for using Custom CDS Entity in RAP applications? With more details on this feature or implementing top, skip on internal table etc. ?

Thank you and best regards,

Lubos

YW
Explorer
0 Kudos

Hi Kemer, I have same questions with you. I want to popup some messages in unmanaged query implementation class. but I can't implement it base on Fischer's advance. Have you implemented it? Could you please share your coding to me? thank you in advance.

View Entire Topic
Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

The select method offers two class based exceptions that could be raised by your implementation.

  • cx_rap_query_prov_not_impl

    Should be raised if the provider lacks the ability to fulfill the request at hand in its current state of implementation.
  • cx_rap_query_provider

    General failure. Must be raised if an error prevents successful query processing.

You will have to create a new exception classes that inherit from the above mentioned classes. E.g as follows:

CLASS zdmo_cx_rap_gen_custom_entity DEFINITION<br> 

 PUBLIC

  INHERITING FROM cx_rap_query_provider

and you can raise an exception in your implementation as follows:

 TRY.

....

CATCH cx_root INTO DATA(exception).

DATA(exception_message) = cl_message_helper=>get_latest_t100_exception( exception )->if_message~get_longtext( ).

DATA(exception_t100_key) = cl_message_helper=>get_latest_t100_exception( exception )->t100key.
RAISE EXCEPTION TYPE zdmo_cx_rap_gen_custom_entity
    EXPORTING
          textid   = VALUE scx_t100key( 
          msgid = exception_t100_key-msgid
          msgno = exception_t100_key-msgno                                          
          attr1 = exception_t100_key-attr
          attr2 = exception_t100_key-attr2
          attr3 = exception_t100_key-attr3
          attr4 = exception_t100_key-attr4 )
          previous = exception.
ENDTRY.
lkemr
Explorer
0 Kudos

Thank you very much for the answer Andre. This helps to prevent dump while runtime.

Kaden
Discoverer
0 Kudos

When using this solution, it work as intended apart from the fact that all of the variables I pass it are surrounded by ampersands in the message. Here is an example:

"Invalid Fiscal year: &2025& !"