cancel
Showing results for 
Search instead for 
Did you mean: 

CREATE_DEEP_ENTITY method not triggered but create_entity?

Former Member
0 Kudos

Hi all,

Iam trying to update object with header and items to perform deep entity insert.But the create_entity method is only triggered and not the Create_deep_entity.


Head entity definition in MPC


*Head entity----------------------------------------------------------------

*-----------------------------------------------------------------------------------------

    lcr_delhead_entity = model->create_entity_type( 'delhead' )."delivery items

    "create needed properties of entity "Spool"

    build_props_by_structname( iv_structname = 'GOODS_RCPT_SI_S'

                               icr_entity = lcr_delhead_entity ).

    "enhance property behaviour

    lo_property = lcr_delhead_entity->get_property( iv_property_name = 'DEL_NUM' ).

    lo_property->set_is_key( ).

    lo_property->set_type_edm_string( ).

    lo_property = lcr_delivery_entity->get_property( iv_property_name = 'PRD_NUM' ).

    lo_property->set_is_key( ).

    lo_property->set_type_edm_string( ).

    lcr_delhead_entity->bind_structure( 'GOODS_RCPT_SI_S' ).

    "create entity sets of entity

    lcr_entity_set_del_head = lcr_delhead_entity->create_entity_set( 'deliveryhead' ).

    "set annotations for entity set behaviour

    lcr_entity_set_del_head->set_creatable( abap_true ).

    lcr_entity_set_del_head->set_updatable( abap_true ).

    lcr_entity_set_del_head->set_deletable( abap_true ).

    lcr_entity_set_del_head->set_addressable( abap_true ).

Item entity definition in MPC


* items entity----------------------------------------------------------------

*-----------------------------------------------------------------------------------------

    lcr_delivery_entity = model->create_entity_type( 'delitems' )."delivery items

    "create needed properties of entity "Spool"

    build_props_by_structname( iv_structname = 'GOODS_RCPT_SI_S'

                               icr_entity = lcr_delivery_entity ).

    "enhance property behaviour

    lo_property = lcr_delivery_entity->get_property( iv_property_name = 'DEL_NUM' ).

    lo_property->set_is_key( ).

    lo_property->set_type_edm_string( ).

    lo_property = lcr_delivery_entity->get_property( iv_property_name = 'PRD_NUM' ).

    lo_property->set_is_key( ).

    lo_property->set_type_edm_string( ).

    lo_property = lcr_delivery_entity->get_property( iv_property_name = 'DEL_ITEM_NUM' ).

    lo_property->set_is_key( ).

    lo_property->set_type_edm_string( ).

    lcr_delivery_entity->bind_structure( 'GOODS_RCPT_SI_S' ).

    "create entity sets of entity

    lcr_entity_set_del = lcr_delivery_entity->create_entity_set( 'deliverylist' ).

    "set annotations for entity set behaviour

    lcr_entity_set_del->set_creatable( abap_true ).

    lcr_entity_set_del->set_updatable( abap_true ).

    lcr_entity_set_del->set_deletable( abap_true ).

    lcr_entity_set_del->set_addressable( abap_true ).

Navigation and associations


***********************************************************************************************************************************

*   ASSOCIATIONS

***********************************************************************************************************************************

lo_association = model->create_association(

                            iv_association_name = 'delheadsettodelitemset' "#EC NOTEXT

                            iv_left_type        = 'delhead' "#EC NOTEXT

                            iv_right_type       = 'delitems' "#EC NOTEXT

                            iv_right_card       =  cardinality_feed"'N' "#EC NOTEXT

                            iv_left_card        =  cardinality_entity  )."#EC NOTEXT

                            "iv_def_assoc_set    = abap_false ). "#EC NOTEXT

  "item to head

  lo_association = model->create_association(

                            iv_association_name = 'delitemsettodeleadset' "#EC NOTEXT

                            iv_left_type        = 'delitems' "#EC NOTEXT

                            iv_right_type       = 'delhead' "#EC NOTEXT

                            iv_right_card       =  cardinality_entity"'N' "#EC NOTEXT

                            iv_left_card        =  cardinality_entity  )."#EC NOTEXT

                            "iv_def_assoc_set    = abap_false ). "#EC NOTEXT

***********************************************************************************************************************************

*   NAVIGATION PROPERTIES

***********************************************************************************************************************************

* Navigation Properties for entity - delhead

