I_RO_SAFTStockMovementLine

DDL: I_RO_SAFTSTOCKMOVEMENTLINE SQL: IROSAFTSTKMVTITM Type: view COMPOSITE

Stock Movement Line Items

I_RO_SAFTStockMovementLine is a Composite CDS View (Dimension) that provides data about "Stock Movement Line Items" in SAP S/4HANA. It reads from 4 data sources (I_GLAccountLineItemRawData, I_CompanyCode, I_RO_SAFTDocumentTypeMap, I_RO_SAFTMaterialDocumentItem) and exposes 21 fields with key fields AccountingDocument, CompanyCode, FiscalYear, LedgerGLLineItem, MaterialDocumentLine. It has 12 associations to related views.

Data Sources (4)

SourceAliasJoin Type
I_GLAccountLineItemRawData _Acdoca from
I_CompanyCode _CompanyCode inner
I_RO_SAFTDocumentTypeMap _DocumentMap inner
I_RO_SAFTMaterialDocumentItem _Matdoc inner

Parameters (2)

NameTypeDefault
P_Ledger fagl_rldnr
P_AlternativeGLAccountIsUsed boolean

Associations (12)

CardinalityTargetAliasCondition
[0..1] I_ProductUnitsOfMeasure _ProductUom _Matdoc.Product = _ProductUom.Product and _Matdoc.AlternativeUnit = _ProductUom.AlternativeUnit
[0..1] I_RO_SAFTUnitOfMeasureMap _Uom _Matdoc.AlternativeUnit = _Uom.SourceUnitOfMeasure
[0..*] I_RO_BusinessPartnerTaxType _DCustomer _DCustomer.BusinessPartner = _Acdoca.Customer and _DCustomer.BusinessPartnerIsSAFTRelevant = 'X' and _DCustomer.TaxType = '6' and _DCustomer.FinancialAccountType = 'D' and _DCustomer.ValidFrom <= $session.system_date and _DCustomer.ValidTo >= $session.system_date and _DCustomer.VATRegistration is not initial
[0..*] I_RO_BusinessPartnerTaxType _KSupplier _KSupplier.BusinessPartner = _Acdoca.Supplier and _KSupplier.BusinessPartnerIsSAFTRelevant = 'X' and _KSupplier.TaxType = '6' and _KSupplier.FinancialAccountType = 'K' and _KSupplier.ValidFrom <= $session.system_date and _KSupplier.ValidTo >= $session.system_date and _KSupplier.VATRegistration is not initial
[0..1] I_GLAccountInCompanyCode _GLAccount _GLAccount.CompanyCode = _Acdoca.CompanyCode and _GLAccount.GLAccount = _Acdoca.GLAccount
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType1 _MovementType1.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType1.Plant = _Acdoca.Plant and _MovementType1.TargetGLAccount = _Acdoca.GLAccount and _MovementType1.AccountingDocumentType = _Acdoca.AccountingDocumentType and _MovementType1.DebitCreditCode = _Acdoca.DebitCreditCode
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType2 _MovementType2.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType2.Plant = _Acdoca.Plant and _MovementType2.TargetGLAccount = _Acdoca.GLAccount and _MovementType2.AccountingDocumentType = _Acdoca.AccountingDocumentType and _MovementType2.DebitCreditCode = ''
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType3 _MovementType3.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType3.Plant = _Acdoca.Plant and _MovementType3.TargetGLAccount = _Acdoca.GLAccount and _MovementType3.AccountingDocumentType = '' and _MovementType3.DebitCreditCode = ''
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType4 _MovementType4.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType4.Plant = _Acdoca.Plant and _MovementType4.TargetGLAccount = _Acdoca.GLAccount and _MovementType4.AccountingDocumentType = '' and _MovementType4.DebitCreditCode = _Acdoca.DebitCreditCode
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType5 _MovementType5.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType5.Plant = _Acdoca.Plant and _MovementType5.TargetGLAccount = '' and _MovementType5.AccountingDocumentType = _Acdoca.AccountingDocumentType and _MovementType5.DebitCreditCode = _Acdoca.DebitCreditCode
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType6 _MovementType6.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType6.Plant = _Acdoca.Plant and _MovementType6.TargetGLAccount = '' and _MovementType6.AccountingDocumentType = '' and _MovementType6.DebitCreditCode = ''
[0..1] I_RO_SAFTMvtTypeTableEntry _MovementType7 _MovementType7.GoodsMovementType = _Matdoc.GoodsMovementType and _MovementType7.Plant = '' and _MovementType7.TargetGLAccount = '' and _MovementType7.AccountingDocumentType = '' and _MovementType7.DebitCreditCode = ''

