使用域值仍然是最佳做法吗?

2020-09-05 09:22发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中) ABAP编程模型随NW 7.5...

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

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


ABAP编程模型随NW 7.5和S/4HANA的变化而变化:我们创建由透明表组成的数据模型,定义CDS视图并创建BOPF对象,并使用自动公开创建OData Services。 但是,好的旧域名价值呢? 在我看来,这些在新的编程模型中是缺失的。 如果您想向前端公开域值,我只知道网关编程的方式,该方式在此处描述了 Jerry Wang https ://blogs.sap.com/2016/04/27/how-to-build-drop-down-list-based-on-fixed-value-defined-in-a-domain/。 但这正是我要避免的事情,因为我更喜欢后端逻辑的自动曝光。

您建议什么样的最佳实践? 您是喜欢网关编程还是还是应该放弃域值而改用透明表?

6条回答
Bunny_CDM
2020-09-05 09:43 .采纳回答

您好Tobias,

您可以通过为域构建的DD07L和DD07T上的新ABAP CDS公开域值。 这就是SAP的工作:例如使用域BSTAT。 您可以检查ABAP CDS I_AccountingDocumentCategory和I_AccountingDocumentCategoryT(用于文本)。

 @ EndUserText.label:"会计凭证类别"
 @Analytics:{dataCategory:#DIMENSION,dataExtraction.enabled:true}
 @ VDM.viewType:#BASIC
 @ AbapCatalog.sqlViewName:'IFIAccDocCat'
 @ AccessControl.authorizationCheck:#NOT_REQUIRED
 @ ObjectModel.representativeKey:'AccountingDocumentCategory'
 @ AbapCatalog.buffering.status:#NOT_ALLOWED
 @ ObjectModel.usageType.sizeCategory:#S
 @ ObjectModel.usageType.dataClass:#MASTER
 @ ObjectModel.usageType.serviceQuality:#A
 @ ClientHandling.algorithm:#SESSION_VARIABLE
 @ Metadata.ignorePropagatedAnnotations:正确




 定义视图I_AccountingDocumentCategory为从dd07l中选择
 将[0 .. *]与$ projection.AccountingDocumentCategory = _Text.AccountingDocumentCategory上的_Text关联到I_AccountingDocumentCategoryT
 {
    @ ObjectModel.text.association:'_Text'
    键强制转换(domvalue_l为farp_bstat_d)为AccountingDocumentCategory,
   _文本


 }
 其中dd07l.domname ='BSTAT'和dd07l.as4local ='A';
 

您还可以检查使用它的ABAP CDS I_AccountingDocument。

 @ EndUserText.label:"会计凭证"
 @Analytics:{dataCategory:#DIMENSION,dataExtraction.enabled:true}
 @ VDM.viewType:#BASIC
 @ AbapCatalog.sqlViewName:'IFIAccDoc'
 @ AccessControl.authorizationCheck:#检查
 @ ObjectModel.representativeKey:'AccountingDocument'
 @ ObjectModel.usageType.sizeCategory:#XXL
 @ ObjectModel.usageType.dataClass:#TRANSACTIONAL
 @ ObjectModel.usageType.serviceQuality:#A
 @ ClientHandling.algorithm:#SESSION_VARIABLE
 @ AbapCatalog.buffering.status:#NOT_ALLOWED
 @ Metadata.ignorePropagatedAnnotations:正确


 定义视图I_AccountingDocument
   从bkpf中选择


   将[1..1]与I_CompanyCode关联为$ projection.CompanyCode = _CompanyCode.CompanyCode上的_CompanyCode
   在$ projection.FiscalYear = _FiscalYear.FiscalYear上,将[0..1]与I_FiscalYearForCompanyCode关联为_FiscalYear
                                                                                     和$ projection.CompanyCode = _FiscalYear.CompanyCode
   在$ projection.AccountingDocumentType = _AccountingDocumentType.AccountingDocumentType上,将[0..1]与I_AccountingDocumentType关联为_AccountingDocumentType
   在$ projection.AccountingDocCreatedByUser = _User.UserID上将[0..1]关联为_User的I_User
   与$ projection.AccountingDocumentCategory = _AccountingDocumentCategory.AccountingDocumentCategory上的_AccountingDocumentCategory关联[0..1]到I_AccountingDocumentCategory
   将[0..1]与I_BusinessTransactionType关联为$ projection.BusinessTransactionType = _BusinessTransactionType.BusinessTransactionType上的_BusinessTransactionType
   将[0..1]与I_ReferenceDocumentType关联为$ projection.ReferenceDocumentType = _ReferenceDocumentType.ReferenceDocumentType上的_ReferenceDocumentType
   在$ projection.Ledger = _Ledger.Ledger上将[0..1]与I_Ledger关联为_Ledger
   在$ projection.LedgerGroup = _LedgerGroup.LedgerGroup上,将[0..1]与I_LedgerGroup关联为_LedgerGroup
   在$ projection.Currency = _Currency.Currency上,将[0..1]与I_Currency关联为_Currency
   关联[0..1]与I_Currency作为$ projection.CompanyCodeCurrency = _CompanyCodeCurrency.Currency上的_CompanyCodeCurrency
   在$ projection.AdditionalCurrency1 = _AdditionalCurrency1.Currency上,将[0..1]与I_Currency关联为_AdditionalCurrency1
   在$ projection.AdditionalCurrency2 = _AdditionalCurrency2.Currency上,将[0..1]与I_Currency关联为_AdditionalCurrency2
   将[0..1]与$ projection.ReferenceDocumentLogicalSystem = _LogicalSystem.LogicalSystem上的_LogicalSystem关联到I_LogicalSystem


 {
       @ ObjectModel.foreignKey.association:'_CompanyCode'
   key cast(bukrs as fis_bukrs)as CompanyCode,//FieldGroup:_BASIC
       @ ObjectModel.foreignKey.association:'_FiscalYear'
   key cast(gjahr as fis_gjahr)as FiscalYear,//FieldGroup:AccountingGroup
   key cast(belnr as farp_belnr_d)as AccountingDocument,//字段组:AccountingGroup


       @ ObjectModel.foreignKey.association:'_AccountingDocumentType'
       cast(blart as farp_blart)as AccountingDocumentType,//FieldGroup:AccountingGroup
 

那样,您不需要任何编程逻辑。

路易斯·阿诺(Louis-Arnaud)

一周热门 更多>