"lo_entity_type = model->get_entity_type( iv_entity_name = 'delhead' ). "#EC NOTEXT

lcr_delhead_entity->create_navigation_property( iv_property_name  = 'delheadtodellist' "#EC NOTEXT

                                                          iv_association_name = 'delheadsettodelitemset' ).

"lo_entity_type = model->get_entity_type( iv_entity_name = 'delitems' ). "#EC NOTEXT

lcr_delivery_entity->create_navigation_property( iv_property_name  = 'dellisttodelhdead' "#EC NOTEXT

                                                          iv_association_name = 'delitemsettodeleadset' ).

UI code to update the deep entity


  • my navigation name delheadtodellist



         var requestORderHeader = {}; 
             requestORderHeader.PRD_NUM = "01";
     requestORderHeader.DEL_NUM = "01";
     requestORderHeader.DEL_ITEM_NUM = "01";
     requestORderHeader.ARTI_NUM =  "P010";
     requestORderHeader.DEL_DESC = "200";
     requestORderHeader.SUB_DIV = null;
     requestORderHeader.COLL_TYPE = null;
     requestORderHeader.SEASON = null;
     requestORderHeader.MAIN_CLASS = null;
     requestORderHeader.CLASS = null;
     requestORderHeader.GEN_ARTI_NUM = null;
     requestORderHeader.DEL_QUAN = null;
     requestORderHeader.QUANTITY = null;
  
        var itemData = []; 
  
    itemData.push({ PRD_NUM: "01", DEL_NUM: "01" , DEL_ITEM_NUM: "01", ARTI_NUM: "P010", DEL_DESC: "200", SUB_DIV: null,  COLL_TYPE: null, SEASON: null, MAIN_CLASS: null, CLASS: null, GEN_ARTI_NUM: null, DEL_QUAN: null , QUANTITY: null }); 
  
        //my navigation name delheadtodellist
    requestORderHeader.delheadtodellist = itemData;

   // Retrieve model from controller  
        var oModel = sap.ui.getCore().getModel(); 
            oModel.create('/deliverylist',  
      requestORderHeader,  
      null,  
      function(oData, oResponse) {  
      debugger;
      alert ('Order creation succeed !'); 
      }, 
      function(error) {
      debugger;
      alert('Call service creation failed');  
      } 
      ); 

but still only create_entity method is called and not the CREATE_DEEP_ENTITY method

what might be wrong in my code help me out



Thanks

Deepan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

/IWBEP/IF_MGW_CORE_SRV_RUNTIME~CREATE_ENTITY and

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY  both method was redefined in the DPC class hence preference goes to CREATE_ENTITY and the same method is triggered.Now when i deleted the redefinition of CREATE_ENTITY method CREATE_DEEP_ENTITY is triggered now.

Thanks all!!

kammaje_cis
Active Contributor
0 Kudos

preference goes to CREATE_ENTITY and the same method is triggered.

This is definitely not true.

Former Member
0 Kudos

It works fine if we keep the redefinition of /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_ENTITY but not for

/IWBEP/IF_MGW_CORE_SRV_RUNTIME~CREATE_ENTITY

Former Member
0 Kudos

Thanks Krishna!! If possible can you look into another issue i am facing

vinay_kumar313
Explorer
0 Kudos

I replied, Have a look.. U should add that variable and it works I guess. Use that code.

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi all,

I have tried the batch process too.just incase it works but still only create_entity is only called not the create_deep_entity.


var oModel = sap.ui.getCore().getModel(); 

         

        

          //batch

          var batchChanges = [];

          batchChanges.push(oModel.createBatchOperation("/deliveryhead","POST",requestORderHeader));

          oModel.addBatchChangeOperations(batchChanges);

          oModel.submitBatch(function(data){

           

              debugger;

          },function(err){

             

              debugger;

          }); 

vinay_kumar313
Explorer
0 Kudos

Hi,

Can you please try this,

var obj = { "PRD_NUM": "01", "DEL_NUM": "01" , "DEL_ITEM_NUM": "01", "ARTI_NUM": "P010", "DEL_DESC": "200", "SUB_DIV": null,  "COLL_TYPE": null, "SEASON": null, "MAIN_CLASS": null, "CLASS": null, "GEN_ARTI_NUM": null, "DEL_QUAN": null , "QUANTITY": null };

  var requestORderHeader = {"delheadtodellist" : obj};