Annotations (12)

NameValueLevelField
AbapCatalog.sqlViewName IROSAFTSTKMVTITM view
AbapCatalog.compiler.compareFilter true view
AccessControl.authorizationCheck #MANDATORY view
VDM.viewType #COMPOSITE view
ObjectModel.usageType.sizeCategory #XXL view
ObjectModel.usageType.dataClass #MIXED view
ObjectModel.usageType.serviceQuality #D view
ClientHandling.algorithm #SESSION_VARIABLE view
Analytics.dataCategory #DIMENSION view
Analytics.internalName #LOCAL view
Metadata.allowExtensions true view
EndUserText.label Stock Movement Line Items view

Fields (21)

KeyFieldSource TableSource FieldDescription
KEY AccountingDocument I_GLAccountLineItemRawData AccountingDocument
KEY CompanyCode I_GLAccountLineItemRawData CompanyCode
KEY FiscalYear I_GLAccountLineItemRawData FiscalYear
KEY LedgerGLLineItem I_GLAccountLineItemRawData LedgerGLLineItem
KEY MaterialDocumentLine I_RO_SAFTMaterialDocumentItem MaterialDocumentLine
Product I_GLAccountLineItemRawData Product
Plant I_GLAccountLineItemRawData Plant
DebitCreditCode I_GLAccountLineItemRawData DebitCreditCode
AccountingDocumentType I_GLAccountLineItemRawData AccountingDocumentType
Quantity I_GLAccountLineItemRawData Quantity
PostingDate I_GLAccountLineItemRawData PostingDate
DocumentDate I_GLAccountLineItemRawData DocumentDate
CompanyCodeCurrency I_GLAccountLineItemRawData CompanyCodeCurrency
TransactionAmountInLocalCrcy I_GLAccountLineItemRawData AmountInCompanyCodeCurrency
AccountingDocCreatedByUser I_GLAccountLineItemRawData AccountingDocCreatedByUser
GoodsMovementType I_RO_SAFTMaterialDocumentItem GoodsMovementType
Batch I_RO_SAFTMaterialDocumentItem Batch
MaterialDocumentItemText I_RO_SAFTMaterialDocumentItem MaterialDocumentItemText
SourceUnitOfMeasureFactor _Uom SourceUnitOfMeasureFactor
ChartOfAccountsendasChartOfAccounts
GLAccountendassaknrasTargetGLAccount
@AbapCatalog.sqlViewName: 'IROSAFTSTKMVTITM'
@AbapCatalog.compiler.compareFilter: true
//@AbapCatalog.preserveKey: true

