定义带有关联的子项目CDS视图,以从属项目表开头

2020-09-10 23:34发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)尊敬的会员 我在我们的系统中创...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


尊敬的会员

我在我们的系统中创建了三个表,它们基本上具有以下结构:

头表通过连接条件" HEAD.UUID = ITEM.HEAD_UUID" 和链接到项表 > item表通过连接条件" ITEM.UUID = SUBITEM.ITEM_UUID"链接到子项表

现在,我想基于这些表创建CDS视图,这些视图应在使用OData的Fiori应用程序中使用。 要启用CRUD,还应另外创建一个BO。

头表

 ...

 @ObjectModel:{
   compositionRoot:正确,
   transactionalProcessingEnabled:是的,

   createEnabled:是的,
   updateEnabled:是,
   deleteEnabled:是,

   语义关键字:['product_id'],
   RepresentativeKey:'guid',
   writeActivePersistence:'ZDM_PRDCT',

   draftEnabled:是的,
   writeDraftPersistence:'ZDM_PRDCT_D',
 }

 @ VDM.viewType:#TRANSACTIONAL

 @ Metadata.allowExtensions:是
 @ OData.publish:正确

//这是HEAD TABLE
 定义视图ZDM_PRODUCT
  //HEAD TABLE的基本CDS视图
   作为产品从ZB_DM_PRODUCT中选择
   ...
   在$ projection.guid = _SapComponent.product_guid上将_SapComponent关联[0 .. *]与ZDM_P_SAP_COMP关联


 {

   关键Product.guid,
       product.product_id,

       @ ObjectModel.association.type:[#TO_COMPOSITION_CHILD]
       _SapComponent
       ...
 }
 
 

ITEM_TABLE

 @ObjectModel:{

   createEnabled:是的,
   updateEnabled:是,
   deleteEnabled:是,

   语义关键字:['component_id'],
   RepresentativeKey:'guid',
   writeActivePersistence:'ZDM_PSC',
   writeDraftPersistence:'ZDM_PSC_D'
 }

 @ VDM.viewType:#TRANSACTIONAL
 @ Metadata.allowExtensions:是

 定义视图ZDM_P_SAP_COMP
   从ZB_DM_P_SAP_COMP中选择作为组件
//头表
   关联[1..1]与ZDM_PRODUCT作为$ projection.product_guid = _Product.guid上的_Product
//SUBITEM表格
   与[DM.P_SAP_COMP_T]关联[0 .. *]作为$ projection.guid = _Text.sap_component_guid上的_Text

 {

   关键Component.guid
       Component.product_guid,
       Component.component_id,

       @ ObjectModel.association.type:[#TO_COMPOSITION_PARENT,#TO_COMPOSITION_ROOT]
       _产品,

       @ ObjectModel.association.type:#TO_COMPOSITION_CHILD
       _文本
 }
 
 

子项目表

 ...

 @ObjectModel:{

   createEnabled:是的,
   updateEnabled:是,
   deleteEnabled:是,

   语义关键字:['langu'],
   RepresentativeKey:'guid',
   writeActivePersistence:'ZDM_PSC_T',
   writeDraftPersistence:'ZDM_PSC_TD'

 }

 @ VDM.viewType:#TRANSACTIONAL
 @ Metadata.allowExtensions:是

 定义视图ZDM_P_SAP_COMP_T

   从ZB_DM_P_SAP_COMP_T中选择作为ComponentText
//项目表
   关联[1..1]与ZDM_P_SAP_COMP作为$ projection.sap_component_guid = _Component.guid上的_Component
//头表
   关联[1..1]与ZDM_PRODUCT作为$ projection.product_guid = _Product.guid上的_Product


 {

   键ComponentText.guid
       _Component.product_guid,
       ComponentText.sap_component_guid,
       ComponentText.langu,
       ComponentText.text,

       @ ObjectModel.association.type:[#TO_COMPOSITION_PARENT]
       _零件,

       @ ObjectModel.association.type:[#TO_COMPOSITION_ROOT]
       _产品
 }
 
 

现在,我想创建一个从子项表到头表的关联,以设置关联类型 #TO_COMPOSITION_ROOT 。 要建立连接条件,我需要product_guid,可以从依赖项表中获得。 如果我在编码中使用了该方法,则无法激活BO。 然后我得到了product_guid不是数据库字段的错误。

有人可以在这里帮助我吗?

提前谢谢!

(85.7 kB)