cancel
Showing results for 
Search instead for 
Did you mean: 

IT_KEY_TAB in GET_Entityset method

Former Member
0 Kudos

Hi All,

I have implemented GET_ENTITYSET method and I would like to invoke this method with IT_KEY_TAB filled.

Does anybody help how should I invoke GET_ENTITYSET method where I have values in IT_KEY_TAB?

I tried /sap/opu/odata/sap/ZGW_EPM_SALES_ORDER_SRV/SalesOrder(SoID='500000002') but it is invoking GET_ENTITY method and passing IT_KEY_TAB there but I want to invoke GET_ENTITYSET method.

Entity Set - SalesOrder in my case and Key is SoID.

MetaData -

<?xml version="1.0" encoding="utf-8" ?>

- <edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">

- <edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

- <Schema Namespace="ZGW_EPM_SALES_ORDER_SRV" xml:lang="en" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

- <EntityType Name="SalesOrder" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData">

- <Key>

<PropertyRef Name="SoID" />

</Key>

<Property Name="SoID" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Sa. Ord. ID" />

<Property Name="CurrencyCode" Type="Edm.String" Nullable="false" MaxLength="5" sap:label="Currency" sap:semantics="currency-code" />

<Property Name="GrossAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Gross Amt." />

<Property Name="NetAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Net Amt." />

<Property Name="TaxAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Tax Amt." />

<NavigationProperty Name="SalesOrderItems" Relationship="ZGW_EPM_SALES_ORDER_SRV.OrderItems" FromRole="FromRole_OrderItems" ToRole="ToRole_OrderItems" />

</EntityType>

- <EntityType Name="SalesOrderItems" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData">

- <Key>

<PropertyRef Name="SoID" />

<PropertyRef Name="SoItemPos" />

</Key>

<Property Name="SoID" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Sa. Ord. ID" />

<Property Name="SoItemPos" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="PO Item Pos" />

<Property Name="ProductID" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Product ID" />

<Property Name="Note" Type="Edm.String" Nullable="false" MaxLength="255" sap:label="Description" />

<Property Name="CurrencyCode" Type="Edm.String" Nullable="false" MaxLength="5" sap:label="Currency" sap:semantics="currency-code" />

<Property Name="GrossAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Gross Amt." />

<Property Name="GrossAmountExt" Type="Edm.Decimal" Nullable="false" Precision="12" Scale="4" sap:label="Amount" />

<Property Name="NetAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Net Amt." />

<Property Name="NetAmountExt" Type="Edm.Decimal" Nullable="false" Precision="12" Scale="4" sap:label="Amount" />

<Property Name="TaxAmount" Type="Edm.Decimal" Nullable="false" Precision="15" Scale="14" sap:label="Tax Amt." />

<Property Name="TaxAmountExt" Type="Edm.Decimal" Nullable="false" Precision="12" Scale="4" sap:label="Amount" />

<Property Name="DeliveryDate" Type="Edm.DateTime" Nullable="false" sap:label="Time Stamp" />

<Property Name="Quantity" Type="Edm.Decimal" Nullable="false" Precision="7" Scale="3" sap:label="Quantity" />

<Property Name="QuantityUnit" Type="Edm.String" Nullable="false" MaxLength="3" sap:label="Qty. Unit" sap:semantics="unit-of-measure" />

</EntityType>

- <Association Name="OrderItems" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData">

<End Type="ZGW_EPM_SALES_ORDER_SRV.SalesOrder" Multiplicity="1" Role="FromRole_OrderItems" />

<End Type="ZGW_EPM_SALES_ORDER_SRV.SalesOrderItems" Multiplicity="*" Role="ToRole_OrderItems" />

- <ReferentialConstraint>

- <Principal Role="FromRole_OrderItems">

<PropertyRef Name="SoID" />

</Principal>

- <Dependent Role="ToRole_OrderItems">

<PropertyRef Name="SoID" />

</Dependent>

</ReferentialConstraint>

</Association>

- <EntityContainer Name="ZGW_EPM_SALES_ORDER_SRV" m:IsDefaultEntityContainer="true">

<EntitySet Name="SalesOrderItems" EntityType="ZGW_EPM_SALES_ORDER_SRV.SalesOrderItems" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData" />

<EntitySet Name="SalesOrder" EntityType="ZGW_EPM_SALES_ORDER_SRV.SalesOrder" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData" />

