cancel
Showing results for 
Search instead for 
Did you mean: 

OData: Unable to create working get_entity method (RFC nore ABAP)

Former Member
0 Kudos

Hello,

I have created a simple table for testing purposes...

and wan to implement the get_entity method in SEGW for this.

I have a RFC that gets the 2 key's and returns the matching entry.


SELECT SINGLE *  FROM ZORDER

  INTO ORDERRETURN

  WHERE ORDERADVENCO = ORDERADVENCOINPUT and POSITIONADVENCO = POSITIONADVENCOINPUT.


I attempt to call it with /sap/opu/odata/sap/ZORDER_RFC_SRV/OrderSet(Orderadvencoinput='10100', Positionadvencoinput='10') , but get

the error 400: Bad request.

My metadata returns the following:


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

<edmx:Edmx xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">

-<edmx:DataServices m:DataServiceVersion="2.0">

-<Schema xml:lang="en" xmlns="http://schemas.microsoft.com/ado/2008/09/edm" sap:schema-version="1" Namespace="ZORDER_RFC_SRV">

-<EntityType sap:content-version="1" Name="Order">

-<Key>

<PropertyRef Name="Orderadvencoinput"/>

<PropertyRef Name="Positionadvencoinput"/>

</Key>

<Property Name="Orderreturn" Nullable="false" Type="ZORDER_RFC_SRV.Orderreturn"/>

<Property Name="Orderadvencoinput" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Positionadvencoinput" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

</EntityType>

-<ComplexType Name="Orderreturn">

<Property Name="Orderadvenco" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Positionadvenco" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Outcome" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Plantitem" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Progress" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Status" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Targetquantity" Nullable="false" Type="Edm.Int32" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="INT"/>

<Property Name="Targettime" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

<Property Name="Unit" Nullable="false" Type="Edm.String" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatable="false" sap:label="Char" MaxLength="60"/>

</ComplexType>

-<EntityContainer Name="ZORDER_RFC_SRV_Entities" sap:supported-formats="atom json xlsx" m:IsDefaultEntityContainer="true">

<EntitySet sap:content-version="1" Name="OrderSet" sap:updatable="false" sap:creatable="false" sap:pageable="false" sap:deletable="false" EntityType="ZORDER_RFC_SRV.Order"/>

</EntityContainer>

<atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="http://vhcala4hci.wdf.sap.corp:50000/sap/opu/odata/sap/ZORDER_RFC_SRV/$metadata" rel="self"/>

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

</Schema>

</edmx:DataServices>

</edmx:Edmx>

I have also attempted to code the method myself:


  method ORDERSET_GET_ENTITY.

DATA:  lt_keys TYPE /iwbep/t_mgw_tech_pairs,

        ls_key TYPE /IWBEP/S_MGW_TECH_PAIR,

        lv_ORDERADVENCO   TYPE zorder-ORDERADVENCO,

        lv_POSITIONADVENCO  TYPE zorder-POSITIONADVENCO,

        ls_order TYPE  zorder.

        lt_keys = io_tech_request_context->get_keys( ).

        READ TABLE lt_keys with key name = 'Orderadvenco' into ls_key.

         lv_ORDERADVENCO = ls_key-value.

        READ TABLE lt_keys with key name = 'Positionadvenco' into ls_key.

         lv_POSITIONADVENCO = ls_key-value.

  SELECT SINGLE *

  FROM ZORDER

  INTO ls_order

  WHERE ORDERADVENCO = lv_ORDERADVENCO and POSITIONADVENCO = lv_POSITIONADVENCO.

IF sy-subrc = 0.

    er_entity-ORDERADVENCO = ls_order-ORDERADVENCO.

  ENDIF.

endmethod.

But in this case the lv_ORDERADVENCO and lv_POSITIONADVENCO dont seem to get any value. This making the sy-subrc = 4, and thus failing.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

One thing that also confuses me are the values isnside the Orderadvenco and Positionadvenco....

I tryed converting them from hex to text, but nothing readable.

0 Kudos

Can you show me the data inside lt_keys?

Former Member
0 Kudos

Yes...

0 Kudos

Hi,

I mean the value inside the internal table lt_keys.

Former Member
0 Kudos

How can I access those?

0 Kudos

double click over(in debugging) the lt_keys...i jest need to see what data is inside that table.

Former Member
0 Kudos

