P_RETURNSDOCUMENTITEMREFUND

CDS View

P_RETURNSDOCUMENTITEMREFUND is a CDS View in S/4HANA. It contains 30 fields. 1 CDS views read from this table.

CDS Views using this table (1)

ViewTypeJoinVDMDescription
C_CustomerReturnItemRefund view from CONSUMPTION Returns Order Item Refund

Fields (30)

KeyField CDS FieldsUsed in Views
KEY CustomerReturnItem CustomerReturnItem 1
KEY InspectionDocument InspectionDocument 1
BaseUnit BaseUnit 1
Batch Batch 1
BillOfMaterial BillOfMaterial 1
CustomerReturnItemCategory CustomerReturnItemCategory 1
CustomerReturnType CustomerReturnType 1
CustRetItmFollowUpActivity CustRetItmFollowUpActivity 1
DistributionChannel DistributionChannel 1
HigherLevelItem HigherLevelItem 1
InspectedProductQtyInBaseUnit InspectedProductQtyInBaseUnit 1
Material Material 1
NetAmount NetAmount 1
OrderQuantity OrderQuantity 1
OrderQuantityUnit OrderQuantityUnit 1
OrganizationDivision OrganizationDivision 1
Plant Plant 1
ReplacementMaterial ReplacementMaterial 1
ReplacementMaterialQtyUnit ReplacementMaterialQtyUnit 1
ReplacementMatlSupplyingPlant ReplacementMatlSupplyingPlant 1
RetMatlInspResultCode RetMatlInspResultCode 1
RetsMgmtProcess RetsMgmtProcess 1
RetsMgmtProcessItem RetsMgmtProcessItem 1
RetsMgmtProcessStep RetsMgmtProcessStep 1
ReturnsRefundExtent ReturnsRefundExtent 1
ReturnsRefundProcgMode ReturnsRefundProcgMode 1
ReturnsRefundRjcnReason ReturnsRefundRjcnReason 1
ReturnsRefundType ReturnsRefundType 1
SalesOrganization SalesOrganization 1
TransactionCurrency TransactionCurrency 1
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.sqlViewName: 'PCRTITMRFND'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@VDM.private: true
@VDM.viewType: #CONSUMPTION
@AccessControl.authorizationCheck: #NOT_REQUIRED

define view P_ReturnsDocumentItemRefund

  as select from           P_CustomerReturnItemEnhanced   as Refund

    inner join             I_AdvncdRetsMgmtMatlInspection as AdvncdRetsMgmtMatlInspection on  Refund.CustomerReturn                                       = AdvncdRetsMgmtMatlInspection.ReferenceDocument
                                                                                          and Refund.CustomerReturnItem                                   = AdvncdRetsMgmtMatlInspection.ReferenceDocumentItem
                                                                                          and AdvncdRetsMgmtMatlInspection.ReturnsInspectionPublishStatus = 'P'

    left outer to one join I_AdvncdRetsMgmtCompnStatus    as AdvncdRetsMgmtCompnStatus    on  AdvncdRetsMgmtCompnStatus.RetsMgmtProcess          = Refund.RetsMgmtProcess
                                                                                          and AdvncdRetsMgmtCompnStatus.RetsMgmtProcItmQtySplit  = Refund.RetsMgmtProcItmQtySplit
                                                                                          and AdvncdRetsMgmtCompnStatus.RetsMgmtProcessItem      = Refund.CustomerReturnItem
                                                                                          and AdvncdRetsMgmtCompnStatus.ReturnsReferenceDocument = Refund.CustomerReturn

{
  key       Refund.CustomerReturn,
  key       Refund.CustomerReturnItem,
  key       AdvncdRetsMgmtMatlInspection.InspectionDocument                                 as InspectionDocument,
//            Refund.RetsMgmtItmCompnProcgStatus,

            Refund.CustomerReturnItemCategory,
            cast(Refund.OrderQuantity as returned_quantity)                                 as OrderQuantity,
            Refund.OrderQuantityUnit,
            Refund.ReturnsRefundExtent,
            Refund.ReturnsRefundType,
            Refund.HigherLevelItem,
            AdvncdRetsMgmtCompnStatus.RetsMgmtProcessStep,
            Refund.RetsMgmtProcess,
            Refund.RetsMgmtProcessItem,
            Refund.ReturnsRefundProcgMode,
            cast(Refund.Product as productnumber preserving type)                          as Material,
            Refund.ReturnsRefundRjcnReason,
            Refund.NetAmount,
            Refund.TransactionCurrency,
            cast(AdvncdRetsMgmtMatlInspection.RetMatlInspResultCode as msr_inspection_code) as RetMatlInspResultCode,
            Refund._CustomerReturn.SalesOrganization,
            Refund._CustomerReturn.DistributionChannel,
            Refund._CustomerReturn.OrganizationDivision,
            Refund._CustomerReturn.CustomerReturnType,
            Refund.Plant,
            Refund.Batch,

            cast(case when Refund.ReplacementMaterial is initial
            then Refund.Product
            else Refund.ReplacementMaterial
            end  as  return_replace_product)                                                as ReplacementMaterial,

            case when Refund.ReplacementMaterialQtyUnit is initial
            then OrderQuantityUnit
            else Refund.ReplacementMaterialQtyUnit
            end                                                                             as ReplacementMaterialQtyUnit,

            case when Refund.ReplacementMatlSupplyingPlant is initial
            then Refund.Plant
            else Refund.ReplacementMatlSupplyingPlant
            end                                                                             as ReplacementMatlSupplyingPlant,

            Refund.BillOfMaterial,

            case when AdvncdRetsMgmtMatlInspection.CustRetItmFollowUpActivity <> ''
            then AdvncdRetsMgmtMatlInspection.CustRetItmFollowUpActivity
            else Refund.CustRetItmFollowUpActivity
            end                                                                             as CustRetItmFollowUpActivity,

            AdvncdRetsMgmtMatlInspection.ReturnsDelivery,
            AdvncdRetsMgmtMatlInspection.ReturnsDeliveryItem,
            AdvncdRetsMgmtMatlInspection.InspectedProductQtyInBaseUnit,
            AdvncdRetsMgmtMatlInspection.BaseUnit
}
where
      Refund.RetsMgmtProcessingBlock != 'R'
  and Refund.ItemGeneralIncompletionStatus = 'C'
  and Refund.SDDocumentRejectionStatus     = 'A'
  and Refund.CustRetItmFollowUpActivity != '0008'

