cancel
Showing results for 
Search instead for 
Did you mean: 

Disable fields from Odata service output

3,523

Hello all,

I have 5 properties in entity type....

For e.g.

1. Client ID 2. Support Group 3.Region 4.State 5.City

Out of these 5 properties,I want only 4 properties i.e. Support Group,Region,State and City in the output.

In my RFC FM the Client ID is import parameter while others are export parameters.

When i generate the service, the ET_ENTITYSET internal table is having the structure similar to the entity type.

When i exceute the service ,I have to pass the ClientID as the input option.

.........?$filter=ClntId eq 'ETA'

But this should not come into the output....

Kindly help me in providing solution how can i acheive the service output without the Client ID in the output.

Code snippets would be of great help!!

Thanks,

Akil Syed

View Entire Topic
bharatbajaj
Active Participant
0 Kudos

Hi,

You can disable the property in the DEFINE method of the MPC_EXT Class.

Refer Below Code :

  METHOD define.
    TRY.
        super->define( ).
**Get the Object instance of the Entity Type
        DATA(lo_entity_type) = model->get_entity_type( '<EntityType>' ).

        IF lo_entity_type IS BOUND.
**Get the Object instance of the Property of Entity Type
          DATA(lo_entity_prop) = lo_entity_type->get_property( '<PropertyName>' ).

          IF lo_entity_prop IS BOUND.
**Set the Property as Disabled
            lo_entity_prop->set_disabled( iv_disabled = abap_true ).
          ENDIF.

        ENDIF.

      CATCH /iwbep/cx_mgw_med_exception.
    ENDTRY.

  ENDMETHOD.

Replace the <EntityType> and <PropertyName>, with the actual values as per your service.

Hope this works for you.

Regards,

Bharat Bajaj