But that is what I did in the image... lt_keys seems to be empty.

0 Kudos

Hi,

Your internal table lt_keys has 2 records(that is the reason u have 2X2 ) i want to see those 2 records.

To view the records inside it you need to double click over the lt_keys under the variable tab.

Former Member
0 Kudos

Here it is:

The values are:

1. ORDERADVENCO 10100;

2. POSITIONADVENCO 10;

... so the values that I have passed to the method are in there.

So the problem was in the uppercase writing.

  1. READ TABLE lt_keys with key name = 'Orderadvenco' into ls_key. 
  2.         READ TABLE lt_keys with key name = 'Positionadvenco' into ls_key. 

Thank you.

0 Kudos

that was exactly what i was coming at

Answers (1)

Answers (1)

Former Member
0 Kudos

Okay the problem was in the call.... The parameter names were wrong. I corrected that but it still does not work.

My call:

/sap/opu/odata/SAP/ZORDER_RFC_SRV_01/OrderSet(Orderadvenco='10100',Positionadvenco='10')

My error:

<code>/IWBEP/CX_MGW_BUSI_EXCEPTION</code>

<message>Resource not found for segment 'Order'</message>

My debugger:

The values for Orderadvenco and Positionadvenco are those weired 200200200200... values.

0 Kudos

Are you able to get the Meta data?

Thanks,

Sundar.

Former Member
0 Kudos

Hello Sundar,

Yes I can...

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

<edmx:Edmx xmlns:sap="http://www.sap.com/Protocols/SAPData" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0"><edmx:DataServices m:DataServiceVersion="2.0"><Schema xml:lang="en" xmlns="http://schemas.microsoft.com/ado/2008/09/edm" sap:schema-version="1" Namespace="ZORDER_SRV"><EntityType sap:content-version="1" Name="Order"><Key><PropertyRef Name="Orderadvenco"/><PropertyRef Name="Positionadvenco"/></Key><Property Name="Orderadvenco" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:...<Property Name="Positionadvenco" sap:filterable="false" sap:sortable="false" sap:updatable="false" s...<Property Name="Outcome" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creat...<Property Name="Plantitem" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:cre...<Property Name="Progress" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:crea...<Property Name="Status" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creata...<Property Name="Targetquantity" sap:filterable="false" sap:sortable="false" sap:updatable="false" sa...<Property Name="Targettime" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:cr...<Property Name="Unit" sap:filterable="false" sap:sortable="false" sap:updatable="false" sap:creatabl...</EntityType><EntityContainer Name="ZORDER_SRV_Entities" sap:supported-formats="atom json xlsx" m:IsDefaultEntity...<EntitySet sap:content-version="1" Name="OrderSet" sap:updatable="false" sap:creatable="false" sap:p...</EntityContainer><atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="http://vhcala4hci.wdf.sap.corp:50000/sap/opu/odata/SAP/ZORDER_SRV/$metadata" rel="self"/><atom:link xmlns:atom="http://www.w3.org/2005/Atom" href="http://vhcala4hci.wdf.sap.corp:50000/sap/opu/odata/SAP/ZORDER_SRV/$metadata" rel="latest-version"/></Schema></edmx:DataServices></edmx:Edmx>

Former Member
0 Kudos

...also,

when I call:

/sap/opu/odata/SAP/ZORDER_SRV/OrderSet

I get all the data from the table (as expected), and this interesting detail:

<id>http://vhcala4hci.wdf.sap.corp:50000/sap/opu/odata/SAP/ZORDER_SRV/OrderSet(Orderadvenco='10100',Posi...')</id>

but when I attempt to call that link it ends up in the same error as above.

0 Kudos

May be you should clear the cache


Goto /IWFND/CACHE_CLEANUP

Thanks,

Sundar.

Former Member
0 Kudos

...no effect.

I have also done this guide/tutorial, and I run into the same error.

0 Kudos

The reason for the failure of the call is mostly of two reasons,

1. Due to the incorrect name of the segment in the call.

    That is the reason i asked for meta data your  calling name is same as in Metadata.

2. Due to cache reason.

     so we cleared the cache.

So i suggest you can regenerate the project in SEGW.

Or try transaction /IWFND/MAINT_SERVICE, select your service, and click the LOAD METADATAand REFRESH CATALOG button, it should correct this issue.

Former Member
0 Kudos

I have tried it, but I still get the same error.