- <AssociationSet Name="OrderItems" Association="ZGW_EPM_SALES_ORDER_SRV.OrderItems" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:content-version="1" xmlns:sap="http://www.sap.com/Protocols/SAPData">

<End EntitySet="SalesOrder" Role="FromRole_OrderItems" />

<End EntitySet="SalesOrderItems" Role="ToRole_OrderItems" />

</AssociationSet>

</EntityContainer>

<atom:link rel="self" href="<>:8000/sap/opu/odata/sap/ZGW_EPM_SALES_ORDER_SRV/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />

<atom:link rel="latest-version" href="<>/sap/opu/odata/sap/ZGW_EPM_SALES_ORDER_SRV/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />

</Schema>

</edmx:DataServices>

</edmx:Edmx>

Regards,

Sid

Accepted Solutions (0)

Answers (4)

Answers (4)

AshwinDutt
Active Contributor

Hello Sid,

To invoke Get Entity Set method you need to pass inputs as filters and read those filters.

/sap/opu/odata/sap/ZGW_EPM_SALES_ORDER_SRV/SalesOrder?$filter=SoID eq '500000002'

DATA: my_filter_options TYPE/iwbep/t_mgw_select_option,
my_filter_options
=io_tech_request_context->get_filter( )->get_filter_select_options( ).

To invoke Get Entity method you need to pass inputs as key's and read those keys.

/sap/opu/odata/sap/ZGW_EPM_SALES_ORDER_SRV/SalesOrder(SoID='500000002')


DATA: lt_keys TYPE/iwbep/t_mgw_tech_pairs.
lt_keys
=io_tech_request_context->get_keys( ).


I am not sure why you would still need keys to be read when you are already sending input as filters and can be read with above mentioned code for Get Entity Set.


Regards,

Ashwin

alex_campbell
Contributor
0 Kudos

Very old post, but it's the first google result when searching for "IT_KEY_TAB" and "GET_ENTITYSET" so I thought it was worth submitting a helpful answer...

In cases where you're navigating a 1-to-many association (for example if your path was something like ".../OrderSet('10001234')/Items") then the keys from the source entityset (in my example, OrderId 10001234) will be passed in IT_KEY_TAB, and not as a filter value.

So if your service implements such a 1-to-many association you should take care to implement your selection logic based on the given key, and you can use that association to test it.

AbhishekSharma
Active Contributor
0 Kudos

Hi Siddharth,

I will not repeat same thing again to use Filters for sending values to Gateway Service as suggested by Ashwin Dutt R and Gowtham Raja M

Let me tel you how you can use this Filter Option and make your application work:

See below code :

var filterJson = [],

  pTypeFilterJson = [];

  var oFilter1 = new sap.ui.model.Filter("<your field name1>", sap.ui.model.FilterOperator.EQ, custID);

  filterJson.push(oFilter1);

  var oFilter2 = new sap.ui.model.Filter("<your field name2>", sap.ui.model.FilterOperator.EQ, ordID);

  filterJson.push(oFilter2);

var allFilter = new sap.ui.model.Filter(filterJson, true);      //true will add AND condition in betewwn parameter if you want OR condition then pass false.

//Finally set Filter

  oComponent.setFilter(allFilter, true);

//If you want to navigate to some other View use below lines else you are done for UI5 changes.

  var router = new sap.ui.core.UIComponent.getRouterFor(this);

  router.navTo("order_listing");

Now lets see how you can access these parameters in your Gateway methods:

Go to your *DPC_EXT method.

use below code to get Filter values

Data:

lt_filters            TYPE                   /iwbep/t_mgw_select_option,

ls_filter             TYPE                   /iwbep/s_mgw_select_option, " MGW Framework: Selection

Option Parameters for db selects

*-->get filter

  lt_filters = io_tech_request_context->get_filter( )->get_filter_select_options( ).

lt_filters will get all your Filter values which you have send.


Now you can read values from lt_filters as below

READ TABLE lt_filters WITH TABLE KEY property = '<Parameter Name>' INTO ls_filter.

if sy-subrc is initial.

// your code will be here

endif.

Thanks-

Abhishek


GowthamRaja
Participant
0 Kudos

Hi Siddharth,

In the URL you are giving the inputs with in phrases,so that it will call get_entity.... In order to proceed with get_entityset method, the url inputs should be given with filter options as Ashwin said.

Thanks,

Gowtham