P_DerivativePosOptnDelta

DDL: P_DERIVATIVEPOSOPTNDELTA SQL: POPTDELTAPOS Type: view COMPOSITE

P_DerivativePosOptnDelta is a Composite CDS View in SAP S/4HANA. It reads from 3 data sources (P_DerivativePosAdptrLayer, P_VerFinEvalOptnDeltaUnion, vtbfha) and exposes 78 fields.

Data Sources (3)

SourceAliasJoin Type
P_DerivativePosAdptrLayer P_DerivativePosAdptrLayer from
P_VerFinEvalOptnDeltaUnion P_VerFinEvalOptnDeltaUnion left_outer
vtbfha vtbfha left_outer

Parameters (5)

NameTypeDefault
P_DisplayView cds_view_uom
P_EvaluationDate cds_evaluation_date
P_ComparisionDate cds_evaluation_date
P_OptionDeltaMethod cds_option_delta_method
P_OptionDeltaThreshold cds_option_delta_threshold

Annotations (8)

NameValueLevelField
VDM.private true view
VDM.viewType #COMPOSITE view
ClientHandling.algorithm #SESSION_VARIABLE view
AbapCatalog.sqlViewName POPTDELTAPOS view
AccessControl.authorizationCheck #NOT_REQUIRED view
ObjectModel.usageType.serviceQuality #D view
ObjectModel.usageType.sizeCategory #XL view
ObjectModel.usageType.dataClass #TRANSACTIONAL view

Fields (78)

KeyFieldSource TableSource FieldDescription
CompanyCode vfind CompanyCode
CommodityPriceExposure vfind CommodityPriceExposure
CommodityExposureCategory vfind CommodityExposureCategory
CommodityPriceSubExposure vfind CommodityPriceSubExposure
CommodityPriceExposureVersion vfind CommodityPriceExposureVersion
ValidityStartDateTime vfind ValidityStartDateTime
ValidityEndDateTime vfind ValidityEndDateTime
ValidityStartDate vfind ValidityStartDate
ValidityStartTime vfind ValidityStartTime
ValidityEndDate vfind ValidityEndDate
ValidityEndTime vfind ValidityEndTime
ValidityStartCharTimestamp vfind ValidityStartCharTimestamp
ValidityEndCharTimestamp vfind ValidityEndCharTimestamp
MaximumVersion vfind MaximumVersion
RiskAnalyzerVersionUUID vfind RiskAnalyzerVersionUUID
ExposureDueDate vfind ExposureDueDate
ReportingDate vfind ReportingDate
Commodity vfind Commodity
CashFlowDirection vfind CashFlowDirection
TreasuryPositionLongShortCode vfind TreasuryPositionLongShortCode
DerivativeContrSpecification vfind DerivativeContrSpecification
MarketIdentifierCode vfind MarketIdentifierCode
QuotationPriceType vfind QuotationPriceType
TimeToMaturity vfind TimeToMaturity
CmmdtyForwardIndexTiming vfind CmmdtyForwardIndexTiming
MaturityKeyDate vfind MaturityKeyDate
DerivativeContractMaturityCode vfind DerivativeContractMaturityCode
FinancialInstrProductCategory vfind FinancialInstrProductCategory
FinancialAssetsMgmtProductType vfind FinancialAssetsMgmtProductType
FinInstrTransactionCategory vfind FinInstrTransactionCategory
FinancialInstrumentProductType vfind FinancialInstrumentProductType
FinancialInstrActivityCategory vfind FinancialInstrActivityCategory
FinancialObject vfind FinancialObject
HasError vfind HasError
TermStartDate vfind TermStartDate
TermEndDate vfind TermEndDate
DeliveryDate vfind DeliveryDate
NumberOfCommodityContracts vfind NumberOfCommodityContracts
TreasuryPositionAccount vfind TreasuryPositionAccount
DerivativeContract vfind DerivativeContract
QuotationCurrency vfind QuotationCurrency
PaymentCurrency vfind PaymentCurrency
OptionStrikePrice vfind OptionStrikePrice
OptionStrikeCurrency vfind OptionStrikeCurrency
OptionPutCallCode vfind OptionPutCallCode
OptionExerciseType vfind OptionExerciseType
EndOfDayBusinessEntityKey vfind EndOfDayBusinessEntityKey
ReportingMonth vfind ReportingMonth
ReportingYear vfind ReportingYear
EvaluationDate vfind EvaluationDate
EndOfDaySnapshotDate vfind EndOfDaySnapshotDate
EndOfDaySnapshotDateTime vfind EndOfDaySnapshotDateTime
ConsumptionType vfind ConsumptionType
FinInstrExternalReference vfind FinInstrExternalReference
TradedDrvtvContrSpecification vfind TradedDrvtvContrSpecification
ParDrvtvContractSpecification vfind ParDrvtvContractSpecification
RiskViewIsNotRelevant vfind RiskViewIsNotRelevant
DisplayView vfind DisplayView
OptionDeltaFactorKeyFigure vfinr OptionDeltaFactorKeyFigure
OptionThetaKeyFigureValue vfinr OptionThetaKeyFigureValue
OptionGammaKeyFigureValue vfinr OptionGammaKeyFigureValue
OptionVegaKeyFigureValue vfinr OptionVegaKeyFigureValue
ExternalKeyFigureValue vfinr ExternalKeyFigureValue
OptionDeltaFactor
OptionThetaValue
OptionGammaValue
OptionVegaValue
CommodityPriceExposureUnit vfind CommodityPriceExposureUnit
FinancialTransactionPortfolio vfind FinancialTransactionPortfolio
CmmdtyHdgPlanExposureHedgeBook vfind CmmdtyHdgPlanExposureHedgeBook
CommodityHedgePlanExposureID vfind CommodityHedgePlanExposureID
_CompanyCode vfind _CompanyCode
_DerivativeContrSpecification vfind _DerivativeContrSpecification
_FinAssetsMgmtProductType vfind _FinAssetsMgmtProductType
_MarketIdentifierCode vfind _MarketIdentifierCode
_PhysicalCommodity vfind _PhysicalCommodity
_UnitOfMeasure vfind _UnitOfMeasure
ProfitCenter vtbfha prctr
@VDM.private: true
@VDM.viewType: #COMPOSITE
@ClientHandling.algorithm: #SESSION_VARIABLE
@AbapCatalog.sqlViewName: 'POPTDELTAPOS'
@AccessControl.authorizationCheck: #NOT_REQUIRED

