@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":""
}
}*/