P_PL_SAFTMaterialDocumentRecd

DDL: P_PL_SAFTMATERIALDOCUMENTRECD SQL: PPLSAFTMATDOCREC Type: view COMPOSITE

P_PL_SAFTMaterialDocumentRecd is a Composite CDS View in SAP S/4HANA. It reads from 3 data sources (I_MaterialDocumentRecord, I_Material, I_PL_SAFTMaterialDocItemBasic) and exposes 57 fields with key fields CompanyCode, PL_GoodsMovementTypeCategory, Plant, StorageLocation, MaterialDocumentYear. It has 3 associations to related views.

Data Sources (3)

SourceAliasJoin Type
I_MaterialDocumentRecord a inner
I_Material m inner
I_PL_SAFTMaterialDocItemBasic v inner

Associations (3)

CardinalityTargetAliasCondition
[0..1] I_ProductValuationBasic _ProductValuation a.Material = _ProductValuation.Product and a.InventoryValuationType = _ProductValuation.ValuationType and a.CompanyCode = _ProductValuation.ValuationArea
[0..1] P_PL_SAFTPOSupplierInvoice _POSupplierInvoice a.PurchaseOrder = _POSupplierInvoice.PurchasingDocument and a.PurchaseOrderItem = _POSupplierInvoice.PurchasingDocumentItem
[0..1] P_PL_SAFTGdsMvtBillDocument _GoodsMovementBillingDocument a.DeliveryDocument = _GoodsMovementBillingDocument.DeliveryDocument and a.DeliveryDocumentItem = _GoodsMovementBillingDocument.DeliveryDocumentItem

Annotations (10)

NameValueLevelField
AbapCatalog.sqlViewName PPLSAFTMATDOCREC view
AbapCatalog.compiler.compareFilter true view
AbapCatalog.preserveKey true view
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.private true view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #P view
ClientHandling.algorithm #SESSION_VARIABLE view

Fields (57)

