cancel
Showing results for 
Search instead for 
Did you mean: 

Adding extra field to

Former Member
0 Kudos

Hi Guys,

Got another problem, hopefully someone can help me with this. I have implemented this document, and everything is working. However, I like to add an extra field to the Header type, which is the description of the type of document. This is the BEZEI field in the TVAKT table. However, I've added this field to all the possible classes and types, but it still does not show up in my Odata service. Do I have to activate somewhere or something else?

I have adjusted the following files:

Z_SALESORDER_MODEL_XX:

     TYPE S_SO_HDR

     METHOD DEFINE

Z_SALESORDER_HDR_DATA_XX:
     METHOD GET_ENTITYSET

     TYPE S_VBAK

It does not show up in my $Metadata file either.If you have any experience with this please let me know!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

To more precise: When I tried to replace one of the original fields from the example with the BEZEI field from the TVAKT table, I get the following error in the gateway:

The RFC call was not successful because of system failure 'Syntax error in program Z_SALESORDER_DATA_00==========CP   
wbrown
Participant
0 Kudos

Hello IJsbrand van Rijn,

Can you try and go to the IMG (transaction /nspro) and check the metadata cache.

SAP NetWeaver -> Gateway -> OData Channel -> Administration -> Cache Settings -> Metadata -> Activate or Deactivate Cache.

Execute the Activate or Deactivate Cache. If it says it already deactivated, reactivate it first, then deactivate it right away again. (Sometimes it seems to get stuck). You can also try the Clear Cache as the next activity.

Regards,

Wayne

Former Member
0 Kudos

Thanks to Wayne Brown I solved the problem. Only problem left now is that I get the descriptions in a strange language, but that is something else (I have to retrieve the description in English).Just used the statement spras = 'EN' Thanks everyone for the input!

Former Member
0 Kudos

Good call Wayne, I forgot about this and had this problem way back when we first put in Gateway. But I haven't had the problem with SP03.

Former Member
0 Kudos

We have only SP2 on the gateway server, but this would be a good reason to ask if they are willing to update to SP3!

Answers (1)

Answers (1)

SyambabuAllu
Contributor
0 Kudos

Dear Van,

First u can add the field in Entity of that structure and then populated the value into output structure .

May be it will helpful...I got the same problem.

Thanks,

Syam

Former Member
0 Kudos

Hi Syam,

can you please elaborate on your answer? I do not quite understand it.

Greets,

IJsbrand van Rijn

SyambabuAllu
Contributor
0 Kudos

Hi Van,

lo_property = lo_entity_type->create_property( 'DocumentType' ).

lo_property = lo_entity_type->create_property( 'DocumentDate' ).

lo_property = lo_entity_type->create_property( 'CustomerId' ).

lo_property = lo_entity_type->create_property( 'SalesOrg' ).

lo_property = lo_entity_type->create_property( 'DistChannel' ).

lo_property = lo_entity_type->create_property( 'Division' ).

lo_property = lo_entity_type->create_property( 'OrderValue' ).

lo_property = lo_entity_type->create_property( 'Currency' ).

