C_BillingDocument_F0797

DDL: C_BILLINGDOCUMENT_F0797 SQL: CBDOCF0797 Type: view CONSUMPTION

Billing Document

C_BillingDocument_F0797 is a Consumption CDS View that provides data about "Billing Document" in SAP S/4HANA. It reads from 2 data sources (C_BillingRunErrorLog, I_BillingDocument) and exposes 134 fields with key field BillingDocument. It has 12 associations to related views.

Data Sources (2)

SourceAliasJoin Type
C_BillingRunErrorLog _FirstErrorMessage left_outer
I_BillingDocument BillingDocument from

Associations (12)

CardinalityTargetAliasCondition
[0..*] C_BillingDocumentItem_F0797 _Item $projection.BillingDocument = _Item.BillingDocument
[0..*] C_PricingElement _PricingElement $projection.PricingDocument = _PricingElement.PricingDocument
[0..1] C_SoldToValueHelp _SoldToParty $projection.SoldToParty = _SoldToParty.Customer
[0..1] C_SoldToValueHelp _PayerParty $projection.PayerParty = _PayerParty.Customer
[0..1] C_Dischannelvaluehelp _DistributionChannel $projection.SalesOrganization = _DistributionChannel.SalesOrganization and $projection.DistributionChannel = _DistributionChannel.DistributionChannel
[0..1] C_OrgDivisionValueHelp _Division $projection.SalesOrganization = _Division.SalesOrganization and $projection.DistributionChannel = _Division.DistributionChannel and $projection.Division = _Division.Division
[0..1] C_SalesDocPaymentMethodVH _PaymentMethod $projection.PaymentMethod = _PaymentMethod.PaymentMethod and $projection.CompanyCode = _PaymentMethod.BillingCompanyCode
[0..1] I_CollectiveProcessingErrorLog _ErrorLog _ErrorLog.CollectiveProcessing = '' and $projection.BillingDocument = _ErrorLog.SDDocument and _ErrorLog.CollectiveProcessingMsgCounter = _FirstErrorMessage.CollectiveProcessingMsgCounter and _ErrorLog.ScheduleLine = _FirstErrorMessage.ScheduleLine and _ErrorLog.SystemMessageType = 'E'
[0..1] C_BillingDocumentUserVH _CreatedByUser $projection.CreatedByUser = _CreatedByUser.UserID
[1] E_BillingDocument _Extension $projection.BillingDocument = _Extension.BillingDocument
[0..1] C_BillgSalesDocCatVH _SDDocumentCategory $projection.SDDocumentCategory = _SDDocumentCategory.SDDocumentCategory
[0..1] I_SitnInstceIndicator _SitnInstceIndicator _SitnInstceIndicator.SitnInstceAnchorObjectKey = $projection.BillingDocument and _SitnInstceIndicator.SitnDefAnchorObject = 'BillingDocument'

Annotations (15)

NameValueLevelField
AbapCatalog.sqlViewName CBDOCF0797 view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #CHECK view
EndUserText.label Billing Document view
VDM.viewType #CONSUMPTION view
Search.searchable true view
Metadata.allowExtensions true view
ObjectModel.compositionRoot true view
ObjectModel.createEnabled false view
ObjectModel.updateEnabled EXTERNAL_CALCULATION view
ObjectModel.deleteEnabled false view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view

Fields (134)