KeyFieldSource TableSource FieldDescription
KEY CompanyCode I_MaterialDocumentRecord CompanyCode
KEY PL_GoodsMovementTypeCategory z PL_GoodsMovementTypeCategory
KEY Plant I_MaterialDocumentRecord Plant
KEY StorageLocation I_MaterialDocumentRecord StorageLocation
KEY MaterialDocumentYear z MaterialDocumentYear
KEY MaterialDocument z MaterialDocument
KEY MaterialDocumentItem z MaterialDocumentItem
FiscalYear I_MaterialDocumentRecord FiscalYear
Material I_MaterialDocumentRecord Material
InventoryValuationType I_MaterialDocumentRecord InventoryValuationType
Customer I_MaterialDocumentRecord Customer
Supplier I_MaterialDocumentRecord Supplier
IssuingOrReceivingPlant I_MaterialDocumentRecord IssuingOrReceivingPlant
IssuingOrReceivingStorageLoc I_MaterialDocumentRecord IssuingOrReceivingStorageLoc
IssgOrRcvgSpclStockInd I_MaterialDocumentRecord IssgOrRcvgSpclStockInd
GoodsReceiptType I_MaterialDocumentRecord GoodsReceiptType
DocumentDate I_MaterialDocumentRecord DocumentDate
PostingDate I_MaterialDocumentRecord PostingDate
PurchaseOrder I_MaterialDocumentRecord PurchaseOrder
PurchaseOrderItem I_MaterialDocumentRecord PurchaseOrderItem
DeliveryDocument I_MaterialDocumentRecord DeliveryDocument
DeliveryDocumentItem I_MaterialDocumentRecord DeliveryDocumentItem
BillOfLading I_MaterialDocumentRecord BillOfLading
GoodsMovementType I_MaterialDocumentRecord GoodsMovementType
DebitCreditCode I_MaterialDocumentRecord DebitCreditCode
IsAutomaticallyCreated I_MaterialDocumentRecord IsAutomaticallyCreated
InventorySpecialStockType I_MaterialDocumentRecord InventorySpecialStockType
MasterFixedAsset I_MaterialDocumentRecord MasterFixedAsset
FixedAsset I_MaterialDocumentRecord FixedAsset
ControllingArea I_MaterialDocumentRecord ControllingArea
CostCenter I_MaterialDocumentRecord CostCenter
ManufacturingOrder I_MaterialDocumentRecord ManufacturingOrder
WBSElementInternalID I_MaterialDocumentRecord WBSElementInternalID
GLAccount I_MaterialDocumentRecord GLAccount
MaterialBaseUnit I_MaterialDocumentRecord MaterialBaseUnit
CompanyCodeCurrency I_MaterialDocumentRecord CompanyCodeCurrency
_Plant _Plant
_StorageLocation _StorageLocation
_IssuingOrReceivingPlant _IssuingOrReceivingPlant
_IssuingOrReceivingStorageLoc _IssuingOrReceivingStorageLoc
_Material _Material
_MaterialBaseUnit _MaterialBaseUnit
_ProductValuation _ProductValuation
_Customer _Customer
_Supplier _Supplier
_PurchaseOrder _PurchaseOrder
_PurchaseOrderItem _PurchaseOrderItem
_DeliveryDocument _DeliveryDocument
_DeliveryDocumentItem _DeliveryDocumentItem
_GoodsMovementBillingDocument _GoodsMovementBillingDocument
_POSupplierInvoice _POSupplierInvoice
_MasterFixedAsset _MasterFixedAsset
_FixedAsset _FixedAsset
_CostCenter _CostCenter
_ManufacturingOrder _ManufacturingOrder
_WBSElement _WBSElement
_GLAccount _GLAccount
@AbapCatalog.sqlViewName: 'PPLSAFTMATDOCREC'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@VDM.private: true
@VDM.viewType: #COMPOSITE
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass:  #MIXED
@ObjectModel.usageType.serviceQuality: #P
@ClientHandling.algorithm: #SESSION_VARIABLE
define view P_PL_SAFTMaterialDocumentRecd
  as select distinct from P_PL_SAFTMaterialDocRecdBasic as z
    inner join   I_MaterialDocumentRecord      as a on  a.MaterialDocumentYear = z.MaterialDocumentYear
                                                    and a.MaterialDocument     = z.MaterialDocument
                                                    and a.MaterialDocumentItem = z.MaterialDocumentItem

    inner join   I_PL_SAFTMaterialDocItemBasic as v on  v.MaterialDocument     = a.MaterialDocument
                                                    and v.MaterialDocumentYear = a.MaterialDocumentYear
                                                    and v.MaterialDocumentItem = a.MaterialDocumentItem
    inner join   I_Material                    as m on  m.Material     =  a.Material
                                                    and m.MaterialType <> 'DIEN'
                                                    and m.MaterialType <> 'SERV'

  association [0..1] to I_ProductValuationBasic     as _ProductValuation             on  a.Material               = _ProductValuation.Product
                                                                                     and a.InventoryValuationType = _ProductValuation.ValuationType
                                                                                     and a.CompanyCode            = _ProductValuation.ValuationArea

  association [0..1] to P_PL_SAFTPOSupplierInvoice  as _POSupplierInvoice            on  a.PurchaseOrder     = _POSupplierInvoice.PurchasingDocument
                                                                                     and a.PurchaseOrderItem = _POSupplierInvoice.PurchasingDocumentItem

  association [0..1] to P_PL_SAFTGdsMvtBillDocument as _GoodsMovementBillingDocument on  a.DeliveryDocument     = _GoodsMovementBillingDocument.DeliveryDocument
                                                                                     and a.DeliveryDocumentItem = _GoodsMovementBillingDocument.DeliveryDocumentItem

