我曾在以下教程中使用深度实体构建Fiori应用程序(我使用发票头+项目(:https://blogs.sap.com/2017/07/18/steps-to-create-deep-insert-odata/
在我开始在后台调试之前,一切都很好。该服务正确地发送数据,但在后端,项目却丢失了。后端代码:
METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
DATA custom_create_deep_entity TYPE zcl_xxx_mpc_ext=>ts_deep_entity.
CASE iv_entity_set_name.
WHEN 'xxxSet'.
CALL METHOD me->custom_create_deep_entity
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 = custom_create_deep_entity.
copy_data_to_ref(
EXPORTING
is_data = custom_create_deep_entity
CHANGING
cr_data = er_deep_entity
).
ENDCASE.
ENDMETHOD.
METHOD custom_create_deep_entity.
DATA: lr_deep_entity TYPE zcl_xxx_mpc_ext=>ts_deep_entity,
lt_items TYPE zcl_xxx_mpc=>tt_zinvoiceitem,
ls_items TYPE zcl_xxx_mpc=>ts_zinvoiceitem.
io_data_provider->read_entry_data(
IMPORTING
es_data = lr_deep_entity ).
ls_header_input = VALUE #(
bukrs = lr_deep_entity-bukrs
wrbtr = lr_deep_entity-wrbtr
).
LOOP AT lr_deep_entity-items ASSIGNING FIELD-SYMBOL(<ls_item>).
"never reached because 'items' is empty
ENDLOOP.
er_deep_entity = VALUE #(
bukrs = ls_header_input-bukrs
wrbtr = ls_header_input-wrbtr
items = lr_deep_entity-items
).
ENDMETHOD.
MPC_EXT:类中重新定义的DEFINE方法
METHOD define.
super->define( ).
DATA:
lo_annotation TYPE REF TO /iwbep/if_mgw_odata_annotation,
lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
lo_complex_type TYPE REF TO /iwbep/if_mgw_odata_cmplx_type,
lo_property TYPE REF TO /iwbep/if_mgw_odata_property,
lo_entity_set TYPE REF TO /iwbep/if_mgw_odata_entity_set.
lo_entity_type = model->get_entity_type( iv_entity_name = 'Zxxxxxx' ).
lo_entity_type->bind_structure( iv_structure_name = 'ZCL_XXX_MPC_EXT=>TS_DEEP_ENTITY' ).
ENDMETHOD.
我需要重新定义任何其他方法来防止传输项目数据吗?
谢谢:(
结构如何zclxxx_mpc_ext=>ts_deep_entity看起来像?
根据项目的"__MPC_EXT"类的"类型"选项卡中提到的类型,更改导航的名称和基础结构名称。[来源]
调用服务时,您的有效负载是什么样子的?
如果有效载荷看起来正确,那么您的结构显然有问题ts_deep_entity
查看您的ts_deep_entity
。确保内部的深层结构或表类型名称与segw数据模型中的实体集相同。