var oModel = sap.ui.getCore().getModel();
oModel.create('/deliverylist',
   requestORderHeader,
   null,
   function(oData, oResponse) {
   debugger;
   alert ('Order creation succeed !');
   },
   function(error) {
   debugger;
   alert('Call service creation failed');
   }
   );
Former Member
0 Kudos

Hi vinay thanks..

I have tried the same way. no still only the create_entity is triggered and not create_deep_entity

Requestheader object which i am sending to omodel.create

vinay_kumar313
Explorer
0 Kudos

Hi Deepan,

Can you pleas provide the GET entity list in JSON format. I meant there should be a Read operation where you get list.

I am wondering have you implemented batch operation? you can try with batch operation if you have more than one entityset to update.

Former Member
0 Kudos

Thanks vinay.

yes i have an read operation

  • I am reading initially fill the table using the below code by passing filters

sdelread = "/deliverylist"


  this.getView().byId("idProductsTable").bindItems(sdelRead,oTemplate,false,filters);

  • Now i want the selected entries from the table to be pushed back to backend.

  • Reg the batch process i was just trying in case if it works with it..
vinay_kumar313
Explorer
0 Kudos

Hi,

is there any deep entity in that list. The screen shot which u shared, I can't see the below part.

Former Member
0 Kudos

Hi Vinay,

u mean the navigation part ?  yes it is there