{
  key a.CompanyCode,
  key z.PL_GoodsMovementTypeCategory,
  key a.Plant,
  key a.StorageLocation,
  key z.MaterialDocumentYear,
  key z.MaterialDocument,
  key z.MaterialDocumentItem,

      a.FiscalYear,

      a.Material,
      a.InventoryValuationType,


      a.Customer,
      a.Supplier,

      a.IssuingOrReceivingPlant,
      a.IssuingOrReceivingStorageLoc,
      a.IssgOrRcvgSpclStockInd,
      a.GoodsReceiptType,

      a.DocumentDate,
      a.PostingDate,

      a.PurchaseOrder,
      a.PurchaseOrderItem,

      a.DeliveryDocument,
      a.DeliveryDocumentItem,

      a.BillOfLading,

      a.GoodsMovementType,
      a.DebitCreditCode,

      a.IsAutomaticallyCreated,
      a.InventorySpecialStockType,

      a.MasterFixedAsset,
      a.FixedAsset,
      a.ControllingArea,
      a.CostCenter,
      a.ManufacturingOrder,
      a.WBSElementInternalID,
      a.GLAccount,

      @Semantics.unitOfMeasure: true
      @ObjectModel.foreignKey.association: '_MaterialBaseUnit'
      a.MaterialBaseUnit,
      @Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
      case when a.DebitCreditCode = 'H'
        then - a.QuantityInBaseUnit
        else a.QuantityInBaseUnit
      end             as QuantityInBaseUnit,

      @Semantics.currencyCode: true
      a.CompanyCodeCurrency,

      //Material unit price

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      abs( cast( case
        when a.TotalGoodsMvtAmtInCCCrcy <> 0
          then division(TotalGoodsMvtAmtInCCCrcy, a.QuantityInBaseUnit,2)
        when a.TotalGoodsMvtAmtInCCCrcy = 0 and v.StockValueInCCCrcy <> 0 and v.TotalValStockQuantity <> 0
          then division(v.StockValueInCCCrcy,v.TotalValStockQuantity,2)
        when z.PL_MMDocumentHasAlwaysPriceAmt = 'X' and _ProductValuation.MovingAveragePrice is not null
          then _ProductValuation.MovingAveragePrice
        else 0
      end as netpr) ) as NetPriceInCompanyCodeCrcy,

      //Material movement total amount

      @Semantics.amount.currencyCode: 'CompanyCodeCurrency'
      cast( case
        when a.TotalGoodsMvtAmtInCCCrcy <> 0
          then
            case when a.DebitCreditCode = 'H'
              then - a.TotalGoodsMvtAmtInCCCrcy
              else a.TotalGoodsMvtAmtInCCCrcy
            end
        when a.TotalGoodsMvtAmtInCCCrcy = 0 and v.StockValueInCCCrcy <> 0 and v.TotalValStockQuantity <> 0
          then
            case when a.DebitCreditCode = 'H'
              then  - a.QuantityInBaseUnit * division(v.StockValueInCCCrcy,v.TotalValStockQuantity,2)
              else (a.QuantityInBaseUnit * division(v.StockValueInCCCrcy,v.TotalValStockQuantity,2))
            end
        when z.PL_MMDocumentHasAlwaysPriceAmt = 'X' and _ProductValuation.MovingAveragePrice is not null
          then
            case when a.DebitCreditCode = 'H'
              then - _ProductValuation.MovingAveragePrice * a.QuantityInBaseUnit
              else _ProductValuation.MovingAveragePrice * a.QuantityInBaseUnit
            end
        else 0
      end as ck_gwbk) as TotalAmountInCoCodeCrcy,

      _Plant,
      _StorageLocation,

      _IssuingOrReceivingPlant,
      _IssuingOrReceivingStorageLoc,

      _Material,
      _MaterialBaseUnit,
      _ProductValuation,

      _Customer,
      _Supplier,

      _PurchaseOrder,
      _PurchaseOrderItem,

      _DeliveryDocument,
      _DeliveryDocumentItem,

      _GoodsMovementBillingDocument,

      _POSupplierInvoice,

      _MasterFixedAsset,
      _FixedAsset,
      _CostCenter,
      _ManufacturingOrder,
      _WBSElement,
      _GLAccount


}
where
       z.PL_GoodsMovementTypeCategory <> 'MM'
  or(
       a.Plant                        <> a.IssuingOrReceivingPlant
    or a.StorageLocation              <> a.IssuingOrReceivingStorageLoc
    or a.Material                     <> a.IssgOrRcvgMaterial
  )
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_MATERIAL",
"I_MATERIALDOCUMENTRECORD",
"I_PL_SAFTMATERIALDOCITEMBASIC",
"I_PRODUCTVALUATIONBASIC",
"P_PL_SAFTMATERIALDOCRECDBASIC"
],
"ASSOCIATED":
[
"I_COSTCENTER",
"I_CUSTOMER",
"I_DELIVERYDOCUMENT",
"I_DELIVERYDOCUMENTITEM",
"I_FIXEDASSET",
"I_GLACCOUNT",
"I_MANUFACTURINGORDER",
"I_MASTERFIXEDASSET",
"I_MATERIAL",
"I_PLANT",
"I_PRODUCTVALUATIONBASIC",
"I_PURCHASEORDER",
"I_PURCHASEORDERITEM",
"I_STORAGELOCATION",
"I_SUPPLIER",
"I_UNITOFMEASURE",
"I_WBSELEMENTBYINTERNALKEY",
"P_PL_SAFTGDSMVTBILLDOCUMENT",
"P_PL_SAFTPOSUPPLIERINVOICE"
],
"BASE":
[
"I_MATERIALDOCUMENTRECORD"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/