Skip to Content
0

How to Transfer Item Data of Deep Entity back to View after Calling CREATE_DEEP_ENTITY

Aug 24, 2017 at 10:02 PM

79

avatar image
Former Member

Hi Gurus

I am developing a UI5 interface which suppose to create a Head/Items deep entity.

I have a item list on the page, when Submitting, CREATE_DEEP_ENTITY get called and everything works fine.

However, I have a couple of item level fields will be updated after CREATING, and I want to show up these fields' data on the list.

Now the problem is, in the View I don't see the data in the Model.

In the Controller, I use below code to submit data to Gateway server:

oHead.ItemSet = items;
oModel.create('/ObjectSet', oHead, null,
	function(oData, oResponse) {
		alert("Success");
	},
	function() {
		alert("Internal error");
	}
);

But when I check oData, I don't see the new data .

In method CREATE_DEEP_ENTITY, I have below code to pass data to the OData layer, then I expect the new data in lw_deep_entity will be pass back to the Model above.

      copy_data_to_ref(
        EXPORTING
          is_data = lw_deep_entity
        CHANGING
          cr_data = er_deep_entity ).

Do I miss something here? Or the way is total wrong to service my purpose?

Any input is highly appreciated.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Mantri Shekar Aug 28, 2017 at 07:13 AM
0

Hi john,

Could you Please show me the whole code written in Deep Entity Method. So that it will help to trace the issue.

Apart from that you mentioned the below statement

But when I check oData, I don't see the new data .

This might be a problem in UI Side where u haven't Copied the object properly.First Ensure you are passing the Object with data in oModel.create.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Mantri

Thanks for the reply. Let me try to describe my issue more clear.

My task is to create a Transfer Order.

From the page side I build the item list based on user input, then I called oModel.create method with no problem:

oHead.ItemSet = items;
oModel.create('/ObjectSet', oHead, null,
	function(oData, oResponse) {
		alert("Success");
	},
	function() {
		alert("Internal error");
	}
);

Here Head/Item data get passed to gateway server without issue. In method CREATE_DEEP_ENTITY I can get all of the data, I called a FM to create the Transfer Order, then TO number and item numbers are generated. I try to pass these numbers back to the page so users can see them.

But in the success function, I can not see those numbers in object oData.

In CREATE_DEEP_ENTITY I have code like below

  CASE iv_entity_set_name.
    WHEN 'TransferOrderSet'.
      CALL METHOD me->create_to_deep
        EXPORTING
          iv_entity_name          = iv_entity_name
          iv_entity_set_name      = iv_entity_set_name
          iv_source_name          = iv_source_name
          it_key_tab              = it_key_tab
          it_navigation_path      = it_navigation_path
          io_expand               = io_expand
          io_tech_request_context = io_tech_request_context
          io_data_provider        = io_data_provider
        IMPORTING
          er_deep_entity          = lw_to_deep.
      copy_data_to_ref(
        EXPORTING
          is_data = lw_to_deep
        CHANGING
          cr_data = er_deep_entity ).

In method CREATE_TO_DEEP, I have code like below:

 io_data_provider->read_entry_data(
    IMPORTING
      es_data = lr_to_deep ).
* prepare data here
  CALL FUNCTION 'Z_XXXX'
    TABLES
      gritems = lt_item
      return  = lt_ret2
    CHANGING
      grhead  = lw_head.
  READ TABLE lt_ret2 TRANSPORTING NO FIELDS WITH KEY type = 'E'.
  IF sy-subrc NE 0.
    MOVE-CORRESPONDING lw_head TO er_deep_entity.
    IF lt_item[] IS NOT INITIAL.
      SELECT * FROM ltap
        INTO TABLE lt_ltap
        FOR ALL ENTRIES IN lt_item
        WHERE mblnr = lt_item-mat_doc
          AND mjahr = lt_item-doc_year.
      LOOP AT lt_item INTO lw_item.
        READ TABLE lt_ltap INTO lw_ltap WITH KEY mblnr = lw_item-mat_doc
                                                 mjahr = lw_item-doc_year
                                                 mbpos = lw_item-doc_item.
        IF sy-subrc = 0.
          lw_item-trnsf_order   = lw_ltap-tanum.
          lw_item-to_item       = lw_ltap-tapos.
        ENDIF.
        APPEND lw_item TO er_deep_entity-items.
      ENDLOOP.
    ENDIF.
  ENDIF.
 

Can I really expect those data get passed back to the page automatically?

I am new on Fiori/oData, so I am looking for good practise. If this is not the standard way, then how? Just call oModel.read()?

0