KeyFieldSource TableSource FieldDescription
KEY BillingDocument I_BillingDocument BillingDocument
BillingDocumentType I_BillingDocument BillingDocumentType
BillingDocumentTypeName
PayerParty I_BillingDocument PayerParty
OverallBillingStatus
SoldToParty I_BillingDocument SoldToParty
BillingIssueType I_BillingDocument BillingIssueType
TransactionCurrency I_BillingDocument TransactionCurrency
Currency
BillingDocumentIsCancelled I_BillingDocument BillingDocumentIsCancelled
CancelledBillingDocument I_BillingDocument CancelledBillingDocument
SDDocumentCategory I_BillingDocument SDDocumentCategory
BillingDocumentDate I_BillingDocument BillingDocumentDate
CompanyCode I_BillingDocument CompanyCode
FiscalYear I_BillingDocument FiscalYear
AccountingDocument
DocumentReferenceID
PurchaseOrderByCustomer I_BillingDocument PurchaseOrderByCustomer
SalesOrganization I_BillingDocument SalesOrganization
DistributionChannel I_BillingDocument DistributionChannel
Division I_BillingDocument Division
SalesDistrict I_BillingDocument SalesDistrict
TotalNetAmount I_BillingDocument TotalNetAmount
TaxAmount I_BillingDocument TotalTaxAmount
TotalGrossAmount
AccountingTransferStatus I_BillingDocument AccountingTransferStatus
IncotermsVersion I_BillingDocument IncotermsVersion
IncotermsClassification I_BillingDocument IncotermsClassification
IncotermsLocation1 I_BillingDocument IncotermsLocation1
IncotermsLocation2 I_BillingDocument IncotermsLocation2
IsRelevantForAccrual I_BillingDocument IsRelevantForAccrual
PaymentMethod I_BillingDocument PaymentMethod
CustomerPaymentTerms I_BillingDocument CustomerPaymentTerms
IsIntrastatReportingRelevant I_BillingDocument IsIntrastatReportingRelevant
IsIntrastatReportingExcluded I_BillingDocument IsIntrastatReportingExcluded
SitnNumberOfInstances _SitnInstceIndicator SitnNumberOfInstances
BillingDocumentHasSituations
InvoiceListType I_BillingDocument InvoiceListType
ShippingCondition I_BillingDocument ShippingCondition
ManualInvoiceMaintIsRelevant I_BillingDocument ManualInvoiceMaintIsRelevant
CustomerAccountAssignmentGroup I_BillingDocument CustomerAccountAssignmentGroup
FixedValueDate I_BillingDocument FixedValueDate
AdditionalValueDays AdditionalValueDays
AssignmentReference AssignmentReference
AccountingExchangeRateIsSet AccountingExchangeRateIsSet
AbsltAccountingExchangeRate
AcctgExchangeRateIsIndrctQtan
DunningArea I_BillingDocument DunningArea
DunningBlockingReason I_BillingDocument DunningBlockingReason
DunningKey I_BillingDocument DunningKey
PricingDocument I_BillingDocument PricingDocument
SDPricingProcedure I_BillingDocument SDPricingProcedure
CustomerGroup I_BillingDocument CustomerGroup
CustomerRebateAgreement I_BillingDocument CustomerRebateAgreement
CustomerPriceGroup I_BillingDocument CustomerPriceGroup
PriceListType I_BillingDocument PriceListType
Country I_BillingDocument Country
TaxDepartureCountry I_BillingDocument TaxDepartureCountry
CustomerTaxClassification1 I_BillingDocument CustomerTaxClassification1
CustomerTaxClassification2 I_BillingDocument CustomerTaxClassification2
CustomerTaxClassification3 I_BillingDocument CustomerTaxClassification3
CustomerTaxClassification4 I_BillingDocument CustomerTaxClassification4
CustomerTaxClassification5 I_BillingDocument CustomerTaxClassification5
CustomerTaxClassification6 I_BillingDocument CustomerTaxClassification6
CustomerTaxClassification7 I_BillingDocument CustomerTaxClassification7
CustomerTaxClassification8 I_BillingDocument CustomerTaxClassification8
CustomerTaxClassification9 I_BillingDocument CustomerTaxClassification9
VATRegistration I_BillingDocument VATRegistration
CityCode I_BillingDocument CityCode
County I_BillingDocument County
Region I_BillingDocument Region
VATRegistrationCountry I_BillingDocument VATRegistrationCountry
VATRegistrationOrigin I_BillingDocument VATRegistrationOrigin
IsEUTriangularDeal I_BillingDocument IsEUTriangularDeal
UxFcTexts
UxAcPost
UxAcCancel
SoldToPartyName _SoldToParty OrganizationBPName1
SoldToPartyAdditionalName _SoldToParty OrganizationBPName2
PayerPartyName _PayerParty OrganizationBPName1
PayerPartyAdditionalName _PayerParty OrganizationBPName2
CreationDate I_BillingDocument CreationDate
CreationTime I_BillingDocument CreationTime
CreatedByUser I_BillingDocument CreatedByUser
BillingDocumentIsTemporary
InvoiceClearingStatus I_BillingDocument InvoiceClearingStatus
_CompanyCode I_BillingDocument _CompanyCode
_FiscalYear I_BillingDocument _FiscalYear
_SalesOrganization _SalesOrganization
_DistributionChannel _DistributionChannel
_Division _Division
_SalesDistrict _SalesDistrict
_ShippingCondition _ShippingCondition
_InvoiceListType _InvoiceListType
_SDDocumentCategory _SDDocumentCategory
_CustomerPaymentTerms I_BillingDocument _CustomerPaymentTerms
_IncotermsClassification I_BillingDocument _IncotermsClassification
_IncotermsVersion I_BillingDocument _IncotermsVersion
_BillingDocumentType I_BillingDocument _BillingDocumentType
_SoldToParty _SoldToParty
_PayerParty _PayerParty
_BillingIssueType I_BillingDocument _BillingIssueType
_OverallBillingStatus I_BillingDocument _OverallBillingStatus
_PaymentMethod _PaymentMethod
_CustomerGroup I_BillingDocument _CustomerGroup
_CustomerPriceGroup I_BillingDocument _CustomerPriceGroup
_CustomerAccountAssgmtGroup I_BillingDocument _CustomerAccountAssgmtGroup
_DunningBlockingReason I_BillingDocument _DunningBlockingReason
_DunningKey I_BillingDocument _DunningKey
_Country I_BillingDocument _Country
_TaxDepartureCountry I_BillingDocument _TaxDepartureCountry
_TransactionCurrency I_BillingDocument _TransactionCurrency
_AccountingTransferStatus I_BillingDocument _AccountingTransferStatus
_CityCode I_BillingDocument _CityCode
_County_2 I_BillingDocument _County_2
_Region I_BillingDocument _Region
_VATRegistrationCountry I_BillingDocument _VATRegistrationCountry
_VATRegistrationOrigin I_BillingDocument _VATRegistrationOrigin
_SDPricingProcedure I_BillingDocument _SDPricingProcedure
SystemMessageIdentification _ErrorLog SystemMessageIdentification
SystemMessageNumber _ErrorLog SystemMessageNumber
SystemMessageType _ErrorLog SystemMessageType
SystemMessageVariable1 _ErrorLog SystemMessageVariable1
SystemMessageVariable2 _ErrorLog SystemMessageVariable2
SystemMessageVariable3 _ErrorLog SystemMessageVariable3
SystemMessageVariable4 _ErrorLog SystemMessageVariable4
SystemMessageText
_Item _Item
_PricingElement _PricingElement
_PriceListType _PriceListType
_InvoiceClearingStatus I_BillingDocument _InvoiceClearingStatus
_DunningAreaText I_BillingDocument _DunningAreaText
_CreatedByUser _CreatedByUser
_SitnInstceIndicator _SitnInstceIndicator
@AbapCatalog.sqlViewName: 'CBDOCF0797'
@AbapCatalog: {
  compiler.compareFilter: true,
  preserveKey: true
}
@AccessControl: {
  authorizationCheck: #CHECK,
  privilegedAssociations: [ '_PricingElement', '_DunningAreaText' ]
}
@EndUserText.label: 'Billing Document'
@VDM.viewType: #CONSUMPTION
@Search.searchable: true

