@AbapCatalog.sqlViewName: 'PLANTREF'
@VDM.viewType: #BASIC@AccessControl.authorizationCheck: #NOT_REQUIRED@VDM.private: true@ObjectModel.usageType.serviceQuality: #A@ObjectModel.usageType.sizeCategory : #S@ObjectModel.usageType.dataClass: #MASTER@AbapCatalog.compiler.compareFilter:true@ClientHandling.algorithm: #SESSION_VARIABLEdefineview P_PlantReferences asselectfrom t001w
leftouter to one join tvkov on t001w.vkorg = tvkov.vkorg
and t001w.vtweg = tvkov.vtweg
leftouter to one join twpa on t001w.mandt = twpa.mandt
{
key t001w.werks as Plant,
t001w.vkorg as SalesOrganization,
t001w.vtweg as DistributionChannel,
// t001w.spart,
t001w.vlfkz as PlantCategory,
cast (
casewhen t001w.vlfkz = 'B' and twpa.vlgvz = t001w.werks
then ''
when t001w.vlfkz = 'B' //twpa.vlgvz <> t001w.werks
then twpa.vlgvz
else ''
endas vlgvz ) as ReferenceDistributionCenter,
cast (
casewhen tvkov.vlgfi = t001w.werks and t001w.vlfkz = 'A'
then '' //t001w.werks is reference store
when tvkov.vlgfi <> '' and t001w.vlfkz = 'A' //twpa.vlgfi <> t001w.werks
then tvkov.vlgfi
when tvkov.vlgfi = '' and t001w.vlfkz = 'A' and twpa.vlgfi = t001w.werks
then '' //t001w.werks is reference store
when tvkov.vlgfi = '' and t001w.vlfkz = 'A' and twpa.vlgfi<> t001w.werks
then twpa.vlgfi
else '' //no reference store maintained
endas vlgfi ) as ReferenceStore,
cast (
casewhen t001w.vlfkz = 'B' and twpa.vlgvz = t001w.werks
then 'X'
else ''
endas boole_d ) as IsReferenceDistributionCenter,
cast (
casewhen tvkov.vlgfi = t001w.werks and t001w.vlfkz = 'A'
then 'X'
when tvkov.vlgfi = '' and twpa.vlgfi = t001w.werks and t001w.vlfkz = 'A'
then 'X'
else ''
endas boole_d ) as IsReferenceStore
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"T001W",
"TVKOV",
"TWPA"
],
"ASSOCIATED":
[],
"BASE":
[],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/