Skip to Content

Is the usage of domain values still best practice?

The ABAP programming model changes with NW 7.5 and S/4HANA: We create data models consisting of transparent tables, define CDS views and create BOPF objects and use auto exposure to create OData Services. But what about good old domain values? It seem to me that those are missing in in the new programming model. If you want to expose domain values to the frontend I only know the way of Gateway programming which described Jerry Wang here: https://blogs.sap.com/2016/04/27/how-to-build-drop-down-list-based-on-fixed-value-defined-in-a-domain/ . But this is exactly what I would like to avoid since I prefer autoexposure of backend logic.

What kind of best practice do you suggest? Do you prefer gateway programming or should we abandon domain values and use transparent table instead?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 19, 2017 at 07:46 AM

    Hi Tobias,

    You can expose domain values through a new ABAP CDS on DD07L and DD07T that you would have built for your domain. That is what SAP does : for example with domain BSTAT. You can check the ABAP CDS I_AccountingDocumentCategory and I_AccountingDocumentCategoryT (for texts).

    @EndUserText.label: 'Accounting Document Category'
    @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: true  
    
    
    
    
    define view I_AccountingDocumentCategory as select from dd07l
    association [0..*] to I_AccountingDocumentCategoryT as _Text on $projection.AccountingDocumentCategory = _Text.AccountingDocumentCategory
    {
       @ObjectModel.text.association: '_Text'
       key cast( domvalue_l as farp_bstat_d ) as AccountingDocumentCategory,
      _Text
    
    
    } 
    where dd07l.domname = 'BSTAT' and dd07l.as4local = 'A';       
    

    You can also check the ABAP CDS I_AccountingDocument that use it.

    @EndUserText.label: 'Accounting Document'
    @Analytics: { dataCategory: #DIMENSION, dataExtraction.enabled: true }
    @VDM.viewType: #BASIC
    @AbapCatalog.sqlViewName: 'IFIAccDoc'
    @AccessControl.authorizationCheck: #CHECK
    @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: true 
    
    
    define view I_AccountingDocument
      as select from bkpf
    
    
      association [1..1] to I_CompanyCode                as _CompanyCode                on  $projection.CompanyCode = _CompanyCode.CompanyCode
      association [0..1] to I_FiscalYearForCompanyCode   as _FiscalYear                 on  $projection.FiscalYear  = _FiscalYear.FiscalYear
                                                                                        and $projection.CompanyCode = _FiscalYear.CompanyCode
      association [0..1] to I_AccountingDocumentType     as _AccountingDocumentType     on  $projection.AccountingDocumentType = _AccountingDocumentType.AccountingDocumentType
      association [0..1] to I_User                       as _User                       on  $projection.AccountingDocCreatedByUser = _User.UserID
      association [0..1] to I_AccountingDocumentCategory as _AccountingDocumentCategory on  $projection.AccountingDocumentCategory = _AccountingDocumentCategory.AccountingDocumentCategory
      association [0..1] to I_BusinessTransactionType    as _BusinessTransactionType    on  $projection.BusinessTransactionType = _BusinessTransactionType.BusinessTransactionType
      association [0..1] to I_ReferenceDocumentType      as _ReferenceDocumentType      on  $projection.ReferenceDocumentType = _ReferenceDocumentType.ReferenceDocumentType
      association [0..1] to I_Ledger                     as _Ledger                     on  $projection.Ledger = _Ledger.Ledger
      association [0..1] to I_LedgerGroup                as _LedgerGroup                on  $projection.LedgerGroup = _LedgerGroup.LedgerGroup
      association [0..1] to I_Currency                   as _Currency                   on  $projection.Currency = _Currency.Currency
      association [0..1] to I_Currency                   as _CompanyCodeCurrency        on  $projection.CompanyCodeCurrency = _CompanyCodeCurrency.Currency
      association [0..1] to I_Currency                   as _AdditionalCurrency1        on  $projection.AdditionalCurrency1 = _AdditionalCurrency1.Currency
      association [0..1] to I_Currency                   as _AdditionalCurrency2        on  $projection.AdditionalCurrency2 = _AdditionalCurrency2.Currency
      association [0..1] to I_LogicalSystem              as _LogicalSystem              on  $projection.ReferenceDocumentLogicalSystem = _LogicalSystem.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, // FieldGroup: AccountingGroup
    
    
          @ObjectModel.foreignKey.association: '_AccountingDocumentType'
          cast(blart as farp_blart)                                                  as AccountingDocumentType, // FieldGroup: AccountingGroup
    

    That way you don't need any programming logic.

    Louis-Arnaud

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 23, 2017 at 05:48 AM

    Thank you for this answer. This is a working solution and you can also use it in NW 7.5. But IMHO there should be an Annotation for it. What do you think?


    Best Regards,
    Tobias
    Add comment
    10|10000 characters needed characters exceeded