Derived SQL interpretation, reconstructed from the parsed view metadata (data sources, associations, and field mappings). SAP annotations are omitted and the structure is reformulated as SQL — this is a functional approximation, not the verbatim SAP source.
-- Derived SQL interpretation of CDS view P_CmmdtyHedgeCalcExpsrDealQuan.
-- Reconstructed from parsed metadata (data sources, associations, fields).
-- SAP annotations are omitted and the structure is reformulated as SQL;
-- this is a functional approximation, not the verbatim SAP source. Some join
-- conditions may be unavailable and a few CDS constructs are kept as-is.
-- SQL view name: PCMHDGCALEXDLQUA
-- Parameters: P_CmmdtyHdgUtilznPlnExposureID : cmm_exposure_id, P_CmmdtyHdgUtilznEvalDate : sydatum, P_CmmdtyHdgUtilznIsDesignated : xfeld, P_CmmdtyHdgUtilznIsFreeStndg : xfeld, P_CmmdtyHdgUtilznIsCnstltnData : xfeld, P_CmmdtyHdgUtilznAreOverHedged : xfeld, P_CmmdtyHdgPlanExposureVersion : cmm_exposure_version
CREATE VIEW P_CmmdtyHedgeCalcExpsrDealQuan AS
SELECT
Quantity.CmmdtyHdgConstellationExposure AS CmmdtyHdgConstellationExposure,
Quantity.CommodityHedgePlanExposureUUID AS CommodityHedgePlanExposureUUID,
Quantity.CmmdtyHdgPlnExpsrCompanyCode AS CmmdtyHdgPlnExpsrCompanyCode,
Quantity.CmmdtyHedgePlanExposureDCSID AS CmmdtyHedgePlanExposureDCSID,
Quantity.CmmdtyHdgPlanExpsrMktIDCode AS CmmdtyHdgPlanExpsrMktIDCode,
Quantity.CmmdtyHdgPlanExposureDirection AS CmmdtyHdgPlanExposureDirection,
Quantity.CmmdtyHdgPlanExposureHedgeBook AS CmmdtyHdgPlanExposureHedgeBook,
Quantity.CmmdtyHdgPlnExpsrPerdStartDate AS CmmdtyHdgPlnExpsrPerdStartDate,
Quantity.CmmdtyHdgPlnExpsrPeriodClass AS CmmdtyHdgPlnExpsrPeriodClass,
TQPosition.CmmdtyHdgTgtQuotaPositionYear AS CmmdtyHdgTgtQuotaPositionYear,
TgtQtaExpsrmap.CmmdtyHdgPlnExpsrDelivPerdType AS CmmdtyHdgTgtQuotaPeriodNumber,
Expsrprd.CmmdtyHdgPlnExpsrDelivPerdType AS CmmdtyHdgPlnExpsrDelivPerdType,
Expsrprd.CmmdtyHdgPlnExpsrDelivPerdYear AS CmmdtyHdgPlnExpsrDelivPerdYear,
concat ( concat( Expsrprd.CmmdtyHdgPlnExpsrDelivPerdType, '/' ), Expsrprd.CmmdtyHdgPlnExpsrDelivPerdYear ) AS CmmdtyHdgPlnExpsrDelivPerdText,
Quantity.CmmdtyHedgePlnExposureQuantity AS CmmdtyHedgePlnExposureQuantity,
Quantity.CmmdtyHdgPlnExpsrQuantityUnit AS CmmdtyHdgPlnExpsrQuantityUnit,
sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) AS CmmdtyHdgUtilznHedgedAbsltVal,
case when Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 then ( sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) * cast(100 as abap.fltp)) / Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHedgeUtilznHedgedPercent AS fltpendasCmmdtyHedgeUtilznHedgedPercent,
sum(Quantity.CmmdtyHdgDsgntdDealQuantity) AS CmmdtyHdgUtilznHedgedAcctgVal,
case when Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 then ( sum(Quantity.CmmdtyHdgDsgntdDealQuantity) * cast(100 as abap.fltp)) / Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHdgUtilznHedgedAcctgPct AS fltpendasCmmdtyHdgUtilznHedgedAcctgPct,
sum(Quantity.CmmdtyHdgFreeStndgQuantity) AS CmmdtyHdgUtilznHdgFreeStndgVal,
case when Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 then ( sum(Quantity.CmmdtyHdgFreeStndgQuantity) * cast(100 as abap.fltp)) / Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHdgUtilznHdgFreeStndgPct AS fltpendasCmmdtyHdgUtilznHdgFreeStndgPct,
case when TargetQuota.CmmdtyHdgTgtQuotaIsFullyHedged = 'X' and Quantity.CmmdtyHdgIsPrcgInDelivPeriod = 'X' and TgtQtaExpsrmap.CmmdtyHdgTgtQtaPerdStartValue <= substring($parameters.P_CmmdtyHdgUtilznEvalDate,5,4) then (sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) - ( Quantity.CmmdtyHedgePlnExposureQuantity ) ) else (sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) - ( Quantity.CmmdtyHedgePlnExposureQuantity * ( TQPosition.CmmdtyHdgTgtQtaUprLmtInPercent / cast(100 as abap.fltp) ) ) ) end as CmmdtyHdgUtilznOverHedgedValue AS fltpendasCmmdtyHdgUtilznOverHedgedValue,
case when ( Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 ) and TargetQuota.CmmdtyHdgTgtQuotaIsFullyHedged = ' ' then ((sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) - ( Quantity.CmmdtyHedgePlnExposureQuantity * ( TQPosition.CmmdtyHdgTgtQtaUprLmtInPercent / cast(100 as abap.fltp) ) ) ) * cast(100 as abap.fltp)) / Quantity.CmmdtyHedgePlnExposureQuantity when ( Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 ) and ( TargetQuota.CmmdtyHdgTgtQuotaIsFullyHedged = 'X' and Quantity.CmmdtyHdgIsPrcgInDelivPeriod = 'X' and TgtQtaExpsrmap.CmmdtyHdgTgtQtaPerdStartValue <= substring($parameters.P_CmmdtyHdgUtilznEvalDate,5,4) ) then ((sum(Quantity.CmmdtyHdgDealQtyInExposureUoM) - ( Quantity.CmmdtyHedgePlnExposureQuantity ) ) * cast(100 as abap.fltp)) / Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHedgeUtilznOverHedgedPct AS fltpendasCmmdtyHedgeUtilznOverHedgedPct,
case when ( Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 ) and TargetQuota.CmmdtyHdgTgtQuotaIsFullyHedged = ' ' then ( TQPosition.CmmdtyHdgTgtQtaUprLmtInPercent / cast(100 as abap.fltp ) )* Quantity.CmmdtyHedgePlnExposureQuantity when ( Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 ) and ( TargetQuota.CmmdtyHdgTgtQuotaIsFullyHedged = 'X' and Quantity.CmmdtyHdgIsPrcgInDelivPeriod = 'X' and TgtQtaExpsrmap.CmmdtyHdgTgtQtaPerdStartValue <= substring($parameters.P_CmmdtyHdgUtilznEvalDate,5,4) ) then Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHdgUtilznTgtQtaMgmtValue AS fltpendasCmmdtyHdgUtilznTgtQtaMgmtValue,
case when Quantity.CmmdtyHedgePlnExposureQuantity is not null and Quantity.CmmdtyHedgePlnExposureQuantity is not initial and Quantity.CmmdtyHedgePlnExposureQuantity <> 0 then ( TQPosition.CmmdtyHdgAcctgUprLmtInPercent / cast(100 as abap.fltp ) ) * Quantity.CmmdtyHedgePlnExposureQuantity else cast(0 as abap.fltp) end as CmmdtyHdgUtilznTgtQtaAcctgVal AS fltpendasCmmdtyHdgUtilznTgtQtaAcctgVal,
TQPosition.CmmdtyHdgAcctgUprLmtInPercent AS CmmdtyHdgUtilznTgtQtaAcctgPct
INNER JOIN P_CmmdtyHdgExpsrVersionPeriod AS Expsrprd ON /* join condition not captured in parsed metadata */
INNER JOIN P_CmmdtyHdgTgtQtaExpsrPerdMap ON /* join condition not captured in parsed metadata */
INNER JOIN P_CmmdtyHdgTgtQuotaHedgeBook AS TargetQuota ON /* join condition not captured in parsed metadata */
INNER JOIN I_CmmdtyHdgTargetQuotaPosition AS TQPosition ON /* join condition not captured in parsed metadata */
;