alok pradhan
alok pradhan

Reputation: 1

READ Method is not triggering for SAP RAP Service Read Call

I have a requirement to implement Read Method for SAP RAP Service. In the Read call I need to send message-based condition. But created Behavioral Definition for the same but the method is not triggering. Please let me know what I am missing ?

I tried to execute with read call, data is coming but no error message https://1374dadc-372f-46e3-a692-b2bd57ae0ee4.abap-web.us10.hana.ondemand.com/sap/opu/odata4/sap/yap_testview_srv_o4/srvd/sap/yap_testview_srv/0001/YAP_CDS_VIEW_NEW1.

Thanks in advance Alok

unmanaged;
//strict ( 2 );

define behavior for YAP_CDS_VIEW_NEW1 alias Testview
 implementation in class zbp_ap_cds_view_new1 unique
//persistent table zfe_atrav_001031
//lock master
authorization master ( instance )
//etag master <field_name>
{


}

Class Implementation

CLASS lhc_YAP_CDS_VIEW_NEW1 DEFINITION INHERITING FROM cl_abap_behavior_handler.
  PRIVATE SECTION.

  data: keys TYPE TABLE FOR READ IMPORT yap_cds_view_new1,
       result TYPE TABLE FOR READ RESULT yap_cds_view_new1.

    METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
      IMPORTING keys REQUEST requested_authorizations FOR yap_cds_view_new1 RESULT result.

    METHODS read FOR READ
        IMPORTING keys FOR READ yap_cds_view_new1
        RESULT result.

ENDCLASS.

CLASS lhc_YAP_CDS_VIEW_NEW1 IMPLEMENTATION.

  METHOD get_instance_authorizations.

  READ ENTITIES OF yap_cds_view_new1 IN LOCAL MODE
    ENTITY Testview
    ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(results).

    DATA(lresult) =  results[ 1 ].

    APPEND VALUE #(  %tky = lresult-%tky ) TO failed-Testview.

    APPEND VALUE #( %tky        = lresult-%tky
                    %msg        = new_message_with_text(

                         severity = if_abap_behv_message=>severity-error
                         text = 'No Data Found' )
                          )
            TO reported-Testview.
  ENDMETHOD.

  METHOD read.

  READ ENTITIES OF yap_cds_view_new1 IN LOCAL MODE
    ENTITY Testview
    ALL FIELDS WITH CORRESPONDING #( keys )
    RESULT DATA(results).

    DATA(lresult) =  results[ 1 ].

    APPEND VALUE #(  %tky = lresult-%tky ) TO failed-Testview.

    APPEND VALUE #( %tky        = lresult-%tky
                    %msg        = new_message_with_text(

                         severity = if_abap_behv_message=>severity-error
                         text = 'No Data Found' )
                          )
            TO reported-Testview.

  ENDMETHOD.

ENDCLASS.

Upvotes: 0

Views: 474

Answers (1)

rcaziraghi
rcaziraghi

Reputation: 1

So I've looked into this and, if you've implemented an unmanaged BO (this is NOT QUERY), the "READ" method will only be triggered after Create / Update / Delete operation is executed, as the "Read modified entities" phase. A query scenario would trigger a "Select" method of our API if_rap_query_provider. The READ method of the BDef implementation, however, belongs to the transactional scenarios, not to the query case.

Basically, despite its name suggesting general read functionality, it does not handle initial data retrieval or general query operations.

Upvotes: 0

Related Questions