@ObjectModel.usageType.serviceQuality: #D
@ObjectModel.usageType.sizeCategory: #XL
@ObjectModel.usageType.dataClass: #TRANSACTIONAL

define view P_DerivativePosOptnDelta
  with parameters
    @Consumption.defaultValue: 'P'
    P_DisplayView          : cds_view_uom,
    @Environment.systemField: #SYSTEM_DATE
    P_EvaluationDate       : cds_evaluation_date,
    @Environment.systemField: #SYSTEM_DATE
    P_ComparisionDate      : cds_evaluation_date,
    P_OptionDeltaMethod    : cds_option_delta_method,
    P_OptionDeltaThreshold : cds_option_delta_threshold

  as select from    P_DerivativePosAdptrLayer
                 (P_DisplayView: $parameters.P_DisplayView, P_EvaluationDate: $parameters.P_EvaluationDate, P_ComparisionDate: $parameters.P_ComparisionDate) as vfind
    left outer join P_VerFinEvalOptnDeltaUnion
                    (P_EvaluationDate: $parameters.P_EvaluationDate, P_ComparisionDate: $parameters.P_ComparisionDate)                                        as vfinr  on  vfind.RiskAnalyzerVersionUUID = vfinr.RiskAnalyzerVersionUUID
                                                                                                                                                                        and vfind.EvaluationDate          = vfinr.EvaluationDate
                                                                                                                                                                        and vfind.ConsumptionType         = vfinr.ConsumptionType
    left outer join vtbfha                                                                                                                                    as vtbfha on  vfind.CompanyCode            = vtbfha.bukrs
                                                                                                                                                                        and vfind.CommodityPriceExposure = vtbfha.rfha
{

  vfind.CompanyCode,
  vfind.CommodityPriceExposure,
  vfind.CommodityExposureCategory,
  vfind.CommodityPriceSubExposure,
  vfind.CommodityPriceExposureVersion,
  vfind.ValidityStartDateTime,
  vfind.ValidityEndDateTime,
  vfind.ValidityStartDate,
  vfind.ValidityStartTime,
  vfind.ValidityEndDate,
  vfind.ValidityEndTime,
  vfind.ValidityStartCharTimestamp,
  vfind.ValidityEndCharTimestamp,
  vfind.MaximumVersion,
  vfind.RiskAnalyzerVersionUUID,
  vfind.ExposureDueDate,
  vfind.ReportingDate,
  vfind.Commodity,
  vfind.CashFlowDirection,
  vfind.TreasuryPositionLongShortCode,
  vfind.DerivativeContrSpecification,
  vfind.MarketIdentifierCode,
  vfind.QuotationPriceType,
  vfind.TimeToMaturity,
  vfind.CmmdtyForwardIndexTiming,
  vfind.MaturityKeyDate,
  vfind.DerivativeContractMaturityCode,
  vfind.FinancialInstrProductCategory,
  vfind.FinancialAssetsMgmtProductType,
  vfind.FinInstrTransactionCategory,
  vfind.FinancialInstrumentProductType,
  vfind.FinancialInstrActivityCategory,
  vfind.FinancialObject,
  vfind.HasError,
  vfind.TermStartDate,
  vfind.TermEndDate,
  vfind.DeliveryDate,
  vfind.NumberOfCommodityContracts,
  //    vfind.CommodityPriceFixationStatus,

  cast (  case   when ( vfind.FinancialInstrProductCategory = '760' or  vfind.FinancialInstrProductCategory = '750'
                    or vfind.FinancialInstrProductCategory = '700' )
                  and vfind.CommodityPriceFixationStatus = '2'
                 then ( case when ( vfind.ConsumptionType = '03' and vfind.ExposureDueDate < vfind.EvaluationDate ) or
                                  ( ( vfind.ConsumptionType = '01' or vfind.ConsumptionType = '02') and vfind.ExposureDueDate <= vfind.EvaluationDate )
                             then '1'
                             else '2' end )
                 else   vfind.CommodityPriceFixationStatus
           end as  ftr_fixing_status )                                as CommodityPriceFixationStatus,

  vfind.TreasuryPositionAccount,
  vfind.DerivativeContract,
  vfind.QuotationCurrency,
  vfind.PaymentCurrency,
  vfind.OptionStrikePrice,
  vfind.OptionStrikeCurrency,
  vfind.OptionPutCallCode,
  vfind.OptionExerciseType,
  vfind.EndOfDayBusinessEntityKey,
  vfind.ReportingMonth,
  vfind.ReportingYear,
  vfind.EvaluationDate,
  vfind.EndOfDaySnapshotDate,
  vfind.EndOfDaySnapshotDateTime,
  vfind.ConsumptionType,
  vfind.FinInstrExternalReference,
  vfind.TradedDrvtvContrSpecification,
  vfind.ParDrvtvContractSpecification,
  vfind.RiskViewIsNotRelevant,
  vfind.DisplayView,


  // Logic for separating out the options instrument from other instruments

  case when (vfind.FinancialInstrProductCategory = '750' or vfind.FinancialInstrProductCategory = '760')
            then(cast( case $parameters.P_OptionDeltaMethod //Option Delta Factor Method Logic

                            when '1'
                                then vfind.CommodityPriceExposureQuantity
                            when '2' then
  // Multiply with OptionDeltaFactor (= RiskAnalyzerKeyfigureValue). If this value is null, then multiply with 1.

                                case
                                 when vfinr.OptionDeltaFactorKeyFigAbs = 0 or vfinr.OptionDeltaFactorKeyFigAbs is null
                                   then vfind.CommodityPriceExposureQuantity * 1
                                  else
                                     vfind.CommodityPriceExposureQuantity * vfinr.OptionDeltaFactorKeyFigAbs
                                 end
  //then cast( vfind.CommodityPriceExposureQuantity as cmm_eval_option_delta_factor ) * coalesce( vfinr.OptionDeltaFactorKeyFigure, 1 )

                            when '3' then
                              case
                                when vfinr.OptionDeltaFactorKeyFigAbs = 0 or vfinr.OptionDeltaFactorKeyFigAbs is null
                                   then CommodityPriceExposureQuantity // "non options" are always "in the money"

                                when vfinr.OptionDeltaFactorKeyFigAbs >= 0 and vfinr.OptionDeltaFactorKeyFigAbs >= :P_OptionDeltaThreshold
                                   then CommodityPriceExposureQuantity // in the money

                                else 0 // out of the money for options

                              end
                            else
                               vfind.CommodityPriceExposureQuantity
                            end as abap.quan( 13, 3 )))
       else vfind.CommodityPriceExposureQuantity
       end                                                            as CommodityPriceExposureQuantity,

  vfinr.OptionDeltaFactorKeyFigure,
  vfinr.OptionThetaKeyFigureValue,
  vfinr.OptionGammaKeyFigureValue,
  vfinr.OptionVegaKeyFigureValue,
  vfinr.ExternalKeyFigureValue,
  cast( vfinr.OptionDeltaFactorKeyFigure as cds_option_delta_factor ) as OptionDeltaFactor,
  cast( vfinr.OptionThetaKeyFigureValue  as cds_option_theta_value )  as OptionThetaValue,
  cast( vfinr.OptionGammaKeyFigureValue  as cds_option_gamma_value )  as OptionGammaValue,
  cast( vfinr.OptionVegaKeyFigureValue   as cds_option_vega_value  )  as OptionVegaValue,
  //vfind.CommodityPriceExposureQuantity,


  vfind.CommodityPriceExposureUnit,
  //    vfind._CommodityPriceFixationStatus,


  vfind.FinancialTransactionPortfolio,
  vfind.CmmdtyHdgPlanExposureHedgeBook,
  vfind.CommodityHedgePlanExposureID,

  vfind._CompanyCode,
  vfind._DerivativeContrSpecification,
  vfind._FinAssetsMgmtProductType,
  vfind._MarketIdentifierCode,
  vfind._PhysicalCommodity,
  vfind._UnitOfMeasure,
  vtbfha.prctr                                                        as ProfitCenter
}
/*+[internal] {
"BASEINFO":
{
"FROM":
[
"P_DERIVATIVEPOSADPTRLAYER",
"P_VERFINEVALOPTNDELTAUNION",
"VTBFHA"
],
"ASSOCIATED":
[
"I_CMMDTY",
"I_COMPANYCODE",
"I_DERIVATIVECONTRSPEC",
"I_FINASSETSMGNTPRODUCTTYPE",
"I_MARKETIDENTCODE",
"I_UNITOFMEASURE"
],
"BASE":
[
"P_DERIVATIVEPOSADPTRLAYER"
],
"ANNO_REF":
[],
"SCALAR_FUNCTION":
[],
"VERSION":0,
"ANNOREF_EVALUATION_ERROR":""
}
}*/