P_AR_LengthOfRefDoc

DDL: P_AR_LENGTHOFREFDOC SQL: PLENREFDOC Type: view COMPOSITE Package: GLO_FIN_IS_VAT_AR

Private View to find the length of ReferenceDocument

P_AR_LengthOfRefDoc is a Composite CDS View that provides data about "Private View to find the length of ReferenceDocument" in SAP S/4HANA. It reads from 7 data sources and exposes 27 fields with key fields CompanyCode, AccountingDocument, DocumentReferenceID, FiscalYear, AccountingDocument. Part of development package GLO_FIN_IS_VAT_AR.

Data Sources (7)

SourceAliasJoin Type
I_AccountingDocument I_AccountingDocument from
I_AR_DocumentTypeClass I_AR_DocumentTypeClass inner
I_BillingDocumentBasic I_BillingDocumentBasic union_all
I_BillingDocumentType I_BillingDocumentType inner
I_DeliveryDocument I_DeliveryDocument union_all
I_DeliveryDocumentType I_DeliveryDocumentType inner
I_SalesOrganization I_SalesOrganization inner

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PLENREFDOC view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #COMPOSITE view
ClientHandling.algorithm #SESSION_VARIABLE view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.dataClass #MIXED view
AccessControl.personalData.blocking #NOT_REQUIRED view
VDM.private true view

Fields (27)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_AccountingDocument CompanyCode
KEY AccountingDocument I_AccountingDocument AccountingDocument
KEY DocumentReferenceID I_AccountingDocument DocumentReferenceID
KEY FiscalYear I_AccountingDocument FiscalYear
AccountingDocumentType I_AR_DocumentTypeClass AccountingDocumentType
DocumentClass I_AR_DocumentTypeClass DocumentClass
refdoc
subsbl
CompanyCodeasCompanyCode
KEY AccountingDocument I_DeliveryDocument DeliveryDocument
KEY DocumentReferenceID I_DeliveryDocument ReferenceDocumentNumber
KEY CreationDate14endendasFiscalyear
AccountingDocumentType
CreationDateendendasReportingDate
DocumentClass
refdoc
subsbl
CompanyCodeasCompanyCode
KEY AccountingDocument I_BillingDocumentBasic BillingDocument
KEY DocumentReferenceID I_BillingDocumentBasic DocumentReferenceID
KEY Fiscalyear
AccountingDocumentType
ReportingDate I_BillingDocumentBasic BillingDocumentDate
DocumentClass
refdoc
subsbl
subsbl1
@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
           
           }
           
           */