"""Adding here that field and bind that field into Entity.

Thanks,

Syam.

Former Member
0 Kudos

Hi Syam,

I did this already:

lo_property = lo_entity_type->create_property( 'DocumentType' ).
lo_property = lo_entity_type->create_property( 'DocumentDate' ).
lo_property = lo_entity_type->create_property( 'CustomerId' ).
lo_property = lo_entity_type->create_property( 'SalesOrg' ).
lo_property = lo_entity_type->create_property( 'DistChannel' ).
lo_property = lo_entity_type->create_property( 'Division' ).
lo_property = lo_entity_type->create_property( 'OrderValue' ).
lo_property = lo_entity_type->create_property( 'Currency' ).
lo_property = lo_entity_type->create_property( 'DocumentDesc' ).

  * Bind your structure that represents the above properties
lo_entity_type->bind_structure( 'Z_SALESORDER_MODEL_00=>S_SO_HDR' ).

And at the Get_Entityset method I implemented this to fill this field:


loop at lt_vbak into ls_vbak.
     ls_sohdr-OrderId = ls_vbak-vbeln.
     ls_sohdr-DocumentType = ls_vbak-auart.
     ls_sohdr-DocumentDate = ls_vbak-audat.
     ls_sohdr-CustomerId = ls_vbak-kunnr.
     ls_sohdr-SalesOrg = ls_vbak-vkorg.
     ls_sohdr-DistChannel = ls_vbak-vtweg.
     ls_sohdr-Division = ls_vbak-spart.
     ls_sohdr-OrderValue = ls_vbak-netwr.
     ls_sohdr-Currency = ls_vbak-waerk.
  select bezei from tvakt
       into ls_sohdr-DocumentDesc
       where auart = ls_vbak-auart.
   endselect.
     append ls_sohdr to <fs_sohdrs>.
   endloop.

But still it won't show up in my gateway service, even not in the metadata.

Greets,

IJsbrand van Rijn

Former Member
0 Kudos

Something is going on if it's not even showing up in the metadata of the service...are you sure you activated the entire Z_SALESORDER_MODEL_XX class?

Regardless of what is in the get_entityset method, changing the model class should show up in the metadata of the service.

Maybe post the entire contents of the model class and the data provider class and we can narrow the problem down.

Former Member
0 Kudos

Hi Mike,

below you find the entire code of the DEFINE method from the Z_SALES_ORDER_MODEL_00 class.

method DEFINE.
DATA: lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
       lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set,
       lo_association TYPE REF TO /iwbep/if_mgw_odata_assoc,
       lo_nav_property TYPE REF TO /iwbep/if_mgw_odata_nav_prop,
       lo_property TYPE REF TO /iwbep/if_mgw_odata_property.

*-----------------------------------------------------------------------------
* Sales Order Header
*-----------------------------------------------------------------------------

* Create the SalesOrderHeader data object
lo_entity_type = model->create_entity_type( 'SOHeader' ).

* Define the properties of the SalesOrderHeader object
lo_property = lo_entity_type->create_property( 'OrderId' ).

* set it as a key element
lo_property->set_is_key( ).

lo_property = lo_entity_type->create_property( 'DocumentType' ).
*  LINE BELOW IS FOR ADDING TEXTUAL DESCRIPTION OF DOCUMENT TYPE (NOT WORKING)
lo_property = lo_entity_type->create_property( 'DocumentDesc' ).
lo_property = lo_entity_type->create_property( 'DocumentDate' ).
lo_property = lo_entity_type->create_property( 'CustomerId' ).
lo_property = lo_entity_type->create_property( 'SalesOrg' ).
lo_property = lo_entity_type->create_property( 'DistChannel' ).
lo_property = lo_entity_type->create_property( 'Division' ).
lo_property = lo_entity_type->create_property( 'OrderValue' ).
lo_property = lo_entity_type->create_property( 'Currency' ).



* Bind your structure that represents the above properties
lo_entity_type->bind_structure( 'Z_SALESORDER_MODEL_00=>S_SO_HDR' ).

* Name for the collection
lo_entity_type->create_entity_set( 'SOHeaders' ).

*-----------------------------------------------------------------------------
* Sales Order Item
*-----------------------------------------------------------------------------

* Create the SalesOrderItem data object
lo_entity_type = model->create_entity_type( 'SOItem' ).

* Define the properties of the SalesOrderItem object
lo_property = lo_entity_type->create_property( 'OrderId' ).

* set it as a key element
lo_property->set_is_key( ).
lo_property = lo_entity_type->create_property( 'Item' ).

* set it as a key element
lo_property->set_is_key( ).
lo_property = lo_entity_type->create_property( 'Material' ).
lo_property = lo_entity_type->create_property( 'Description' ).
lo_property = lo_entity_type->create_property( 'Plant' ).
lo_property = lo_entity_type->create_property( 'Quantity' ).
lo_property = lo_entity_type->create_property( 'UoM' ).
lo_property = lo_entity_type->create_property( 'Value' ).

* Bind your structure that represents the above properties
lo_entity_type->bind_structure( 'Z_SALESORDER_MODEL_00=>S_SO_ITEM' ).

lo_entity_type->create_entity_set( 'SOItems' ).

******************************************************************************
* ASSOCIATIONS
******************************************************************************
"Define Association SO Header to SO Items
lo_association = model->create_association(
iv_association_name = 'SOHeader_SOItems'
iv_left_type = 'SOHeader'
iv_right_type = 'SOItem'
iv_right_card = cardinality_feed
iv_left_card = cardinality_entity ).

"Define Association SO Item to SO Header
lo_association = model->create_association(
iv_association_name = 'SOItem_SOHeader'
iv_left_type = 'SOItem'
iv_right_type = 'SOHeader'
iv_right_card = cardinality_entity
iv_left_card = cardinality_entity ).

******************************************************************************
* NAVIGATION PROPERTIES
******************************************************************************
"Navigation Properties for entity SO Header
lo_entity_type = model->get_entity_type( iv_entity_name = 'SOHeader' ).

"Add Navigation Property from role SOHeader to role SOItems
lo_entity_type->create_navigation_property(
iv_property_name = 'SOItems'
iv_association_name = 'SOHeader_SOItems' ).

"Navigation Properties for entity SO Item
lo_entity_type = model->get_entity_type( iv_entity_name = 'SOItem' ).

"Add Navigation Property from role SOItem to SOHeader
lo_entity_type->create_navigation_property(
iv_property_name = 'SOHeader'
iv_association_name = 'SOItem_SOHeader' ).
endmethod.