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_CMMDTYNEWACTPNLVALUE_SUM_2.
-- 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: PCMMPNLNASUM2
-- Parameters: P_EvaluationDate : cmm_eval_keydate, P_ExchRateEvaluationDate : cmm_eval_keydate, P_EndOfDaySnapshotFromDate : cmm_dend_cutdate, P_EndOfDaySnapshotToDate : cmm_dend_cutdate, P_MinEndOfDayFromDateTime : cmm_min_eod_from_datetime, P_MaxEndOfDayToDateTime : cmm_max_eod_to_datetime, P_MinPriceQuotationDate : cmm_min_price_quotation_date, P_MaxPriceQuotationDate : cmm_max_price_quotation_date, P_MinSubstnPrcQtanDate : cmm_min_sub_price_quote_date, P_MaxSubstnPrcQtanDate : cmm_max_sub_price_quote_date, P_MinExchRateMttyDate : cmm_min_ex_rate_maturity_date, P_MaxExchRateMttyDate : cmm_max_ex_rate_maturity_date, P_MinFwdQuotationDate : cmm_min_fwd_quotation_date, P_MaxFwdQuotationDate : cmm_max_fwd_quotation_date
CREATE VIEW P_CMMDTYNEWACTPNLVALUE_SUM_2 AS
SELECT
source.PricingKey AS PricingKey,
source.Version AS Version,
source.PricingDocumentItem AS PricingDocumentItem,
cast (source.ConditionType as kscha) AS ConditionType,
source.SubConditionType AS SubConditionType,
cast (source.PriceSetValue as cds_price_set_value) AS PriceSetValue,
cast (source.PriceRemoveValue as cds_price_lift_value) AS PriceRemoveValue,
cast (source.OldQuantityPriceRemoveValue + source.OldQuantityPriceSetValue as cds_price_chg_value) AS PriceChangeValue,
cast (source.DocumentToStstcFXSetValue as cds_doc_to_stat_fx_set_value) AS DocumentToStstcFXSetValue,
cast (source.DocumentToStstcFXRemoveValue as cds_doc_to_stat_fx_lift_value) AS DocumentToStstcFXRemoveValue,
cast (source.OldQtyDocToStstcFXRemoveValue + source.OldQtyDocToStstcFXSetValue as cds_doc_to_stat_fx_chg_value) AS DocumentToStstcFXChangeValue,
source.MarketToStstcFXSetValue AS MarketToStstcFXSetValue,
source.MarketToStstcFXRemoveValue AS MarketToStstcFXRemoveValue,
source.OldQtyMktToStstcFXRemoveValue + source.OldQtyMktToStstcFXSetValue AS MarketToStstcFXChangeValue,
source.PriceSetMarketSpreadValue AS PriceSetMarketSpreadValue,
source.PriceRemoveMarketSpreadValue AS PriceRemoveMarketSpreadValue,
source.PriceSetDocumentSpreadValue AS PriceSetDocumentSpreadValue,
source.PriceRemoveDocumentSpreadValue AS PriceRemoveDocumentSpreadValue,
cast (source.PriceSetMktAdjmtValue as cds_mav_term_value) AS PriceSetMktAdjmtValue,
cast (source.PriceRemoveMktAdjmtValue as cds_mav_term_value) AS PriceRemoveMktAdjmtValue,
cast (source.OldQtyPriceRemoveMktAdjmtValue + source.OldQtyPriceSetMktAdjmtValue as cds_mav_term_value) AS PriceChangeMktAdjmtValue,
source.FxSetMktAdjmtValue AS FxSetMktAdjmtValue,
source.FxRemoveMktAdjmtValue AS FxRemoveMktAdjmtValue,
source.OldQtyFxsetMktAdjmtValue + source.OldQtyFxRemoveMktAdjmtValue AS FXChangeMktAdjmtValue,
cast ( cast( case source.PNLElementaryEventType when 'SET_PRICE' then source.PriceSetValue + source.PriceSetMarketSpreadValue + source.PriceSetDocumentSpreadValue when 'RMV_PRICE' then source.PriceRemoveValue + source.PriceRemoveMarketSpreadValue + source.PriceRemoveDocumentSpreadValue when 'CHG_PRICE' then source.OldQuantityPriceRemoveValue + source.OldQuantityPriceSetValue when 'SET_FX_MD' then source.MarketToStstcFXSetValue when 'SET_FX_DS' then source.DocumentToStstcFXSetValue when 'RMV_FX_MD' then source.MarketToStstcFXRemoveValue when 'RMV_FX_DS' then source.DocumentToStstcFXRemoveValue when 'CHG_FX_MD' then source.OldQtyMktToStstcFXRemoveValue + source.OldQtyMktToStstcFXSetValue when 'CHG_FX_DS' then source.OldQtyDocToStstcFXRemoveValue + source.OldQtyDocToStstcFXSetValue when 'SET_MAV' then PriceSetMktAdjmtValue when 'RMV_MAV' then PriceRemoveMktAdjmtValue when 'CHG_MAV' then source.OldQtyPriceRemoveMktAdjmtValue + source.OldQtyPriceSetMktAdjmtValue when 'SET_MAV_FX' then FxSetMktAdjmtValue when 'RMV_MAV_FX' then FxRemoveMktAdjmtValue when 'CHG_MAV_FX' then source.OldQtyFxsetMktAdjmtValue + source.OldQtyFxRemoveMktAdjmtValue else 0 + source.PriceSetValue + source.PriceRemoveValue + source.OldQuantityPriceRemoveValue + source.OldQuantityPriceSetValue + source.MarketToStstcFXSetValue + source.DocumentToStstcFXSetValue + source.MarketToStstcFXRemoveValue + source.DocumentToStstcFXRemoveValue + source.OldQtyMktToStstcFXRemoveValue + source.OldQtyMktToStstcFXSetValue + source.OldQtyDocToStstcFXRemoveValue + source.OldQtyDocToStstcFXSetValue + source.PriceSetMktAdjmtValue + source.PriceRemoveMktAdjmtValue + source.OldQtyPriceRemoveMktAdjmtValue + source.OldQtyPriceSetMktAdjmtValue + source.FxSetMktAdjmtValue + source.FxRemoveMktAdjmtValue + source.OldQtyFxsetMktAdjmtValue + source.OldQtyFxRemoveMktAdjmtValue + source.PriceSetMarketSpreadValue + source.PriceRemoveMarketSpreadValue + source.PriceSetDocumentSpreadValue + source.PriceRemoveDocumentSpreadValue end as abap.curr(15,2) ) as cmm_cds_pnl_value ) as PnLValue AS curr152ascmm_cds_pnl_valueasPnLValue,
cast (source.MarketConditionTermRate as cds_market_termrate) AS MarketConditionTermRate,
cast (source.ContrSpreadCndnTermRate as cds_contract_spread_rate) AS ContrSpreadCndnTermRate,
cast (source.FloatingMktSpreadCndnTermRate as cds_flt_market_spread_termrate) AS FloatingMktSpreadCndnTermRate,
cast (source.FixedMktSpreadCndnTermRate as cds_fix_market_spread_termrate) AS FixedMktSpreadCndnTermRate,
cast (source.SpreadCurrency as cmm_spread_currency) AS SpreadCurrency,
cast (source.MktDocToStstcExchRate as cds_mkt_doc_to_stat_exchrate) AS MktDocToStstcExchRate,
cast (source.MktMarketToDocExchRate as cds_mkt_mark_to_doc_exchrate) AS MktMarketToDocExchRate,
source.MarketAdjustmentValueRate AS MarketAdjustmentValueRate,
cast (source.MarketAdjustmentValueCurrency as cmm_mkt_adjustmentvalue_crcy) AS MarketAdjustmentValueCurrency,
source.PNLEventGroup AS PNLEventGroup,
cast ( source.ComparativeEvaluationDate as cds_evaluation_date_compar) AS ComparativeEvaluationDate,
cast (source.ContractConditionType as cds_ctr_condition_type) AS ContractConditionType,
source.ContrCmmdtyQtyInTermUnit AS ContrCmmdtyQtyInTermUnit,
source.ComparContrCmmdtyQtyInTrmUnit AS ComparContrCmmdtyQtyInTrmUnit,
cast (source.ContractMktToDocExchRate as cds_ctr_mark_to_doc_exchrate) AS ContractMktToDocExchRate,
cast (source.ComparContrMktToDocExchRate as cds_comp_ctr_mark_to_doc_rate) AS ComparContrMktToDocExchRate,
cast (source.ContrDocToStstcExchRate as cds_ctr_doc_to_stat_exchrate) AS ContrDocToStstcExchRate,
cast (source.ComparContrDocToStstcExchRate as cds_comp_ctr_doc_to_stat_rate) AS ComparContrDocToStstcExchRate,
cast (source.ContrMarketToStstcExchRate as cds_comp_ctr_doc_to_stat_rate) AS ContrMarketToStstcExchRate,
cast (source.MktMarketToStstcExchRate as cds_mkt_mkt_to_stat_exchrate) AS MktMarketToStstcExchRate,
source.MktAdjmtValueCndnTermValue AS MktAdjmtValueCndnTermValue,
source.ComparMktAdjmtValCndnTermValue AS ComparMktAdjmtValCndnTermValue,
source.ContrCndnTrmRateIsFxd AS ContrCndnTrmRateIsFxd,
source.ComparativeCndnTrmRateIsFixed AS ComparativeCndnTrmRateIsFixed,
source.ContrTrmExchRateIsFxd AS ContrTrmExchRateIsFxd,
source.ComparCndnTrmExchrateIsFxd AS ComparCndnTrmExchrateIsFxd,
source.MTMDataSourceType AS MTMDataSourceType,
source.ValidityStartDate AS ValidityStartDate,
source.ValidityStartDateTime AS ValidityStartDateTime,
source.ValidityEndDate AS ValidityEndDate,
source.ValidityEndDateTime AS ValidityEndDateTime,
source.SourceTransactionEventDateTime AS SourceTransactionEventDateTime,
source.SourceTransacEventEndDateTime AS SourceTransacEventEndDateTime,
source.EndOfDayBusinessEntityKey AS EndOfDayBusinessEntityKey,
source.CompanyCode AS CompanyCode,
source.SalesOrganization AS SalesOrganization,
source.DistributionChannel AS DistributionChannel,
source.Division AS Division,
source.Creditor AS Creditor,
source.SoldToParty AS SoldToParty,
source.Material AS Material,
source.PhysicalCommodity AS PhysicalCommodity,
source.Plant AS Plant,
source.StorageLocation AS StorageLocation,
source.Batch AS Batch,
source.IncotermsClassification AS IncotermsClassification,
source.IncotermsTransferLocation AS IncotermsTransferLocation,
source.ConditionApplication AS ConditionApplication,
source.SourceDocumentShortNumber AS SourceDocumentShortNumber,
source.SourceDocument AS SourceDocument,
cast (source.SourceDocumentItem as cds_source_document_item) AS SourceDocumentItem,
source.SourceDocumentBusObjType AS SourceDocumentBusObjType,
source.OrignRefDocumentShortNumber AS OrignRefDocumentShortNumber,
source.OriginReferenceDocument AS OriginReferenceDocument,
source.OriginReferenceDocumentItem AS OriginReferenceDocumentItem,
source.OriginReferenceDocBusObjType AS OriginReferenceDocBusObjType,
source.ReferenceDocument AS ReferenceDocument,
source.ReferenceDocumentItem AS ReferenceDocumentItem,
source.ReferenceDocBusObjType AS ReferenceDocBusObjType,
source.DeliveryDate AS DeliveryDate,
source.ExpectedPaymentDate AS ExpectedPaymentDate,
source.StatisticsCurrency AS StatisticsCurrency,
source.DocumentCurrency AS DocumentCurrency,
source.ProfitCenter AS ProfitCenter,
source.BusinessArea AS BusinessArea,
source.PurchasingOrganization AS PurchasingOrganization,
source.MaterialGroup AS MaterialGroup,
source.IsIntercompanyTransfer AS IsIntercompanyTransfer,
source.ConditionCalculationType AS ConditionCalculationType,
source.ConditionRate AS ConditionRate,
source.ConditionCurrency AS ConditionCurrency,
source.ConditionQuantity AS ConditionQuantity,
source.ConditionQuantityUnit AS ConditionQuantityUnit,
source.QuotationPriceType AS QuotationPriceType,
source.ConditionTermRate AS ConditionTermRate,
cast (source.ConditionTermRateCurrency as cmm_cond_term_rate_crcy) AS ConditionTermRateCurrency,
cast (source.ConditionTermRateQuantity as cmm_reporting_priceunit) AS ConditionTermRateQuantity,
cast (source.ConditionTermRateQuantityUnit as cds_priceuom) AS ConditionTermRateQuantityUnit,
source.ConditionTermValue AS ConditionTermValue,
source.ConditionTermValueCurrency AS ConditionTermValueCurrency,
source.ConditionTermName AS ConditionTermName,
source.ConditionTermStatus AS ConditionTermStatus,
source.RoundingDecimalPlaces AS RoundingDecimalPlaces,
source.ConditionTermRateIsRounded AS ConditionTermRateIsRounded,
source.ConditionTermRateNmrtr AS ConditionTermRateNmrtr,
source.ConditionTermRateDnmntr AS ConditionTermRateDnmntr,
source.ConditionTermFactor AS ConditionTermFactor,
source.ComparConditionTermFactor AS ComparConditionTermFactor,
source.ConditionTermExtensionUsage AS ConditionTermExtensionUsage,
source.MaturitySelectionType AS MaturitySelectionType,
cast (source.ExchRateMaturityDate as cmm_maturity_date) AS ExchRateMaturityDate,
source.FixedExchRateDate AS FixedExchRateDate,
source.QuotationPeriodReferenceDate AS QuotationPeriodReferenceDate,
source.QuotationKeyType AS QuotationKeyType,
source.QuotationDateList AS QuotationDateList,
source.QuotationPeriodStartDate AS QuotationPeriodStartDate,
source.QuotationPeriodEndDate AS QuotationPeriodEndDate,
cast (source.ComparativeMarketDCS as cds_comp_mkt_dcsid) AS MarketDCS,
cast (source.ComparMktMarketIdentifierCode as cds_comp_mkt_mic) AS MktMarketIdentifierCode,
cast (source.ComparMktMaturityKeyDate as cds_comp_mkt_keydate) AS ComparMktMaturityKeyDate,
cast (source.ComparMktDrvtvContrCode as cds_comp_mkt_contract_code) AS ComparMktDrvtvContrCode,
cast (source.ComparMarketBasisID as cds_comp_mkt_basis_id) AS MarketBasisID,
cast (source.ComparMarketBasisType as cds_comp_mkt_basis_type) AS ComparMarketBasisType,
cast (source.ComparMktQuotationPriceType as cds_comp_mkt_quotation_prctype) AS ComparMktQuotationPriceType,
cast (source.ContractDCS as cds_ctr_dcsid) AS ContractDCS,
cast (source.ContractMarketIdentifierCode as cds_ctr_mic) AS ContractMarketIdentifierCode,
cast (source.ContractMaturityKeydate as cds_ctr_keydate) AS ContractMaturityKeyDate,
cast (source.ContrDrvtvContrMaturityCode as cds_ctr_contract_code) AS ContrDrvtvContrMaturityCode,
cast (source.ContractBasisID as cds_ctr_basis_id) AS ContractBasisID,
cast (source.ContractBasisType as cds_ctr_basis_type) AS ContractBasisType,
cast (source.ContractQuotationPriceType as cds_ctr_quotation_pricetype) AS ContractQuotationPriceType,
source.QuotationGroup AS QuotationGroup,
source.QuotationGroupCalculationRule AS QuotationGroupCalculationRule,
cast (source.ConditionTermRateFixation as cds_fixation_id) AS ConditionTermRateFixation,
source.PricingStatus AS PricingStatus,
source.CndnTermRateFixationDate AS CndnTermRateFixationDate,
source.CndnTermRateFixationTime AS CndnTermRateFixationTime,
source.CndnTermExchRateFixationDate AS CndnTermExchRateFixationDate,
source.CndnTermExchRateFixationTime AS CndnTermExchRateFixationTime,
cast (source.CommodityQuantity as cmm_mtm_quan_comm) AS CommodityQuantity,
source.CommodityUnit AS CommodityUnit,
source.QuantitySign AS QuantitySign,
source.MTMConditionGroupCategory AS MTMConditionGroupCategory,
source.MTMConditionGroup AS MTMConditionGroup,
source.MTMCalculationGroup AS MTMCalculationGroup,
source.MTMAdjustmentType AS MTMAdjustmentType,
source.MTMCalcGrpMarketPriceCondition AS MTMCalcGrpMarketPriceCondition,
source.ConditionTermRateIsFixed AS ConditionTermRateIsFixed,
source.ConditionTermExchRateIsFixed AS ConditionTermExchRateIsFixed,
source.PriceIsRealized AS PriceIsRealized,
cast (source.PNLEventType as cmm_event) AS PnLEventType,
cast (source.PNLElementaryEventType as cmm_effect) AS PnLElementaryEventType,
source.MTMDataSourceGroup AS MTMDataSourceGroup,
source.VersStockRecordUUID AS VersStockRecordUUID,
cast( source.HasError as cmm_error_occured) AS HasError,
cast( source.SystemMessageNumber as cds_systemmessagenumber) AS SystemMessageNumber,
source.ImplicitFixationIsRelevant AS ImplicitFixationIsRelevant,
source.ComparImplicitFixationIsRlvt AS ComparImplicitFixationIsRlvt,
source.CmmdtyPriceExpsrMassUnit AS CmmdtyPriceExpsrMassUnit,
source.CmmdtyPriceExpsrQtyInMassUnit AS CmmdtyPriceExpsrQtyInMassUnit,
source.CmmdtyPriceExpsrVolumeUnit AS CmmdtyPriceExpsrVolumeUnit,
source.CmmdtyPriceExpsrQtyInVolUnit AS CmmdtyPriceExpsrQtyInVolUnit,
source.CndnToStstcExchangeRateType AS CndnToStstcExchangeRateType,
source.ConditionToDocExchangeRateType AS ConditionToDocExchangeRateType,
source.DocToStstcExchangeRateType AS DocToStstcExchangeRateType,
source.MarketToTermExchangeRateType AS MarketToTermExchangeRateType,
source.PriceSettingMethod AS PriceSettingMethod,
source.PriceSettingMethodStatus AS PriceSettingMethodStatus,
source.ValidToDateTime AS ValidToDateTime,
source.PricingProcedure AS PricingProcedure,
source.PricingConditionTerm AS PricingConditionTerm,
source.CmmdtyRootDocExternalNumber AS CmmdtyRootDocExternalNumber,
source.CmmdtyDocumentExternalNumber AS CmmdtyDocumentExternalNumber
FROM P_CMMDTYNEWACTPNL_CALC_2
;