P_DuplicateSalesDocumentGrpg

DDL: P_DUPLICATESALESDOCUMENTGRPG SQL: PSDDPLSLSDOCGRPG Type: view CONSUMPTION

Grouping Criteria for Duplicate Sales Documents

P_DuplicateSalesDocumentGrpg is a Consumption CDS View that provides data about "Grouping Criteria for Duplicate Sales Documents" in SAP S/4HANA. It reads from 2 data sources (C_SglGregorianCalDateFunction, I_SalesDocument) and exposes 19 fields with key field DuplicateSalesDocumentGroup.

Data Sources (2)

SourceAliasJoin Type
C_SglGregorianCalDateFunction C_SglGregorianCalDateFunction inner
I_SalesDocument SalesDocument from

Parameters (1)

NameTypeDefault
P_DateFunction datefunctionid

Annotations (6)

NameValueLevelField
AbapCatalog.sqlViewName PSDDPLSLSDOCGRPG view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #NOT_REQUIRED view
EndUserText.label Grouping Criteria for Duplicate Sales Documents view
VDM.viewType #CONSUMPTION view
VDM.private true view

Fields (19)

KeyFieldSource TableSource FieldDescription
KEY DuplicateSalesDocumentGroup
NumberOfDuplicateSlsDocuments
SDDocumentCategory I_SalesDocument SDDocumentCategory
_SDDocumentCategory I_SalesDocument _SDDocumentCategory
SalesDocumentType I_SalesDocument SalesDocumentType
_SalesDocumentType I_SalesDocument _SalesDocumentType
SoldToParty I_SalesDocument SoldToParty
_SoldToParty I_SalesDocument _SoldToParty
CreationDate I_SalesDocument CreationDate
TotalNetAmount I_SalesDocument TotalNetAmount
TransactionCurrency I_SalesDocument TransactionCurrency
_TransactionCurrency I_SalesDocument _TransactionCurrency
SalesOrganization I_SalesDocument SalesOrganization
_SalesOrganization I_SalesDocument _SalesOrganization
DistributionChannel I_SalesDocument DistributionChannel
_DistributionChannel I_SalesDocument _DistributionChannel
OrganizationDivision I_SalesDocument OrganizationDivision
_OrganizationDivision I_SalesDocument _OrganizationDivision
PurchaseOrderByCustomer I_SalesDocument PurchaseOrderByCustomer
@AbapCatalog.sqlViewName: 'PSDDPLSLSDOCGRPG'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Grouping Criteria for Duplicate Sales Documents'

@VDM.viewType: #CONSUMPTION
@VDM.private: true
define view P_DuplicateSalesDocumentGrpg
 
  with parameters
    P_DateFunction : datefunctionid
    
  as select from I_SalesDocument as SalesDocument

  inner join C_SglGregorianCalDateFunction( P_DateFunction: $parameters.P_DateFunction, P_Language: $session.system_language ) as Range 
    on  SalesDocument.CreationDate >= Range.DateFunctionStartDate
    and SalesDocument.CreationDate <= Range.DateFunctionEndDate
  
{

  key min( SalesDocument.SalesDocument )          as DuplicateSalesDocumentGroup,

      count( * )                                  as NumberOfDuplicateSlsDocuments,

      @ObjectModel.foreignKey.association: '_SDDocumentCategory'
      SalesDocument.SDDocumentCategory,
      SalesDocument._SDDocumentCategory,

      @ObjectModel.foreignKey.association: '_SalesDocumentType'
      SalesDocument.SalesDocumentType,
      SalesDocument._SalesDocumentType,

      @ObjectModel.foreignKey.association: '_SoldToParty'
      SalesDocument.SoldToParty,
      SalesDocument._SoldToParty,

      SalesDocument.CreationDate,

      SalesDocument.TotalNetAmount,

      @ObjectModel.foreignKey.association: '_TransactionCurrency'
      SalesDocument.TransactionCurrency,
      SalesDocument._TransactionCurrency,

      @ObjectModel.foreignKey.association: '_SalesOrganization'
      SalesDocument.SalesOrganization,
      SalesDocument._SalesOrganization,

      @ObjectModel.foreignKey.association: '_DistributionChannel'
      SalesDocument.DistributionChannel,
      SalesDocument._DistributionChannel,

      @ObjectModel.foreignKey.association: '_OrganizationDivision'
      SalesDocument.OrganizationDivision,
      SalesDocument._OrganizationDivision,

      SalesDocument.PurchaseOrderByCustomer
}
where
       SalesDocument.SalesDocumentProcessingType <> 'S'
  and     
       SalesDocument.SalesDocumentProcessingType <> 'P'
  and
       SalesDocument.OverallSDDocumentRejectionSts <> 'C'
  and(
       SalesDocument.SDDocumentCategory =  'A' // Inquiry

    or SalesDocument.SDDocumentCategory =  'B' // Quotation

    or SalesDocument.SDDocumentCategory =  'C' // Order

    or SalesDocument.SDDocumentCategory =  'G' // Contract

    or SalesDocument.SDDocumentCategory =  'H' // Returns

    or SalesDocument.SDDocumentCategory =  'I' // Order w/o charge

    or SalesDocument.SDDocumentCategory =  'K' // Credit memo request

    or SalesDocument.SDDocumentCategory =  'L' // Debit memo request

  )
group by
  SalesDocument.SDDocumentCategory,
  SalesDocument.SalesDocumentType,
  SalesDocument.SoldToParty,
  SalesDocument.CreationDate,
  SalesDocument.TotalNetAmount,
  SalesDocument.TransactionCurrency,
  SalesDocument.SalesOrganization,
  SalesDocument.DistributionChannel,
  SalesDocument.OrganizationDivision,
  SalesDocument.PurchaseOrderByCustomer
having
  count( * ) > 1
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"C_SGLGREGORIANCALDATEFUNCTION",
"I_SALESDOCUMENT"
],
"ASSOCIATED":
[
"I_CURRENCY",
"I_CUSTOMER",
"I_DISTRIBUTIONCHANNEL",
"I_DIVISION",
"I_SALESDOCUMENTTYPE",
"I_SALESORGANIZATION",
"I_SDDOCUMENTCATEGORY"
],
"BASE":
[
"I_SALESDOCUMENT"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/