@Metadata.allowExtensions: true

@AccessControl.personalData.blocking: #('TRANSACTIONAL_DATA')
@ObjectModel: {
   compositionRoot: true,
   semanticKey:     ['BillingDocument'],   
   createEnabled: false,
   updateEnabled: 'EXTERNAL_CALCULATION',
   deleteEnabled: false,
   usageType: { 
    serviceQuality:#D, // more than 3 tables // had to move to D because of ATC

    sizeCategory: #XL, // because parent is XL (ATC)

    dataClass: #MIXED
   }
}

define view C_BillingDocument_F0797
  as select from I_BillingDocument as BillingDocument
  left outer join C_BillingRunErrorLog                  as _FirstErrorMessage    on _FirstErrorMessage.SDDocument = BillingDocument.BillingDocument

  association [0..*] to C_BillingDocumentItem_F0797     as _Item                 on $projection.BillingDocument = _Item.BillingDocument
  
  association [0..*] to C_PricingElement                as _PricingElement       on $projection.PricingDocument = _PricingElement.PricingDocument
   
  association [0..1] to C_SoldToValueHelp               as _SoldToParty          on $projection.SoldToParty     = _SoldToParty.Customer
  association [0..1] to C_SoldToValueHelp               as _PayerParty           on $projection.PayerParty      = _PayerParty.Customer

  association [0..1] to C_Dischannelvaluehelp           as _DistributionChannel  on  $projection.SalesOrganization   = _DistributionChannel.SalesOrganization
                                                                                 and $projection.DistributionChannel = _DistributionChannel.DistributionChannel
                                                                                 


  association [0..1] to C_OrgDivisionValueHelp          as _Division             on  $projection.SalesOrganization   = _Division.SalesOrganization
                                                                                 and $projection.DistributionChannel = _Division.DistributionChannel
                                                                                 and $projection.Division            = _Division.Division
                                                                                 
                                                                                 
  association [0..1] to C_SalesDocPaymentMethodVH       as _PaymentMethod        on  $projection.PaymentMethod      = _PaymentMethod.PaymentMethod
                                                                                 and $projection.CompanyCode = _PaymentMethod.BillingCompanyCode
                                                                                                                                          
  association [0..1] to I_CollectiveProcessingErrorLog  as  _ErrorLog            on  _ErrorLog.CollectiveProcessing            = ''  
                                                                                 and $projection.BillingDocument               = _ErrorLog.SDDocument   
                                                                                 and _ErrorLog.CollectiveProcessingMsgCounter  = _FirstErrorMessage.CollectiveProcessingMsgCounter
                                                                                 and _ErrorLog.ScheduleLine                    = _FirstErrorMessage.ScheduleLine  
                                                                                 and _ErrorLog.SystemMessageType               = 'E'                                                                                
  
  association [0..1] to C_BillingDocumentUserVH   as _CreatedByUser           on $projection.CreatedByUser = _CreatedByUser.UserID
  
  association [1]    to E_BillingDocument               as _Extension            on $projection.BillingDocument = _Extension.BillingDocument
  
  association [0..1] to C_BillgSalesDocCatVH as _SDDocumentCategory on  $projection.SDDocumentCategory = _SDDocumentCategory.SDDocumentCategory
  
  association [0..1] to I_SitnInstceIndicator as _SitnInstceIndicator on _SitnInstceIndicator.SitnInstceAnchorObjectKey = $projection.BillingDocument
                                                                      and _SitnInstceIndicator.SitnDefAnchorObject = 'BillingDocument'   
{

      @Search.defaultSearchElement: true
      @Search.fuzzinessThreshold: 0.9
      @Search.ranking: #HIGH
      @ObjectModel.readOnly: true
  key BillingDocument.BillingDocument,

      @ObjectModel: {
        foreignKey.association: '_BillingDocumentType',
        readOnly: true
      }
      BillingDocument.BillingDocumentType,

      BillingDocument._BillingDocumentType._Text[1: Language = $session.system_language ].BillingDocumentTypeName,

      @Search: {
        defaultSearchElement: true,
        fuzzinessThreshold: 0.8,
        ranking: #HIGH
      }
      @ObjectModel: {
        foreignKey.association: '_PayerParty',
        readOnly: true
      }      
      BillingDocument.PayerParty,
      
    
      

      @ObjectModel: {
        foreignKey.association: '_OverallBillingStatus',
        mandatory: true,
        readOnly: true
      }
      @DefaultAggregation: #NONE
      cast(BillingDocument.OverallBillingStatus as billing_document_status preserving type) as OverallBillingStatus,
      

      @Search: {
        defaultSearchElement: true,
        fuzzinessThreshold: 0.8,
        ranking: #HIGH
      }
      @ObjectModel: {
        foreignKey.association: '_SoldToParty',
        readOnly: true
        }
      BillingDocument.SoldToParty,
      
      
      

      @ObjectModel.readOnly: true    
      BillingDocument.BillingIssueType,

      @Semantics.currencyCode: true
      @ObjectModel: {
        foreignKey.association: '_TransactionCurrency',
        readOnly: true
      }
      BillingDocument.TransactionCurrency,
      @ObjectModel.readOnly: true
      BillingDocument._CompanyCode.Currency,
      @ObjectModel.readOnly: true
      BillingDocument.BillingDocumentIsCancelled,
      @ObjectModel.readOnly: true      
      BillingDocument.CancelledBillingDocument,
      
      @Consumption.valueHelp: '_SDDocumentCategory'  
      @ObjectModel: {
        foreignKey.association: '_SDDocumentCategory',
        readOnly: true
      }
      BillingDocument.SDDocumentCategory,

      // * General Information *

      @ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
      BillingDocument.BillingDocumentDate,
      @ObjectModel.readOnly: true
      BillingDocument.CompanyCode,
      @ObjectModel.readOnly: true
      @Semantics.fiscal.year: true
      BillingDocument.FiscalYear,
      @Search.defaultSearchElement: true      
      @Search.fuzzinessThreshold: 0.9
      @ObjectModel.readOnly: true            
      cast(AccountingDocument as accounting_document_number) as AccountingDocument,
      @ObjectModel.readOnly: true
      cast(BillingDocument.DocumentReferenceID as xblnr_v1_case_sensitive) as DocumentReferenceID,
      @ObjectModel.readOnly: true
      BillingDocument.PurchaseOrderByCustomer,
      @ObjectModel: { 
        foreignKey.association: '_SalesOrganization',
        readOnly: true
      }
      BillingDocument.SalesOrganization,
      @ObjectModel.readOnly: true      
      BillingDocument.DistributionChannel,
      @ObjectModel.readOnly: true      
      BillingDocument.Division, 
      @ObjectModel.readOnly: true
      BillingDocument.SalesDistrict,
      
      
      @ObjectModel.readOnly: true
      BillingDocument.TotalNetAmount,
      @ObjectModel.readOnly: true
      BillingDocument.TotalTaxAmount as TaxAmount,
      @DefaultAggregation: #NONE
      @Semantics.amount.currencyCode: 'TransactionCurrency'
      @ObjectModel.readOnly: true      
      cast( (BillingDocument.TotalTaxAmount + BillingDocument.TotalNetAmount) as sdci_odata_total_amount) as TotalGrossAmount,
      
      @UI: { textArrangement: #TEXT_ONLY }
      @ObjectModel.readOnly: true      
      BillingDocument.AccountingTransferStatus,      
      
      // * Terms and Conditions *

      @ObjectModel.readOnly: true
      @ObjectModel.foreignKey.association: '_IncotermsVersion'
      BillingDocument.IncotermsVersion,
      @ObjectModel: {
        foreignKey.association: '_IncotermsClassification',
        readOnly: true
      }
      BillingDocument.IncotermsClassification,
      @ObjectModel.readOnly: true
      BillingDocument.IncotermsLocation1,
      @ObjectModel.readOnly: true
      BillingDocument.IncotermsLocation2,
      @ObjectModel.readOnly: true
      BillingDocument.IsRelevantForAccrual,      
      // Missing: IncotermsLocation1Label, IncotermsLocation2Label , foreign key association to IncotermsVersion

      
      @ObjectModel: {
        foreignKey.association: '_PaymentMethod',
        readOnly: true
      }
      BillingDocument.PaymentMethod,
      @ObjectModel: {
        foreignKey.association: '_CustomerPaymentTerms',
        readOnly: true
      }
      BillingDocument.CustomerPaymentTerms,
      @ObjectModel.readOnly: true
      //@ObjectModel.foreignKey.association: '_'

      BillingDocument.IsIntrastatReportingRelevant,
      @ObjectModel.readOnly: true
      BillingDocument.IsIntrastatReportingExcluded,

      _SitnInstceIndicator.SitnNumberOfInstances as SitnNumberOfInstances,
    
      @Consumption.filter.selectionType: #SINGLE
      cast(case when _SitnInstceIndicator.SitnNumberOfInstances > 0 then 'X' else ' ' end as billingdocumenthassituations) as BillingDocumentHasSituations,      
      
      @ObjectModel.readOnly: true
      BillingDocument.InvoiceListType,
      @ObjectModel.readOnly: true
      BillingDocument.ShippingCondition,
      @ObjectModel.readOnly: true
      BillingDocument.ManualInvoiceMaintIsRelevant,
      
      
      
      // * Accounting Data *

      @ObjectModel.readOnly: true
      BillingDocument.CustomerAccountAssignmentGroup,
      @ObjectModel.readOnly: true
      BillingDocument.FixedValueDate,
      @ObjectModel.readOnly: true
      AdditionalValueDays,
      @ObjectModel.readOnly: true
      AssignmentReference,
      @ObjectModel.readOnly: true
      AccountingExchangeRateIsSet,
      @ObjectModel.readOnly: true
      cast(abs( AccountingExchangeRate ) as kurrf_not_converted)                                               as AbsltAccountingExchangeRate,
      @ObjectModel.readOnly: true
      cast(case when AccountingExchangeRate < 0 then 'X' else ' ' end  as kurrf_quotatn_is_indirect) as AcctgExchangeRateIsIndrctQtan,

      
      
      @ObjectModel: {
        text.control: #('ASSOCIATED_TEXT_UI_HIDDEN'),
        readOnly: true
      }
      BillingDocument.DunningArea,
      @ObjectModel.readOnly: true           
      BillingDocument.DunningBlockingReason,
      @ObjectModel.readOnly: true
      BillingDocument.DunningKey,
      
      // * Pricing *

      @UI.hidden:true
      BillingDocument.PricingDocument,
      @ObjectModel.readOnly: true
      BillingDocument.SDPricingProcedure,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerGroup,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerRebateAgreement,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerPriceGroup,
      @ObjectModel.readOnly: true
      @ObjectModel.foreignKey.association: '_PriceListType'
      BillingDocument.PriceListType,
      
      // * Taxes *

      @ObjectModel.readOnly: true
      BillingDocument.Country,
      @ObjectModel.readOnly: true
      BillingDocument.TaxDepartureCountry,
      // Missing: Foreign key associations

      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification1,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification2,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification3,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification4,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification5,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification6,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification7,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification8,
      @ObjectModel.readOnly: true
      BillingDocument.CustomerTaxClassification9,
      @ObjectModel.readOnly: true
      BillingDocument.VATRegistration,
      @ObjectModel.readOnly: true     
      BillingDocument.CityCode,
      @ObjectModel.readOnly: true     
      BillingDocument.County,
      @ObjectModel.readOnly: true     
      BillingDocument.Region,
      @ObjectModel.readOnly: true     
      BillingDocument.VATRegistrationCountry,
      @ObjectModel.readOnly: true     
      BillingDocument.VATRegistrationOrigin,
      @ObjectModel.readOnly: true
      BillingDocument.IsEUTriangularDeal,
            
      // Field control, workaround, for texts

      @ObjectModel: { filter.enabled: false, readOnly: true }
      cast('1' as sdci_odata_ux_fc) as UxFcTexts,
      @ObjectModel: { filter.enabled: false, readOnly: true }
      cast('1' as sdci_odata_ux_fc) as UxAcPost,
      @ObjectModel: { filter.enabled: false, readOnly: true }
      cast('1' as sdci_odata_ux_fc) as UxAcCancel,
      
      // Workaround: 

      // CustomerName in C_SoldToValueHelp is not annotated as default search element

      // (reason: it is a calculated field which is not supported by HANA for a contains search)

      // Thus OrganizationBPName1 and OrganizationBPName2 are included in our consumption view

      // and are defined as default search elements (beside the SoldToParty itself)  

      @UI.hidden
      @Consumption.filter.hidden: true      
      @Search.defaultSearchElement: true
      @Search.fuzzinessThreshold: 0.8
      _SoldToParty.OrganizationBPName1 as SoldToPartyName,

      @UI.hidden
      @Consumption.filter.hidden: true
      @Search.defaultSearchElement: true
      @Search.fuzzinessThreshold: 0.8
      _SoldToParty.OrganizationBPName2 as SoldToPartyAdditionalName,
      
      @UI.hidden
      @Consumption.filter.hidden: true
      @Search.defaultSearchElement: true
      @Search.fuzzinessThreshold: 0.8
      _PayerParty.OrganizationBPName1 as PayerPartyName,

      @UI.hidden
      @Consumption.filter.hidden: true
      @Search.defaultSearchElement: true
      @Search.fuzzinessThreshold: 0.8      
      _PayerParty.OrganizationBPName2 as PayerPartyAdditionalName,      
            
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true            
      case tstmp_is_valid(cast(BillingDocument.LastChangeDateTime as abap.dec(15,0)))
        when 0 then cast( dats_tims_to_tstmp( BillingDocument.CreationDate, BillingDocument.CreationTime, 'UTC', $session.client, 'NULL' ) as timestampl )
        else BillingDocument.LastChangeDateTime
      end as LastChangeDateTime,
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true      
      BillingDocument.CreationDate,
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true      
      BillingDocument.CreationTime,
      
      @ObjectModel.foreignKey.association: '_CreatedByUser'
      BillingDocument.CreatedByUser,
  
      @ObjectModel.readOnly: true  
      @Consumption.filter.hidden: true
      cast(case when BillingDocumentIsTemporary = 'S' then 'X' else BillingDocumentIsTemporary end as vf_draft_indicator) as BillingDocumentIsTemporary,   
      
      @ObjectModel.readOnly: true
      BillingDocument.InvoiceClearingStatus,
      
      @Search.defaultSearchElement: false
      BillingDocument._CompanyCode,
      @Search.defaultSearchElement: false
      BillingDocument._FiscalYear,
      @Search.defaultSearchElement: false
      _SalesOrganization,
      @Search.defaultSearchElement: false
      _DistributionChannel,
      @Search.defaultSearchElement: false
      _Division,
      @Search.defaultSearchElement: false
      _SalesDistrict,
      @Search.defaultSearchElement: false
      _ShippingCondition,
      @Search.defaultSearchElement: false
      _InvoiceListType,
      
      @Search.defaultSearchElement: false
      _SDDocumentCategory,
      @Search.defaultSearchElement: false
      BillingDocument._CustomerPaymentTerms,
      @Search.defaultSearchElement: false
      BillingDocument._IncotermsClassification,
      @Search.defaultSearchElement: false
      BillingDocument._IncotermsVersion,
      @Search.defaultSearchElement: false
      BillingDocument._BillingDocumentType,
      @Search.defaultSearchElement: false
      _SoldToParty,
      @Search.defaultSearchElement: false
      _PayerParty,
      @Search.defaultSearchElement: false
      BillingDocument._BillingIssueType,
      @Search.defaultSearchElement: false
      BillingDocument._OverallBillingStatus,
      @Search.defaultSearchElement: false
      _PaymentMethod,
      @Search.defaultSearchElement: false
      BillingDocument._CustomerGroup,
      @Search.defaultSearchElement: false
      BillingDocument._CustomerPriceGroup,
      
      @Search.defaultSearchElement: false
      BillingDocument._CustomerAccountAssgmtGroup,
//      BillingDocument._DunningArea,

      @Search.defaultSearchElement: false
      BillingDocument._DunningBlockingReason,
      @Search.defaultSearchElement: false
      BillingDocument._DunningKey,
      
      @Search.defaultSearchElement: false
      BillingDocument._Country,
      @Search.defaultSearchElement: false
      BillingDocument._TaxDepartureCountry,
      @Search.defaultSearchElement: false
      BillingDocument._TransactionCurrency,
      @Search.defaultSearchElement: false
      BillingDocument._AccountingTransferStatus,
      @Search.defaultSearchElement: false
      BillingDocument._CityCode,
      @Search.defaultSearchElement: false
      BillingDocument._County_2,
      @Search.defaultSearchElement: false
      BillingDocument._Region,
      @Search.defaultSearchElement: false
      BillingDocument._VATRegistrationCountry,
      @Search.defaultSearchElement: false
      BillingDocument._VATRegistrationOrigin,
      @Search.defaultSearchElement: false
      BillingDocument._SDPricingProcedure,      
       
      // Error Log Message

      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageIdentification,
      @ObjectModel.readOnly: true      
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageNumber,
      @ObjectModel.readOnly: true      
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageType,
      @ObjectModel.readOnly: true      
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageVariable1,
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageVariable2,
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageVariable3,
      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true
      _ErrorLog.SystemMessageVariable4,
      
      // todo: replacement of field name SystemMessageText

      @ObjectModel.readOnly: true
      @Consumption.filter.hidden: true      
      cast('' as sdci_odata_issue_text) as SystemMessageText,

      @Search.defaultSearchElement: true      
      @ObjectModel.association.type:  [ #TO_COMPOSITION_CHILD ]
      _Item,
      @Search.defaultSearchElement: false
      @ObjectModel.association.type:  [ #TO_COMPOSITION_CHILD ]
      _PricingElement,
      @Search.defaultSearchElement: false
      _PriceListType,
      
      @Search.defaultSearchElement: false
      BillingDocument._InvoiceClearingStatus,
      
      @Search.defaultSearchElement: false
      @Consumption.hidden: true
      BillingDocument._DunningAreaText,
      @Search.defaultSearchElement: false
      _CreatedByUser,
      
      @Search.defaultSearchElement: false
      _SitnInstceIndicator

      //,PARTYSET

} // GFN is missing for draft, fkart_ab  

// Invoice list documents are not relevant

where BillingDocument.BillingDocumentCategory <> 'R'                                                                                                                                                                                                                    
  
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"C_BILLINGRUNERRORLOG",
"C_SOLDTOVALUEHELP",
"I_BILLINGDOCUMENT",
"I_BILLINGDOCUMENTTYPE",
"I_BILLINGDOCUMENTTYPETEXT",
"I_COLLECTIVEPROCESSINGERRORLOG",
"I_COMPANYCODE",
"I_SITNINSTCEINDICATOR"
],
"ASSOCIATED":
[
"C_BILLGSALESDOCCATVH",
"C_BILLINGDOCUMENTITEM_F0797",
"C_BILLINGDOCUMENTUSERVH",
"C_DISCHANNELVALUEHELP",
"C_ORGDIVISIONVALUEHELP",
"C_PRICINGELEMENT",
"C_SALESDOCPAYMENTMETHODVH",
"C_SOLDTOVALUEHELP",
"E_BILLINGDOCUMENT",
"I_ACCOUNTINGTRANSFERSTATUS",
"I_BILLINGDOCUMENTTYPE",
"I_BILLINGISSUETYPE",
"I_CITYCODE",
"I_COLLECTIVEPROCESSINGERRORLOG",
"I_COMPANYCODE",
"I_COUNTRY",
"I_CURRENCY",
"I_CUSTOMERACCOUNTASSGMTGROUP",
"I_CUSTOMERGROUP",
"I_CUSTOMERPAYMENTTERMS",
"I_CUSTOMERPRICEGROUP",
"I_DUNNINGAREATEXT",
"I_DUNNINGBLOCKINGREASONCODE",
"I_DUNNINGKEY",
"I_FISCALYEARFORCOMPANYCODE",
"I_INCOTERMSCLASSIFICATION",
"I_INCOTERMSVERSION",
"I_INVOICECLEARINGSTATUS",
"I_OVERALLBILLINGSTATUS",
"I_PRICELISTTYPE",
"I_REGION",
"I_SALESDISTRICT",
"I_SALESORGANIZATION",
"I_SHIPPINGCONDITION",
"I_SITNINSTCEINDICATOR",
"I_SLSPRICINGPROCEDURE",
"I_TAXINGCOUNTY",
"I_VATREGISTRATIONORIGIN"
],
"BASE":
[
"I_BILLINGDOCUMENT"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/