I_SUPDMNDALLDOCRETSLSORD

CDS View

View for Return Sales Orders

I_SUPDMNDALLDOCRETSLSORD is a CDS View in S/4HANA. View for Return Sales Orders. It contains 31 fields. 4 CDS views read from this table.

CDS Views using this table (4)

ViewTypeJoinVDMDescription
I_SupDmndAllDocRetSlsOrdAssgC view left_outer COMPOSITE Cube View for Return Sales Orders Assignment Details
I_SupDmndAllDocRetSlsOrdC view from COMPOSITE Cube View for Return Sales Orders Details
I_SupDmndAllDocSupAmt view union_all COMPOSITE View for Supply of All Documents
P_SupDmndAllDocRetSlsOrdAssgmt view from COMPOSITE

Fields (31)

KeyField CDS FieldsUsed in Views
KEY AssignedSupplyType AssignedSupplyType 3
KEY Batch Batch 3
KEY Material Material 3
KEY Plant Plant 3
KEY ProductAvailabilityDate ProductAvailabilityDate 3
KEY StorageLocation StorageLocation 3
KEY SupplyItem SupplyItem 3
KEY SupplyNumber SupplyNumber 3
KEY SupplyScheduleLine SupplyScheduleLine 3
BaseUnit BaseUnit 3
CompanyCode CompanyCode 1
CrossPlantConfigurableProduct CrossPlantConfigurableProduct 3
Customer Customer 1
DistributionChannel DistributionChannel 1
Division Division 1
DocumentCurrency DocumentCurrency 3
MaterialGroup MaterialGroup 3
MaterialType MaterialType 1
NetPriceAmount NetPriceAmount 3
OrderType OrderType 1
PurchasingGroup PurchasingGroup 3
PurchasingOrganization PurchasingOrganization 1
RequestedDeliveryDate RequestedDeliveryDate 3
SalesDistrict SalesDistrict 1
SalesDocumentRjcnReason SalesDocumentRjcnReason 2
SalesOrganization SalesOrganization 1
SDDocumentReason SDDocumentReason 2
StockSegment StockSegment 2
SupAssgmtSource SupAssgmtSource 3
SupplyDeliveryDate SupplyDeliveryDate 1
TotalQuantity TotalQuantity 2
@ClientHandling.algorithm: #SESSION_VARIABLE
@VDM: {
  viewType: #BASIC,
  lifecycle.contract.type: #PUBLIC_LOCAL_API
}
@AccessControl: {
  authorizationCheck: #NOT_REQUIRED,
  personalData.blocking: #('TRANSACTIONAL_DATA')
}
@AbapCatalog: {
  sqlViewName: 'ISUPDMNDADRETSO',
  compiler.compareFilter: true
 }
@ObjectModel: {
   usageType: {
     dataClass:      #TRANSACTIONAL,
     serviceQuality: #X,
     sizeCategory:   #XXL
   }
}
@EndUserText.label: 'View for Return Sales Orders'
define view I_SupDmndAllDocRetSlsOrd
  as select from    vbak                         as vbak
    inner join      vbap                         as vbap    on vbak.vbeln = vbap.vbeln
    inner join      vbep                         as vbep    on vbap.vbeln = vbep.vbeln
                                                           and vbap.posnr = vbep.posnr
    inner join      kna1                         as kna1    on vbak.kunnr = kna1.kunnr

  //    inner join             tvep                         as tvep    on vbep.ettyp = tvep.ettyp

    inner join      I_SupDmndMaterialPlant       as marc    on  vbap.matnr = marc.Material
                                                            and vbap.werks = marc.Plant
    left outer join vbkd                         as vbkd    on  vbap.vbeln      = vbkd.vbeln
                                                            and vbap.vbkd_posnr = vbkd.posnr
    left outer join I_SDDocumentCompletePartners as vbpa_sp on  vbap.vbeln              = vbpa_sp.SDDocument
                                                            and vbap.posnr              = vbpa_sp.SDDocumentItem
                                                            and vbpa_sp.PartnerFunction = 'AG'
{
  cast(vbap.vbeln as abap.char(12))        as SupplyNumber,
  cast(vbap.posnr as abap.char(6))         as SupplyItem,
  cast(vbep.etenr as  abap.char(4))        as SupplyScheduleLine,
  'R'                                      as AssignedSupplyType,
  'R'                                      as SupAssgmtSource,
  vbep.mbdat                               as SupplyDeliveryDate,
  vbep.mbdat                               as ProductAvailabilityDate,
  vbep.mbdat                               as RequestedDeliveryDate,
  case
    when vbep.umvkn != 0 and vbep.umvkn != 1
    then cast( vbep.wmeng * division(vbep.umvkz,vbep.umvkn,3) as ovr_conf_so_sl_qty )
    else cast( vbep.wmeng as ovr_conf_so_sl_qty )
  end                                      as TotalQuantity,
  case
    when vbep.umvkn != 0 and vbep.umvkn != 1
    then cast( vbep.wmeng * division(vbep.umvkz,vbep.umvkn,3) as ovr_conf_so_sl_qty ) - vbep.dlvqty_bu
    else vbep.wmeng - vbep.dlvqty_bu
  end                                      as OpenSupplyQuantity,
  vbap.meins                               as BaseUnit,
  vbap.matnr                               as Material,
  vbap.matkl                               as MaterialGroup,
  vbap.werks                               as Plant,
  vbak.auart                               as OrderType,
  marc.MaterialType,
  vbap.sgt_rcat                            as StockSegment,
  marc.CrossPlantConfigurableProduct,
  vbak.vkorg                               as SalesOrganization,
  vbak.vtweg                               as DistributionChannel,
  vbak.spart                               as Division,
  vbkd.bzirk                               as SalesDistrict,
  cast('' as ekorg )                       as PurchasingOrganization,
  cast('' as ekgrp )                       as PurchasingGroup,
  cast('' as charg_d )                     as Batch,
  cast('' as lgort_d )                     as StorageLocation,
  coalesce( vbpa_sp.Customer, vbak.kunnr ) as Customer,
  vbak.bukrs_vf                            as CompanyCode,
  vbak.augru                               as SDDocumentReason,
  vbap.abgru                               as SalesDocumentRjcnReason,
  vbap.netpr                               as NetPriceAmount,
  vbap.waerk                               as DocumentCurrency
}
where
  vbak.vbtyp = 'H'  //Document Category = Returns

  and vbak.rfgsk != 'C' //Total Reference Status != Completely processed

  and vbak.lfstk != 'C' //Total Delivery Status != Completely processed

  and kna1.cvp_xblck = ''
  and vbap.rfsta != 'C' //Reference Status != Completely processed

  and vbap.posar != 'B' //Item Type != Text item

  and vbap.lfsta != 'C' //Delivery Status != Completely processed

  //  and vbap.abgru != ' ' //RejectionReason != ' '

  and vbap.shkzg = 'X' //Returns = 'X'

  and(
      vbap.sobkz = ' '
    //    or vbap.sobkz = 'E'

  ) //Consider Orders on Hand


  and vbep.wmeng > 0
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"I_SDDOCUMENTCOMPLETEPARTNERS",
"I_SUPDMNDMATERIALPLANT",
"KNA1",
"VBAK",
"VBAP",
"VBEP",
"VBKD"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/