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 I_MKT_MarketingScoreCube.
-- 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: IMKTSCRC
-- Parameters: P_StartDate : cuan_start_date, P_EndDate : cuan_end_date
CREATE VIEW I_MKT_MarketingScoreCube AS
SELECT
cast(I_MKT_IntactnCntctScoreVal.MarketingScoreUUID as cuan_cds_pm_score_uuid) AS MarketingScoreUUID,
I_MKT_IntactnCntctScoreVal.MktgScoreVersion AS MktgScoreVersion,
I_MKT_IntactnCntctScoreVal.InteractionContact AS InteractionContact,
I_MKT_IntactnCntctScoreVal.MarketingScoreValue AS SumMarketingScoreValue,
cast (1 as cuan_cds_pm_number_of_score) AS NumberOfScores,
I_MKT_IntactnCntctScoreVal.MktgScoreValueCategory AS MktgScoreValueCategory,
I_MKT_IntactnCntctScoreVal.MktgScoreVersionDate AS MktgScoreVersionDate,
cast ( I_MKT_IntactnCntctScoreVal._MKT_CalendarDate.CalendarYear as cuan_year_cds ) AS CalendarYear,
I_MKT_IntactnCntctScoreVal._MKT_CalendarDate.YearQuarter AS YearQuarter,
I_MKT_IntactnCntctScoreVal._MKT_CalendarDate.YearMonth AS YearMonth,
I_MKT_IntactnCntctScoreVal._MKT_CalendarDate.YearWeek AS YearWeek,
I_MKT_IntactnCntctScoreVal.MktgScoreIsCurrentVersion AS MktgScoreIsCurrentVersion,
I_MKT_IntactnCntctScoreVal.PredictiveScenario AS PredictiveScenario,
I_MKT_IntactnCntctScoreVal.PredictiveModelUUID AS PredictiveModelUUID,
I_MKT_IntactnCntctScoreVal._MKT_MarketingScoreModel.PredictiveModel AS PredictiveModel,
cast( I_MKT_IntactnCntctScoreVal._Mkt_Contact.FullName as cuan_pm_contact_name preserving type) AS FullName,
InteractionContactAge,
cast( case when ( InteractionContactAge > 0 and InteractionContactAge < 13 ) then cast ( 1 as abap.char( 10 ) ) when ( InteractionContactAge >= 13 and InteractionContactAge <= 17 ) then cast ( 2 as abap.char( 10 ) ) when ( InteractionContactAge >= 18 and InteractionContactAge <= 24 ) then cast ( 3 as abap.char( 10 ) ) when ( InteractionContactAge >= 25 and InteractionContactAge <= 34 ) then cast ( 4 as abap.char( 10 ) ) when ( InteractionContactAge >= 35 and InteractionContactAge <= 44 ) then cast ( 5 as abap.char( 10 ) ) when ( InteractionContactAge >= 45 and InteractionContactAge <= 54 ) then cast ( 6 as abap.char( 10 ) ) when ( InteractionContactAge >= 55 and InteractionContactAge <= 64 ) then cast ( 7 as abap.char( 10 ) ) when ( InteractionContactAge > 65 ) then cast ( 8 as abap.char( 10 ) ) else cast (0 as abap.char( 10 ) ) end as cuan_cds_age_range ) as AgeRange AS char10endascuan_cds_age_rangeasAgeRange,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.Country AS Country,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.AddressRegion AS AddressRegion,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.GenderCode AS GenderCode,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_CountryMarket.Market AS Market,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.Industry AS Industry,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.Function AS InteractionContactFunction,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.Department AS Department,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.ValidationStatus AS ValidationStatus,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.EmailAddress AS EmailAddress,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.CompanyName AS CompanyName,
cast (I_MKT_IntactnCntctScoreVal._Mkt_Contact.IsConsumer as cuan_isconsumer preserving type) AS IsConsumer,
cast (I_MKT_IntactnCntctScoreVal._Mkt_Contact.IsContactPerson as cuan_iscontact_person preserving type) AS IsContactPerson,
I_MKT_IntactnCntctScoreVal._Mkt_Contact.InteractionContactType AS InteractionContactType,
I_MKT_IntactnCntctScoreVal.InteractionContactOrigin AS InteractionContactOrigin,
cast(I_MKT_IntactnCntctScoreVal.CorporateAccountUUID as cuan_cds_account preserving type) AS CorporateAccountUUID,
cast(I_MKT_IntactnCntctScoreVal._MKT_CorporateAccount.FullName as cuan_api_corp_acct_name preserving type) AS CorporateAccountName,
I_MKT_IntactnCntctScoreVal._MKT_CorporateAccount.CorpAcctIsRlvtForAcctBasedMktg AS CorpAcctIsRlvtForAcctBasedMktg,
I_MKT_IntactnCntctScoreVal._MKT_MktgScoreValueCategory AS _MKT_MktgScoreValueCategory,
I_MKT_IntactnCntctScoreVal._MKT_CalendarDate AS _MKT_CalendarDate,
I_MKT_IntactnCntctScoreVal._MKT_MarketingScore AS _MKT_MarketingScore,
I_MKT_IntactnCntctScoreVal._MKT_MarketingScore.MarketingArea AS MarketingArea,
I_MKT_IntactnCntctScoreVal._MKT_MarketingScore.PredictiveScenarioType AS PredictiveScenarioType,
I_MKT_IntactnCntctScoreVal._MKT_MarketingScoreModel AS _MKT_MarketingScoreModel,
I_MKT_IntactnCntctScoreVal._MKT_IntactnCntctMktgArea AS _MKT_IntactnCntctMktgArea,
I_MKT_IntactnCntctScoreVal._Mkt_Contact AS _Mkt_Contact,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Country AS _MKT_Country,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Region AS _MKT_Region,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Gender AS _MKT_Gender,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Industry AS _MKT_Industry,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Function AS _MKT_Function,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_Department AS _MKT_Department,
I_MKT_IntactnCntctScoreVal._Mkt_Contact._MKT_ValidationStatus AS _MKT_ValidationStatus,
I_MKT_IntactnCntctScoreVal._MKT_CorporateAccount AS _MKT_CorporateAccount
FROM I_MKT_IntactnCntctScoreVal
LEFT OUTER JOIN I_MKT_MktgScoreModelVH AS _MKT_ModelScenVH ON PredictiveModelUUID = _MKT_ModelScenVH.PredictiveModelUUID AND predictivemodel = _MKT_ModelScenVH.PredictiveModel -- association [0..1]
LEFT OUTER JOIN I_MKT_CorpAcctCntctsVH AS _MKT_CorpAcctCntctsVH ON CorporateAccountUUID = _MKT_CorpAcctCntctsVH.CorporateAccountUUID -- association [0..1]
LEFT OUTER JOIN I_MKT_Market AS _MKT_Market ON market = _MKT_Market.Market -- association [0..1]
LEFT OUTER JOIN I_Mkt_IcAgeRange AS _Mkt_IcAgeRange ON AgeRange = _Mkt_IcAgeRange.AgeRange -- association [0..1]
LEFT OUTER JOIN E_MKT_CONTACT AS _ExtensionInteractionContact ON InteractionContact = _ExtensionInteractionContact.InteractionContact -- association [1..1]
LEFT OUTER JOIN E_MKT_PERSON AS _ExtensionPerson ON InteractionContact = _ExtensionPerson.Person -- association [1..1]
LEFT OUTER JOIN E_MKT_COMPANY AS _ExtensionCompany ON InteractionContact = _ExtensionCompany.Company -- association [1..1]
;