cancel
Showing results for 
Search instead for 
Did you mean: 

Odata expanded structure shows outside entity

perage
Participant
0 Kudos

Hi,

I have developed an entityset with an expanded structure. The problem is that the expanded rows (UoMs) are added outside the entity instead of nested as part of the entity.

Can anyone suggest what I've done wrong?

Product entity:

UOM entity

Navigation:

Association

Code get_expanded_entityset

  METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.

    TYPES: BEGIN OF structure.
             INCLUDE TYPE /zzz/cl_pos_api_mpc=>ts_product.
    TYPES units TYPE /zzz/pos_units.
    TYPES END OF structure.

    DATA: table TYPE TABLE OF structure.
    DATA(obj) = NEW zcl_pos_products( ).
    DATA(products) = obj->/zzz/if_pos_products~get_products( ).

  LOOP AT products ASSIGNING FIELD-SYMBOL(<product>).

      APPEND INITIAL LINE TO table ASSIGNING FIELD-SYMBOL(<line>).
      <line> = CORRESPONDING #( <product>  ).
      <line>-units = VALUE #( ( ean = '123456789' unit = 'PCE' ) ( ean = '95167961' unit = 'PCE' ) ).
    ENDLOOP.

    copy_data_to_ref(
      EXPORTING
        is_data = table
      CHANGING
        cr_data = er_entityset
    ).
    APPEND 'UNITS' TO et_expanded_tech_clauses.

Output

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://<removed>/sap/opu/odata/zzz/pos_api_srv/">
    <id>http://<removed>/sap/opu/odata/zzz/pos_api_srv/Products</id>
    <title type="text">Products</title>
    <updated>2020-10-20T08:41:50Z</updated>
    <author>
        <name/>
    </author>
    <link href="Products" rel="self" title="Products"/>
    <entry>
        <id>http://<removed>/sap/opu/odata/zzz/pos_api_srv/Products('000000000001027790')</id>
        <title type="text">Products('000000000001027790')</title>
        <updated>2020-10-20T08:41:50Z</updated>
        <category term="ZZZ.POS_API_SRV.Product" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
        <link href="Products('000000000001027790')" rel="self" title="Product"/>
        <link href="Products('000000000001027790')/Units" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Units" type="application/atom+xml;type=feed" title="Units">
            <m:inline>
                <feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://<removed>/sap/opu/odata/zzz/pos_api_srv/">
                    <id>http://<removed>/sap/opu/odata/zzz/pos_api_srv/Products('000000000001027790')/Units</id>
                    <title type="text">UOMCollection</title>
                    <updated>2020-10-20T08:41:50Z</updated>
                    <author>
                        <name/>
                    </author>
                    <link href="Products('000000000001027790')/Units" rel="self" title="UOMCollection"/>
                </feed>
            </m:inline>
        </link>
        <link href="Products('000000000001027790')/Searchwords" rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Searchwords" type="application/atom+xml;type=feed" title="Searchwords"/>
        <content type="application/xml">
            <m:properties xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
                <d:Id>000000000001027790</d:Id>
                <d:Group>99999999</d:Group>
                <d:Title>VA 40x45/4 kunde</d:Title>
                <d:Description></d:Description>
                <d:Manufacturer></d:Manufacturer>
                <d:ManufacturerPartNumber></d:ManufacturerPartNumber>
                <d:GrossPrice>0.000</d:GrossPrice>
                <d:NetPrice>0.000</d:NetPrice>
                <d:Vat>0.000</d:Vat>
                <d:SalesUnit></d:SalesUnit>
                <d:ImageUrl>file://c:\data\zzz\1027790</d:ImageUrl>
                <d:RequireSn>false</d:RequireSn>
                <d:SellCount>0</d:SellCount>
            </m:properties>
        </content>
    </entry>
</feed>

Accepted Solutions (0)

Answers (0)