cancel
Showing results for 
Search instead for 
Did you mean: 

Read fields of view entity in Custom entity

ankit_gusain
Explorer
0 Kudos

I have one requirement to create Search Help in RAP model. in Item entity I have two fields based on which I want to fetch data. For eg. if profit center field is not initial then fetch from table1 elseif cost center is not initial then fetch from table2 else fetch from table3. How to write such logic? Am I suppose to write in my custom entity class? How will I access Item entity fields in my custom class for fetching data

if there is any other way please let me know.

Marissa
Advisor
Advisor

We helped you to accept the answer, since there were no updates after 7 days.

You can unaccept it anytime if you have further questions.

Accepted Solutions (1)

Accepted Solutions (1)

Ramjee_korada
Active Contributor

Hello Ankit,

It can be done in 2 steps.

  1. Additional binding => So, the item level fields can be mapped to filters of the value help

  2. Custom entity implementation => Read those values as filters and the apply custom logic.
   METHOD if_rap_query_provider~select.
    DATA business_data TYPE t_business_data.
    DATA(top)     = io_request->get_paging( )->get_page_size( ).
    DATA(skip)    = io_request->get_paging( )->get_offset( ).
    DATA(requested_fields)  = io_request->get_requested_elements( ).
    DATA(sort_order)    = io_request->get_sort_elements( ).
    DATA count TYPE int8.
    TRY.
        DATA(filter_condition) = io_request->get_filter( )->get_as_ranges( ).

 		<< custom logic to retrieve results based on filters >>

        IF io_request->is_total_numb_of_rec_requested(  ).
          io_response->set_total_number_of_records( count ).
        ENDIF.
        IF io_request->is_data_requested(  ).
          io_response->set_data( business_data ).
        ENDIF.

      CATCH cx_root INTO DATA(exception).
        DATA(exception_message) = cl_message_helper=>get_latest_t100_exception( exception )->if_message~get_longtext( ).
    ENDTRY.
  ENDMETHOD. 

Best wishes,

Ramjee Korada

ankit_gusain
Explorer
0 Kudos

Hello Ramjee,

I tried this but it didn't work. filter_condition was initial in custom entity class. Please check image below, it is one of my requirment. In this lwa_node_itemdetail-lfdat is coming from item. how to get this lfdat in custom entity class you know so that i can write this logic and display the data

Answers (0)