@AbapCatalog.sqlViewName: 'PLENREFDOC'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.viewType: #COMPOSITE
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.dataClass: #MIXED
@AccessControl.personalData.blocking: #NOT_REQUIRED
@VDM.private: true
//@EndUserText.label: 'Private View to find the length of ReferenceDocument'
define view P_AR_LengthOfRefDoc as select from I_AccountingDocument
inner join I_AR_DocumentTypeClass
on I_AR_DocumentTypeClass.AccountingDocumentType = I_AccountingDocument.AccountingDocumentType
{
key I_AccountingDocument.CompanyCode,
key I_AccountingDocument.AccountingDocument as AccountingDocument,
key I_AccountingDocument.DocumentReferenceID,
key I_AccountingDocument.FiscalYear ,
I_AR_DocumentTypeClass.AccountingDocumentType as AccountingDocumentType,
cast (
case DATS_IS_VALID(I_AccountingDocument.TaxReportingDate)
when 1 then
I_AccountingDocument.TaxReportingDate
else
I_AccountingDocument.PostingDate
end as glo_reporting_date ) as ReportingDate,
//I_AccountingDocument.DocumentDate,
I_AR_DocumentTypeClass.DocumentClass,
length (I_AccountingDocument.DocumentReferenceID ) as refdoc,
substring(I_AccountingDocument.DocumentReferenceID,2,4) as subsbl,
substring(I_AccountingDocument.DocumentReferenceID,1,4) as subsbl1
}
union all
select from I_DeliveryDocument
inner join I_SalesOrganization
on I_DeliveryDocument.SalesOrganization = I_SalesOrganization.SalesOrganization
inner join I_DeliveryDocumentType
on I_DeliveryDocument.DeliveryDocumentType = I_DeliveryDocumentType.DeliveryDocumentType
{
key I_SalesOrganization.CompanyCode as CompanyCode,
key I_DeliveryDocument.DeliveryDocument as AccountingDocument,
key I_DeliveryDocument.ReferenceDocumentNumber as DocumentReferenceID,
key
case
when I_SalesOrganization.ArgentinaDeliveryDateEvent = '1'
then substring(I_DeliveryDocument.ActualGoodsMovementDate,1,4)
else
case
when I_SalesOrganization.ArgentinaDeliveryDateEvent = '3'
then substring(I_DeliveryDocument.CreationDate,1,4)
end
end as Fiscalyear,
'' as AccountingDocumentType,
case
when I_SalesOrganization.ArgentinaDeliveryDateEvent = '1'
then I_DeliveryDocument.ActualGoodsMovementDate
else
case
when I_SalesOrganization.ArgentinaDeliveryDateEvent = '3'
then I_DeliveryDocument.CreationDate
end
end as ReportingDate,
'' as DocumentClass,
length (I_DeliveryDocument.ReferenceDocumentNumber ) as refdoc,
substring(I_DeliveryDocument.ReferenceDocumentNumber,2,4) as subsbl,
substring(I_DeliveryDocument.ReferenceDocumentNumber,1,4) as subsbl1
}
union all
select from I_BillingDocumentBasic
inner join I_BillingDocumentType
on I_BillingDocumentBasic.BillingDocumentType = I_BillingDocumentType.BillingDocumentType
{
key I_BillingDocumentBasic._CompanyCode.CompanyCode as CompanyCode,
key I_BillingDocumentBasic.BillingDocument as AccountingDocument,
key I_BillingDocumentBasic.DocumentReferenceID as DocumentReferenceID,
key substring(I_BillingDocumentBasic.BillingDocumentDate,1,4) as Fiscalyear,
'' as AccountingDocumentType,
I_BillingDocumentBasic.BillingDocumentDate as ReportingDate,
'' as DocumentClass,
length (I_BillingDocumentBasic.DocumentReferenceID ) as refdoc,
substring(I_BillingDocumentBasic.DocumentReferenceID,2,4) as subsbl,
substring(I_BillingDocumentBasic.DocumentReferenceID,1,4) as subsbl1
}
/* Code has to be revised by having one join with I_Accounting Document XBLNR Field (DocumentReferenceID)
/*union all
select from I_MaterialDocumentHeader
//inner join I_AccountingDocument
// on I_MaterialDocumentHeader.MaterialDocument = I_AccountingDocument.DocumentReferenceID
{
key '' as CompanyCode,
key I_MaterialDocumentHeader.MaterialDocument as DocNumber,
key I_MaterialDocumentHeader.ReferenceDocument as DocumentReferenceID,
key substring(I_MaterialDocumentHeader.PostingDate,1,4) as Fiscalyear,
'' as AccountingDocumentType,
substring(I_MaterialDocumentHeader.PostingDate,1,4) as ReportingDate,
'' as DocumentClass,
length (I_MaterialDocumentHeader.ReferenceDocument ) as refdoc,
substring(I_MaterialDocumentHeader.ReferenceDocument,2,4) as subsbl,
substring(I_MaterialDocumentHeader.ReferenceDocument,1,4) as subsbl1
}
*/