P_AssociatedTrdSecret

DDL: P_ASSOCIATEDTRDSECRET Type: view_entity CONSUMPTION

P_AssociatedTrdSecret is a Consumption CDS View in SAP S/4HANA. It reads from 1 data source (I_ChmlComposition) and exposes 8 fields with key field ProdCmplncLegalArea. It has 1 association to related views.

Data Sources (1)

SourceAliasJoin Type
I_ChmlComposition Composition from

Associations (1)

CardinalityTargetAliasCondition
[1..1] P_CChmlCmplConstants _Constants _Constants.Constant1 = _Constants.Constant1

Annotations (3)

NameValueLevelField
AccessControl.authorizationCheck #NOT_REQUIRED view
VDM.viewType #CONSUMPTION view
VDM.private true view

Fields (8)

KeyFieldSource TableSource FieldDescription
ChmlCmplncInfoUUID
ChmlCompositionType
KEY ProdCmplncLegalArea I_ChmlComposition ProdCmplncLegalArea
ChmlCompositionInProcessUUID
ChmlCmpstnInProcIsActiveEntity
ChmlCompositionReleasedUUID
ReleasedByUser
ChmlCmpstnReldIsActiveEntity

--Access Control: Authorizations Checks
@AccessControl:
{
   authorizationCheck: #NOT_REQUIRED
}


--VDM view type
@VDM.viewType: #CONSUMPTION
@VDM.private: true

define view entity P_AssociatedTrdSecret
  --Select data from basic view 'Composition'
  as select from           I_ChmlComposition         as Composition

  --Join data from composition with status In Process => Active or draft composition
    left outer to one join P_AssociatedTrdSecretProc as CompositionInProcess on  Composition.ChmlCmplncInfoUUID  = CompositionInProcess.ChmlCmplncInfoUUID
                                                                             and Composition.ProdCmplncLegalArea = CompositionInProcess.ProdCmplncLegalArea

  --Join data from composition with status Released => only active chemical composition, because released composition is not editable
    left outer to one join P_AssociatedTrdSecretReld as CompositionReleased  on  Composition.ChmlCmplncInfoUUID  = CompositionReleased.ChmlCmplncInfoUUID
                                                                             and Composition.ProdCmplncLegalArea = CompositionInProcess.ProdCmplncLegalArea

  association [1..1] to P_CChmlCmplConstants as _Constants on _Constants.Constant1 = _Constants.Constant1
{
      --UUID of chemical compliance information
  key Composition.ChmlCmplncInfoUUID,

      --Composition Type
  key Composition.ChmlCompositionType,
  
  key Composition.ProdCmplncLegalArea,

      --UUID of chemical composition in process
      CompositionInProcess.ChmlCompositionInProcessUUID,

      --Status In Process
      case
        when CompositionInProcess.ChmlCmpstnInProcStatus = 'IP'
          then CompositionInProcess.ChmlCmpstnInProcStatus
        when CompositionInProcess.ChmlCmpstnInProcStatus = ''
             or CompositionInProcess.ChmlCmpstnInProcStatus is null
      --Set NE if the In Process Version is not existing
          then _Constants[inner].ConstantNotExisting
      end as ChmlCmpstnInProcStatus,

      --Indicator: Is active entity of chemical composition with status In Process
      CompositionInProcess.ChmlCmpstnInProcIsActiveEntity,

      --UUID of chemical composition released
      CompositionReleased.ChmlCompositionReleasedUUID,

      --Status Released
      case
        when CompositionReleased.ChmlCmpstnReldStatus = 'RE'
          then CompositionReleased.ChmlCmpstnReldStatus
        when CompositionReleased.ChmlCmpstnReldStatus = ''
             or CompositionReleased.ChmlCmpstnReldStatus is null
      --Set NE if the Released Version is not existing
          then _Constants[inner].ConstantNotExisting
      end as ChmlCmpstnReldStatus,

      --Released by User
      CompositionReleased.ReleasedByUser,

      --Indicator: Is active entity of chemical composition with status In Process
      CompositionReleased.ChmlCmpstnReldIsActiveEntity
}
where
  --Only for Released and In Process Compositions
  // Check for ChmlCompositionCategory = 'A' leads to temporary materialization of this view

  // Condition: ChmlCompositionType <> 'ANALYTIC1' and ChmlCompositionType <> 'MATLBSD1' does not lead to materialization.

  //       Composition._CompositionType.ChmlCompositionCategory =  'A'

  //  and  Composition.ChmlCompositionType                      <> 'ANALYTIC1'

  (
       Composition.ChmlCompositionType   = 'TS'
  )
  and(
       Composition.ChmlCompositionStatus = 'IP'
    or Composition.ChmlCompositionStatus = 'RE'
  )

group by
  Composition.ChmlCmplncInfoUUID,
  Composition.ChmlCompositionType,
  Composition.ProdCmplncLegalArea,
  CompositionInProcess.ChmlCompositionInProcessUUID,
  CompositionInProcess.ChmlCmpstnInProcStatus,
  CompositionInProcess.ChmlCmpstnInProcIsActiveEntity,
  CompositionReleased.ChmlCompositionReleasedUUID,
  CompositionReleased.ChmlCmpstnReldStatus,
  CompositionReleased.ReleasedByUser,
  CompositionReleased.ChmlCmpstnReldIsActiveEntity,
  _Constants[inner].ConstantNotExisting