union all

select from              P_CustomerReturnItemEnhanced as Refund

  left outer to one join I_AdvncdRetsMgmtCompnStatus  as AdvncdRetsMgmtCompnStatus on  AdvncdRetsMgmtCompnStatus.RetsMgmtProcess          = Refund.RetsMgmtProcess
                                                                                   and AdvncdRetsMgmtCompnStatus.RetsMgmtProcItmQtySplit  = Refund.RetsMgmtProcItmQtySplit
                                                                                   and AdvncdRetsMgmtCompnStatus.RetsMgmtProcessItem      = Refund.CustomerReturnItem
                                                                                   and AdvncdRetsMgmtCompnStatus.ReturnsReferenceDocument = Refund.CustomerReturn
{
  key       Refund.CustomerReturn,
  key       Refund.CustomerReturnItem,
  key       '-'                                                    as InspectionDocument,

//            Refund.RetsMgmtItmCompnProcgStatus,

            Refund.CustomerReturnItemCategory,
            cast(Refund.OrderQuantity as returned_quantity)        as OrderQuantity,
            Refund.OrderQuantityUnit,
            Refund.ReturnsRefundExtent,
            Refund.ReturnsRefundType,
            Refund.HigherLevelItem,
            AdvncdRetsMgmtCompnStatus.RetsMgmtProcessStep,
            Refund.RetsMgmtProcess,
            Refund.RetsMgmtProcessItem,
            Refund.ReturnsRefundProcgMode,
            cast(Refund.Product as productnumber preserving type) as Material,
            Refund.ReturnsRefundRjcnReason,
            Refund.NetAmount,
            Refund.TransactionCurrency,
            cast('' as msr_inspection_code)                        as RetMatlInspResultCode,
            Refund._CustomerReturn.SalesOrganization,
            Refund._CustomerReturn.DistributionChannel,
            Refund._CustomerReturn.OrganizationDivision,
            Refund._CustomerReturn.CustomerReturnType,
            Refund.Plant,
            Refund.Batch,

            cast(case when Refund.ReplacementMaterial is initial
            then Refund.Product
            else Refund.ReplacementMaterial
            end  as  return_replace_product)                       as ReplacementMaterial,

            case when Refund.ReplacementMaterialQtyUnit is initial
            then OrderQuantityUnit
            else Refund.ReplacementMaterialQtyUnit
            end                                                    as ReplacementMaterialQtyUnit,
            case when Refund.ReplacementMatlSupplyingPlant is initial
            then Refund.Plant
            else Refund.ReplacementMatlSupplyingPlant
            end                                                    as ReplacementMatlSupplyingPlant,
            Refund.BillOfMaterial,

            Refund.CustRetItmFollowUpActivity                      as CustRetItmFollowUpActivity,
            cast(''       as vbeln_vl)                             as ReturnsDelivery,
            cast('000000' as posnr_vl)                             as ReturnsDeliveryItem,
            cast(0        as /spe/inspqty)                         as InspectedProductQtyInBaseUnit,
            cast(''       as  meins)                               as BaseUnit

}
where
      Refund.RetsMgmtProcessingBlock != 'R'
  and Refund.ItemGeneralIncompletionStatus = 'C'
  and Refund.SDDocumentRejectionStatus     = 'A'
  and Refund.CustRetItmFollowUpActivity != '0008'
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_ADVNCDRETSMGMTCOMPNSTATUS",
"I_ADVNCDRETSMGMTMATLINSPECTION",
"I_CUSTOMERRETURNENHANCED",
"P_CUSTOMERRETURNITEMENHANCED"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/