{

"d" : {
     "results" : [
       {
         "__metadata" : {
           "id" : "http://testserver.en:8005/sap/opu/odata/Sap/testGOODS_RCPT_SRV/deliverylist(PRD_NUM='',DEL_NUM='0182397083',DEL_ITEM_NUM='000010')",
           "uri" : "http://testserver.en:8005/sap/opu/odata/Sap/testGOODS_RCPT_SRV/deliverylist(PRD_NUM='',DEL_NUM='0182397083',DEL_ITEM_NUM='000010')",
           "type" : "RT_SRS_GOODS_RCPT_SRV.delitems"
         },
         "PRD_NUM" : "",
         "DEL_NUM" : "0182397083",
         "DEL_ITEM_NUM" : "000010",
         "ARTI_NUM" : "000000001101732001",
         "DEL_DESC" : "11.305.12.4288 Blouse, 44D6, 34",
         "SUB_DIV" : "",
         "COLL_TYPE" : "",
         "SEASON" : "05",
         "MAIN_CLASS" : "",
         "CLASS" : "",
         "GEN_ARTI_NUM" : "",
         "DEL_QUAN" : "1.000",
         "QUANTITY" : "1.000",
         "dellisttodelhdead" : {
           "__deferred" : {
            "uri" : "http://testserver.en:8005/sap/opu/odata/Sap/testGOODS_RCPT_SRV/deliverylist(PRD_NUM='',DEL_NUM='0182..."
           }
         }
       },

vinay_kumar313
Explorer
0 Kudos

var sPath = "/deliverylist(PRD_NUM='',DEL_NUM='0182397083',DEL_ITEM_NUM='000010')/dellisttodelhdead"


var obj = { "PRD_NUM": "01", "DEL_NUM": "01" , "DEL_ITEM_NUM": "01", "ARTI_NUM": "P010","DEL_DESC": "200", "SUB_DIV": null,  "COLL_TYPE": null, "SEASON": null, "MAIN_CLASS": null, "CLASS": null, "GEN_ARTI_NUM": null, "DEL_QUAN": null , "QUANTITY": null };

  var requestORderHeader = {"delheadtodellist" : obj};

var oModel = sap.ui.getCore().getModel();
oModel.create(sPath,
   requestORderHeader,
   null,
   function(oData, oResponse) {
   debugger;
   alert ('Order creation succeed !');
   },
   function(error) {
   debugger;
   alert('Call service creation failed');
   }
   );
Former Member
0 Kudos

Hi all,

What might be the issue ? as you can see above ..

  • navigation is fine
  • properties are fine.
kammaje_cis
Active Contributor
0 Kudos

Deepan,

Why don't you try with $ajax first.

I have got oModel.Create() working before, but not sure why is it not working for you.

Documentation says that it is not officially supported. JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.odata.ODataModel

Former Member
0 Kudos

Thanks for reply.No idea how to proceed with ajax create call.

  • My issue is create_entity is only called not the create_deep_entity.
  • can you please check if my navigation are correct as mentioned above post.
AshwinDutt
Active Contributor
0 Kudos

Hello Deepan,

Please check the payload which you are sending has the navigation property which is defined between Header and Item Entities in your GW Model.

Below would help :

Sample Payload in Json Format ->

Where HeaderItem would be the navigation property defined in your GW Model.

{

"Id":"01",

"Name":"John",

"Name2":"Simon",

"HeaderItem":

[

{"Id":"10","Name1":"Test1"},

{"Id":"20","Name2":"Test2"}

]

}

Cross Check your payload again.

Regards,

Ashwin

Former Member
0 Kudos

Yes i have given the navigation property name.

  1. <EntityType sap:content-version="1" Name="delhead">
  2. <Key><PropertyRef Name="DEL_NUM"/></Key>< 
  3. <property Name="PRD_NUM" sap:label="Purchasing Doc." MaxLength="10" Type="Edm.String"/> 
  4. <Property Name="DEL_NUM" sap:label="Delivery" MaxLength="10" Nullable="false" Type="Edm.String"/> 
  5. <Property Name="DEL_ITEM_NUM" sap:label="Item" MaxLength="6" Type="Edm.String"/> 
  6. <Property Name="ARTI_NUM" sap:label="Article" MaxLength="18" Type="Edm.String"/> 
  7. <Property Name="DEL_DESC" sap:label="Description" MaxLength="40" Type="Edm.String"/>< 
  8. <Property Name="SUB_DIV" sap:label="Sub Division" MaxLength="3" Type="Edm.String"/> 
  9. <Property Name="COLL_TYPE" sap:label="Collection Type" MaxLength="2" Type="Edm.String"/> 
  10. <Property Name="SEASON" sap:label="Season" MaxLength="4" Type="Edm.String"/> 
  11. <Property Name="MAIN_CLASS" sap:label="Main Class" MaxLength="2" Type="Edm.String"/>< 
  12. <Property Name="CLASS" sap:label="Class" MaxLength="3" Type="Edm.String"/> 
  13. <Property Name="GEN_ARTI_NUM" sap:label="Cross-site CM" MaxLength="18" Type="Edm.String"/>< 
  14. <Property Name="DEL_QUAN" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/>< 
  15. <Property Name="QUANTITY" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/>< 
  16. <NavigationProperty Name="delheadtodellist" ToRole="ToRole_delheadsettodelitemset" FromRole="FromRole_delheadsettodelitemset" Relationship="GOODSRCPT.delheadsettodelitemset"/> 
  17. </EntityType> 

I have used property name as delheadtodelist

I am passing the same name still create_deep_entity method is not triggered


var requestORderHeader = {}; 

requestORderHeader.PRD_NUM = "01";

requestORderHeader.DEL_NUM = "01";

requestORderHeader.DEL_ITEM_NUM = "01";

requestORderHeader.ARTI_NUM =  "P010";

requestORderHeader.DEL_DESC = "200";

requestORderHeader.SUB_DIV = null;

requestORderHeader.COLL_TYPE = null;

requestORderHeader.SEASON = null;

requestORderHeader.MAIN_CLASS = null;

requestORderHeader.CLASS = null;

requestORderHeader.GEN_ARTI_NUM = null;

requestORderHeader.DEL_QUAN = null;

requestORderHeader.QUANTITY = null;

var itemData = []; 

      

itemData.push({ PRD_NUM: "01", DEL_NUM: "01" , DEL_ITEM_NUM: "01", ARTI_NUM: "P010", DEL_DESC: "200", SUB_DIV: null,  COLL_TYPE: null, SEASON: null, MAIN_CLASS: null, CLASS: null, GEN_ARTI_NUM: null, DEL_QUAN: null , QUANTITY: null }); 

requestORderHeader.delheadtodellist = itemData;   


oModel.create('/deliveryhead', 

                  requestORderHeader, 

                  null, 

                  function(oData, oResponse) { 

                      debugger;

                  alert ('Order creation succeed !');

                  },

                  function(error) {

                      debugger;

                  alert('Call service creation failed'); 

                  }

                  );

kammaje_cis
Active Contributor
0 Kudos

Deepan,

Framework decides to call Deep Entity method or the regular create method based on the request content. If the request content has children, then deep entity is called.

Call $metadata of your service and check if right navigation property is available.

Former Member
0 Kudos

Hi Krishna ,

Navigation seems to be correct.please find the below metadata.but still its not working. ,Always create_entity method get called.

Head Entity


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

<Key><PropertyRef Name="DEL_NUM"/></Key><

<property Name="PRD_NUM" sap:label="Purchasing Doc." MaxLength="10" Type="Edm.String"/>

<Property Name="DEL_NUM" sap:label="Delivery" MaxLength="10" Nullable="false" Type="Edm.String"/>

<Property Name="DEL_ITEM_NUM" sap:label="Item" MaxLength="6" Type="Edm.String"/>

<Property Name="ARTI_NUM" sap:label="Article" MaxLength="18" Type="Edm.String"/>

<Property Name="DEL_DESC" sap:label="Description" MaxLength="40" Type="Edm.String"/><

<Property Name="SUB_DIV" sap:label="Sub Division" MaxLength="3" Type="Edm.String"/>

<Property Name="COLL_TYPE" sap:label="Collection Type" MaxLength="2" Type="Edm.String"/>

<Property Name="SEASON" sap:label="Season" MaxLength="4" Type="Edm.String"/>

<Property Name="MAIN_CLASS" sap:label="Main Class" MaxLength="2" Type="Edm.String"/><

<Property Name="CLASS" sap:label="Class" MaxLength="3" Type="Edm.String"/>

<Property Name="GEN_ARTI_NUM" sap:label="Cross-site CM" MaxLength="18" Type="Edm.String"/><

<Property Name="DEL_QUAN" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/><

<Property Name="QUANTITY" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/><

<NavigationProperty Name="delheadtodellist" ToRole="ToRole_delheadsettodelitemset" FromRole="FromRole_delheadsettodelitemset" Relationship="GOODSRCPT.delheadsettodelitemset"/>

</EntityType>

Item Entity


<EntityType sap:content-version="1" Name="delitems">-<Key><PropertyRef Name="PRD_NUM"/><PropertyRef Name="DEL_NUM"/>

<PropertyRef Name="DEL_ITEM_NUM"/></Key>

<Property Name="PRD_NUM" sap:label="Purchasing Doc." MaxLength="10" Nullable="false" Type="Edm.String"/>

<Property Name="DEL_NUM" sap:label="Delivery" MaxLength="10" Nullable="false" Type="Edm.String"/>

<Property Name="DEL_ITEM_NUM" sap:label="Item" MaxLength="6" Nullable="false" Type="Edm.String"/>

<Property Name="ARTI_NUM" sap:label="Article" MaxLength="18" Type="Edm.String"/>

<Property Name="DEL_DESC" sap:label="Description" MaxLength="40" Type="Edm.String"/>

<Property Name="SUB_DIV" sap:label="Sub Division" MaxLength="3" Type="Edm.String"/>

<Property Name="COLL_TYPE" sap:label="Collection Type" MaxLength="2" Type="Edm.String"/>

<Property Name="SEASON" sap:label="Season" MaxLength="4" Type="Edm.String"/>

<Property Name="MAIN_CLASS" sap:label="Main Class" MaxLength="2" Type="Edm.String"/>

<Property Name="CLASS" sap:label="Class" MaxLength="3" Type="Edm.String"/>

<Property Name="GEN_ARTI_NUM" sap:label="Cross-site CM" MaxLength="18" Type="Edm.String"/>

<Property Name="DEL_QUAN" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/><Property Name="QUANTITY" sap:label="Target quantity" Type="Edm.Decimal" Scale="3" Precision="13"/>

<NavigationProperty Name="dellisttodelhdead" ToRole="ToRole_delitemsettodeleadset" FromRole="FromRole_delitemsettodeleadset" Relationship="GOODSRCPT.delitemsettodeleadset"/>

</EntityType>

Associations


<Association sap:content-version="1" Name="delheadsettodelitemset">

<End Type="GOODSRCPT.delhead" Role="FromRole_delheadsettodelitemset" Multiplicity="1"/>

<End Type="GOODSRCPT.delitems" Role="ToRole_delheadsettodelitemset" Multiplicity="*"/>

</Association>-

<Association sap:content-version="1" Name="delitemsettodeleadset">

<End Type="GOODSRCPT.delitems" Role="FromRole_delitemsettodeleadset" Multiplicity="*"/>

<End Type="GOODSRCPT.delhead" Role="ToRole_delitemsettodeleadset" Multiplicity="1"/></Association>