创建深层实体 SAPUI5 - 项目数据未传输
Create Deep Entity SAPUI5 - Item Data Not Transmitted
我曾经按照以下教程构建具有深层实体的 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.
在 class 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.
我是否需要重新定义任何其他禁止传输项目数据的方法?
谢谢:)
zcl_xxx_mpc_ext=>ts_deep_entity.的结构是怎样的?
Change the names of the navigations and the underlying structure name for the navigation according to the types mentioned in Types tab in ‘__MPC_EXT’ class of your project. [Source]
调用服务时您的有效载荷是什么样的?
如果 payload 看起来是正确的,那么你的结构显然有问题 ts_deep_entity
检查您的 ts_deep_entity
。确保您的深层结构或内部的 table 类型名称与 segw 数据模型中的实体集相同。
我曾经按照以下教程构建具有深层实体的 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.
在 class 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.
我是否需要重新定义任何其他禁止传输项目数据的方法?
谢谢:)
zcl_xxx_mpc_ext=>ts_deep_entity.的结构是怎样的?
Change the names of the navigations and the underlying structure name for the navigation according to the types mentioned in Types tab in ‘__MPC_EXT’ class of your project. [Source]
调用服务时您的有效载荷是什么样的?
如果 payload 看起来是正确的,那么你的结构显然有问题 ts_deep_entity
检查您的 ts_deep_entity
。确保您的深层结构或内部的 table 类型名称与 segw 数据模型中的实体集相同。