@AccessControl.authorizationCheck: #MANDATORY
@VDM.viewType: #COMPOSITE
@ObjectModel: {
                usageType: { sizeCategory: #XXL,
                             dataClass:  #MIXED,
                             serviceQuality: #D } }
@ClientHandling.algorithm: #SESSION_VARIABLE
@Analytics.dataCategory:#DIMENSION
@Analytics.internalName:#LOCAL
@Metadata.allowExtensions:true
@EndUserText.label: 'Stock Movement Line Items'
define view I_RO_SAFTStockMovementLine
  with parameters P_Ledger          : fagl_rldnr,
                  P_AlternativeGLAccountIsUsed : boolean
  as select from I_GLAccountLineItemRawData as _Acdoca
  inner join I_RO_SAFTMaterialDocumentItem  as _Matdoc    on  _Matdoc.MaterialDocument = _Acdoca.ReferenceDocument
                                                          and _Matdoc.MaterialDocumentYear = _Acdoca.ReferenceDocumentContext
                                                          and _Matdoc.MaterialDocumentLine = _Acdoca.ReferenceDocumentItem
  inner join I_CompanyCode                  as _CompanyCode
                                                          on _Acdoca.CompanyCode = _CompanyCode.CompanyCode
  inner join I_RO_SAFTDocumentTypeMap       as _DocumentMap
                                                          on  _DocumentMap.CompanyCode = _Acdoca.CompanyCode
                                                          and _DocumentMap.AccountingDocumentType = _Acdoca.AccountingDocumentType
                                                          and _DocumentMap.RO_SAFTSourceDocumentType = '05'
  association [0..1] to I_ProductUnitsOfMeasure
                                            as _ProductUom
                                                          on  _Matdoc.Product  = _ProductUom.Product
                                                          and _Matdoc.AlternativeUnit = _ProductUom.AlternativeUnit
  association [0..1] to I_RO_SAFTUnitOfMeasureMap
                                            as _Uom       on  _Matdoc.AlternativeUnit = _Uom.SourceUnitOfMeasure
  association [0..*] to I_RO_BusinessPartnerTaxType
                                            as _DCustomer on  _DCustomer.BusinessPartner = _Acdoca.Customer
                                                          and _DCustomer.BusinessPartnerIsSAFTRelevant = 'X'
                                                          and _DCustomer.TaxType = '6'
                                                          and _DCustomer.FinancialAccountType = 'D'
                                                          and _DCustomer.ValidFrom <= $session.system_date
                                                          and _DCustomer.ValidTo >=  $session.system_date
                                                          and _DCustomer.VATRegistration is not initial
  association [0..*] to I_RO_BusinessPartnerTaxType
                                            as _KSupplier on  _KSupplier.BusinessPartner = _Acdoca.Supplier
                                                          and _KSupplier.BusinessPartnerIsSAFTRelevant = 'X'
                                                          and _KSupplier.TaxType = '6'
                                                          and _KSupplier.FinancialAccountType = 'K'
                                                          and _KSupplier.ValidFrom <= $session.system_date
                                                          and _KSupplier.ValidTo >=  $session.system_date
                                                          and _KSupplier.VATRegistration is not initial
  association [0..1] to I_GLAccountInCompanyCode
                                            as _GLAccount on  _GLAccount.CompanyCode = _Acdoca.CompanyCode
                                                          and _GLAccount.GLAccount   = _Acdoca.GLAccount
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType1
                                                          on  _MovementType1.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType1.Plant = _Acdoca.Plant
                                                          and _MovementType1.TargetGLAccount = _Acdoca.GLAccount
                                                          and _MovementType1.AccountingDocumentType = _Acdoca.AccountingDocumentType
                                                          and _MovementType1.DebitCreditCode = _Acdoca.DebitCreditCode
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType2
                                                          on  _MovementType2.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType2.Plant = _Acdoca.Plant
                                                          and _MovementType2.TargetGLAccount = _Acdoca.GLAccount
                                                          and _MovementType2.AccountingDocumentType = _Acdoca.AccountingDocumentType
                                                          and _MovementType2.DebitCreditCode = ''
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType3
                                                          on  _MovementType3.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType3.Plant = _Acdoca.Plant
                                                          and _MovementType3.TargetGLAccount = _Acdoca.GLAccount
                                                          and _MovementType3.AccountingDocumentType = ''
                                                          and _MovementType3.DebitCreditCode = ''
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType4
                                                          on  _MovementType4.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType4.Plant = _Acdoca.Plant
                                                          and _MovementType4.TargetGLAccount = _Acdoca.GLAccount
                                                          and _MovementType4.AccountingDocumentType = ''
                                                          and _MovementType4.DebitCreditCode = _Acdoca.DebitCreditCode
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType5
                                                          on  _MovementType5.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType5.Plant = _Acdoca.Plant
                                                          and _MovementType5.TargetGLAccount = ''
                                                          and _MovementType5.AccountingDocumentType = _Acdoca.AccountingDocumentType
                                                          and _MovementType5.DebitCreditCode = _Acdoca.DebitCreditCode
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType6
                                                          on  _MovementType6.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType6.Plant = _Acdoca.Plant
                                                          and _MovementType6.TargetGLAccount = ''
                                                          and _MovementType6.AccountingDocumentType = ''
                                                          and _MovementType6.DebitCreditCode = ''
  association [0..1] to I_RO_SAFTMvtTypeTableEntry
                                            as _MovementType7
                                                          on  _MovementType7.GoodsMovementType = _Matdoc.GoodsMovementType
                                                          and _MovementType7.Plant = ''
                                                          and _MovementType7.TargetGLAccount = ''
                                                          and _MovementType7.AccountingDocumentType = ''
                                                          and _MovementType7.DebitCreditCode = ''
{
  key _Acdoca.AccountingDocument,
  key _Acdoca.CompanyCode,
  key _Acdoca.FiscalYear,
  key _Acdoca.LedgerGLLineItem,
  key _Matdoc.MaterialDocumentLine,
      concat(
        concat( _Acdoca.CompanyCode, _Acdoca.FiscalYear ),
        concat( _Acdoca.AccountingDocumentType, _Acdoca.AccountingDocument ) ) as
       BusinessTransactionTypeName,
      _Acdoca.Product,
      _Acdoca.Plant,
      _Acdoca.DebitCreditCode,
      _Acdoca.AccountingDocumentType,
      _Acdoca.Quantity,
      _Acdoca.PostingDate,
      _Acdoca.DocumentDate,
      _Acdoca.CompanyCodeCurrency,
      @Semantics: { amount : {currencyCode: 'CompanyCodeCurrency'} }
      _Acdoca.AmountInCompanyCodeCurrency as TransactionAmountInLocalCrcy,
      _Acdoca.AccountingDocCreatedByUser as AccountingDocCreatedByUser,

      cast(
        case
          when _Acdoca.FinancialAccountType = 'M'
            then concat( '00', substring(_CompanyCode.VATRegistration, 3, 20) )
          else
            ( case
                when _DCustomer.VATRegistration is not null
                  then _DCustomer.VATRegistration
                when _DCustomer.VATRegistration is null and _KSupplier.VATRegistration is null
                  then concat( '00', substring(_CompanyCode.VATRegistration, 3, 20) )
                else
                  '0' end )
        end as stceg ) as CustomerVATRegistration,

      cast(
        case
          when _Acdoca.FinancialAccountType = 'M'
            then concat( '00', substring(_CompanyCode.VATRegistration, 3, 20) )
          else
            ( case
                when _KSupplier.VATRegistration is not null
                  then _KSupplier.VATRegistration
                when _KSupplier.VATRegistration is null and _DCustomer.VATRegistration is null
                  then concat( '00', substring(_CompanyCode.VATRegistration, 3, 20) )
                else
                '0' end )
        end as stceg ) as SupplierVATRegistration,

      _Matdoc.GoodsMovementType,
      _Matdoc.Batch,
      _Matdoc.MaterialDocumentItemText,
      _Uom.SourceUnitOfMeasureFactor,

      case
        when _ProductUom.QuantityDenominator is not null
          then division( _ProductUom.QuantityNumerator, _ProductUom.QuantityDenominator, 2)
        else 0
      end as ConversionFactor,

      case $parameters.P_AlternativeGLAccountIsUsed
        when 'X' then _Acdoca.CountryChartOfAccounts
        else _Acdoca.ChartOfAccounts
      end as ChartOfAccounts,

      cast(
        case $parameters.P_AlternativeGLAccountIsUsed
          when 'X' then _GLAccount.AlternativeGLAccount
          else _Acdoca.GLAccount
        end as saknr ) as TargetGLAccount,

      case
        when _MovementType1.RO_SAFTMovementType is not initial
          then _MovementType1.RO_SAFTMovementType
        when _MovementType2.RO_SAFTMovementType is not initial
          then _MovementType2.RO_SAFTMovementType
        when _MovementType3.RO_SAFTMovementType is not initial
          then _MovementType3.RO_SAFTMovementType
        when _MovementType4.RO_SAFTMovementType is not initial
          then _MovementType4.RO_SAFTMovementType
        when _MovementType5.RO_SAFTMovementType is not initial
          then _MovementType5.RO_SAFTMovementType
        when _MovementType6.RO_SAFTMovementType is not initial
          then _MovementType6.RO_SAFTMovementType
        else _MovementType7.RO_SAFTMovementType
      end as RO_SAFTMovementType

} where _Acdoca.SourceLedger = $parameters.P_Ledger
    and _Acdoca.ReferenceDocumentType = 'MKPF'
//    and _Acdoca.FinancialAccountType = 'M'

    and ( _Acdoca.TransactionTypeDetermination = 'BSX'
    or    _Acdoca.TransactionTypeDetermination = 'KON' )