Вы находитесь на странице: 1из 14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

GettingStarted Newsletters

LogOn

Hi,Guest

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

ABAPDevelopment

ABAPNewsfor7.40,SP08ABAPCoreData
Services(CDS)
PostedbyHorstKellerinABAPDevelopmentonOct10,201411:05:43AM
Share

Tweet

14

Like

Recap

WithABAP7.40,SP05theABAPCoreDataServices,shortABAPCDS,wereintroduced.TheABAPCoreData
ServicesimplementthegeneralCDSconceptofSAP(thatisalsoavailableforHANAasHANACDS)forASABAP.
TheyuseaDDLtodefineCDSviewsthatimplementasemanticdatamodelintheABAPDictionary.

ThepowerofABAPCDSis,thatitisopen,meaningdatabaseindependent(withsomeexceptionsifthedatabasesdo
notyetcoverallthefunctionalitiesase.g.viewswithparameters).YoucanusetheDDLofABAPCDSinEclipse
basedADTtocreaterathercomplexviewsthatexceedthecapabilitiesoftheclassicaldatabaseviewscreatedin
SE11byfar.Technically,fromthesourcecodeofaCDSview,aclassicaldatabaseviewisgenerated.Wecallthisthe
CDSdatabaseview.YoucandisplaythefieldsofthisviewinSE11butnotchangethem.Especially,youcanseethe
realdatabaseobjecttheSQLviewthatiscreatedfromtheviewdefinitiononthedatabaseinSE11.ButthisCDS
databaseviewservesmainlytheinternaltechnicalpurposetorealizetheviewinthedictionary.Youcan,butyou
shouldnotuseitinABAPprograms.Instead,youworkwiththeCDSentitiy,whosenameisdefinedbehindDEFINE
VIEW.OnlytheentitycarriesthefullcapabilitiesoftheCDSview,likesemanticalinformation,clienthandling,
connectiontoauthoritychecks(planned),andsoon.YoucanusetheCDSentitybehindTYPEfordeclaringwork
areasandinOpenSQLinABAPprograms.

Youusetheseviewsforthefamouscodepushdowninordertoputmoreanalyticworktothedatabase.Ifthe
functionalityofaviewisonlyneededonce,ofcourseyoucanstilluseJoins,SQLexpressions,subqueries,...inOpen
SQLforthiscodepushdown.Butifyouwanttoreuseaview,needsemanticalortechnicalcapabilitiesofCDSthat
exceedthoseofOpenSQL(butwetrytokeepthetechnicalcapabilitiesonthesamelevel,e.g.,CDSknowsUNION,
OpenSQLwillknowUNIONwithSP12)oryoujustwanttopushdownthefulldatamodeltothedatabase,youuse
CDS.AndinfactI'veseenvery,veryextensivesophisticatedviewsalreadynow(ohboy...).

ButI'masimplemind,notabusinessmodellingguru.Inordertounderstandthebasics,Iworkwithsimpleexamples.
Justtogiveyoutwoofthose:

@AbapCatalog.sqlViewName:'DEMO_CDS_JOIN'
defineviewdemo_cds_scarr_spfli
(id,carrier,flight,departure,destination)
asselectfromspfli
joinscarronscarr.carrid=spfli.carrid
{keyspfli.carrid,
keyscarr.carrname,
keyspfli.connid,
spfli.cityfrom,
spfli.cityto}

ThisisasimplejoinasyoucouldalsodefineitinclassicalSE11.ThenameoftheCDSentityis
demo_cds_scarr_spfliandthenameofthegeneratedCDSdatabaseviewisDEMO_CDS_JOIN.Onedifferencetoa
classicalviewisthefact,thataCDSentitythatusesclientdependentdatasourcesisclientdependentbydefaultbut
neverhasaclientfield.Theclienthandlingisdoneimplicitlywithoutshiningthroughhere.

Anotherview,thatdoesexactlythesameastheaboveonebutshowsanewkindofmodellingcapability:
@AbapCatalog.sqlViewName:'DEMO_CDS_ASSOC'
defineviewdemo_cds_association
(id,carrier,flight,departure,destination)
asselectfromspfli
association[1..1]toscarrasspfli_scarr
on$projection.carrid=spfli_scarr.carrid
{keyspfli.carrid,
keyspfli_scarr.carrname,

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

1/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

keyspfli.connid,
spfli.cityfrom,
spfli.cityto}

Thejoinisreplacedbyanassociation,whichisamoreelegantwaytocodereusablejoins.Associationscanbe
adressedinsidetheviewusingpathexpressions(spfli_scarr.carrnameisthemostsimpleone)andcanbe
published(notshownhere)forusageinotherviewsandinOpenSQL(plannedforSP12).

InanABAPprogramyoucanreadtheviewswithOpenSQL:

SELECT*
FROMdemo_cds_association
ORDERBYid,carrier,flight
INTOTABLE@DATA(result1).
SELECT*
FROMdemo_cds_scarr_spfli
ORDERBYid,carrier,flight
INTOTABLE@DATA(result2).
ASSERTresult1=result2.

Tofindoutmore,seetheCDSdocumentation(itcontainsanauthorizationconceptalready,butthereleaseofthatwas
postponedtoSP12).

Afterthisrecap,nowthemostimportant

NewsforCDSwith7.40,SP08

Besidesmanysmallerenhancements,themostimportantnewsare:

Manynewbuiltinfunctions

BesidesthefunctionalreadyintroducedwithSP05,youcanusestandardfunctionsasCOALESCE,CONCAT,
REPLACE,ABS,DIV,DIVISION,FLOOR,MODandROUNDnowandasinOpenSQLthesearchedCASEwas
introduced.

SpecialfunctionsCURRENCY_CONVERSION,UNIT_CONVERSIONundDECIMAL_SHIFTallowyoutodealwith
dataofthe(in)famousSAPspecificdictionarytypesCURR,CUKY,QUANandUNIT.

@AbapCatalog.sqlViewName:'DEMO_CDS_CRRCNV'
defineviewdemo_cds_currency_conversion
withparametersto_currency:abap.cuky(5),
exc_date:abap.dats
asselectfromdemo_prices
{id,
currency_conversion(amount=>amount,
source_currency=>currency,
round=>'X',
target_currency=>:to_currency,
exchange_rate_date=>:exc_date,
error_handling=>'SET_TO_NULL')asamount,
:to_currencyascurrency}

Parameterviews

Ondatabasesthatsupportit(notalluptonow,butSAPHANAdoes)youcanaddimportingparameterstoaviewthat
canbeusedintheSELECTstatementoftheviewandthatcanbesuppliedwhenusingtheviewinOpenSQL.

Exampleforsuchaview:

@AbapCatalog.sqlViewName:'DEMO_CDS_PARA'
defineviewdemo_cds_parameters
withparametersp_distance_l:S_DISTANCE,
p_distance_o:S_DISTANCE,
p_unit:S_DISTID
asselectfromspfli
{keycarrid,
keyconnid,
cityfrom,
cityto,
distance,
distid}
wheredistid=:p_unitand
distancebetween:p_distance_l
and:p_distance_o

UsageinOpenSQL:

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

2/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

IFcl_abap_dbfeatures=>use_features(
EXPORTING
requested_features=
VALUE#((cl_abap_dbfeatures=>views_with_parameters))).
SELECT*
FROMdemo_cds_parameters(p_distance_l=@from_distance,
p_distance_o=@to_distance,
p_unit=@unit)
ORDERBYcarrid,connid
INTOTABLE@DATA(result).
cl_demo_output=>display(result).
ELSE.
cl_demo_output=>display(
'Databasesystemdoesnotsupportviewswithparameters').
ENDIF.

Extendingviews

ClassicalviewsdeliveredbySAPorpartnerscanbeextendedwiththewellknownclasicalappendviews.Inorderto
achievethesameforCDSviewsanewDDLstatementisintroduced:

@AbapCatalog.sqlViewAppendName:'DEMO_CDS_EXTENS'
extendviewdemo_cds_original_viewwithdemo_cds_view_extension
{spfli.distance,
spfli.distidasunit}

Itaddsnewfieldstotheexistingviewfields.Technically,aclassicalappendviewitsnamedefinedbehindthe
annotation@AbapCatalog.sqlViewAppendNameisgeneratedintheABAPDictionaryforthatpurpose.

8958Views

AverageUserRating
(8ratings)

Share

Tweet

14

Like

35Comments
PaulHardyOct25,20147:15AM

Inregardtoparametertransactions,upuntilnowifwedefineaviewinSE11whichjoins,say,VBAK
andVBAPandcalltheviewZV_SALES_ORDERS.

Wecouldthenwritethefollowing:

SELECT*
FROMzv_sales_orders
INTOlt_sales_orders
WHEREwerksEQp_werks
ANDerdatINs_erdat.

ItakeityoucannotdothiswithaCDSview?

Isthisbecauseitisnota"real"SE11view?

Youhavetodothetrickwiththeparametersinstead?

CheersyCheers

Paul
Like(0)

PeterInotaiOct27,20141:45PM(inresponsetoPaulHardy)

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

3/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
Youcanpassparameterswithoutanyproblemfortheselectstatement.
Thisisanexamplein7.40SP4(soverylimitedfunctionality):
CDSdefinitioninEclipse:

ActuallyitcanbedisplayedinSE11:

AndyoucanwriteSELECTwithWHEREcondition:

Peter
Like(0)

JacquesNomssiOct27,20142:22PM(inresponsetoPeterInotai)

itisrecommendedtoonlyusetheCDSentityZPI_TESTinOpenSQLstatements
(insteadoftheCDSdatabaseviewZPI_TEST_CDS).
Inyoursimplecase,theonlydifferenceisthattheCDSentitydoesnothavea
MANDTfieldyoucanselectwithWHEREconditionsdirectlyontheCDSentity
ZPI_TEST.

regards,

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

4/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
JacquesNomssi
Like(0)

PeterInotaiOct27,20142:28PM(inresponsetoJacquesNomssi)

HiJacques,
Thanksfortheinfo.
Doyoumean"SELECT*FROMzpi_test...."statement?
Inoursystem(onlySP4)itdoesn'tseemtowork.
Thanks,
Peter
Like(0)

JacquesNomssiOct27,20142:40PM(inresponsetoPeterInotai)

HiPeter,

IamonSP05andthefollowingworks:

Definition
@AbapCatalog.sqlViewName:'Y_CDS_PO_DATA'
defineviewy_po_view
asselectfromekkoaspo
innerjoinekpoasitem
onpo.ebeln=item.ebeln
leftouterjoinlfa1asvendor
onpo.lifnr=vendor.lifnr
{keypo.ebelnasebeln,
keyitem.ebelpasebelp,
po.bukrsasbukrs,
po.bstypasbstyp,
vendor.name1asvendor_name
}

Comsumption
REPORTy_cds_consumption.
DATAgs_selTYPEekko.
SELECTOPTIONSso_bstypFORgs_selbstyp.

DATAlt_resultTYPESTANDARDTABLEOFy_po_viewWITH
NONUNIQUEkeyebeln.

SELECT*UPTO100ROWS
FROMy_po_view
INTOTABLE@lt_result
WHEREbstypin@so_bstyp.

cl_demo_output=>display_data(lt_result).

DATAlt_dataTYPESTANDARDTABLEOFy_cds_po_data
WITHNONUNIQUEkeyebeln.

SELECT*UPTO100ROWS
FROMY_CDS_PO_DATA
INTOTABLE@lt_data
WHEREbstypin@so_bstyp.

cl_demo_output=>display_data(lt_data).

bestregards,

JNN
Like(1)

PeterInotaiOct27,20142:48PM(inresponsetoJacques
Nomssi)

HiJNN,
Thanksalotforthedetailedanswer.
ProbabletestinginSP04isnotagoodidea,Ishould
somehowgettoSP05orevenbettertoSP08,
Cheers,
Peter
Like(0)

HorstKellerNov13,20147:00PM(inresponseto
PeterInotai)

CDSforABAPwasreleasedwithSP05.
Beforeitwasanundocumentedprerelease
forSAPinternaluseonly.Andyes,noaccess
totheCDSentitiesbeforeSP05.AsofSP05
thisaccessispossibleandthegenerated
databaseviewsvisibleinSE11areregarded

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

5/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
asinternaltechnicalnecessitiesbutshouldnt
beusedinOpenSQL.

AmixingofCDSentitieswithclassicalSE11
databasesandviewsinoneOpenSQL
statementwillbepossibleinanupcomingSP
andtheusageoftheCDSDBviewsinOpen
SQLwillbedeclaredasobsolete.

Plsseethecomprehensiveexplanationhere:

http://help.sap.com/abapdocu_740/en/index.htm?
file=abenddic_cds_views.htm
Like(2)

PeterInotaiNov14,20149:12AM(in
responsetoHorstKeller)

HiHorst,
Thanksfortheinfo.
Peter
Like(0)

HorstKellerNov13,20146:37PM(inresponsetoPaulHardy)

Ivechosenasimpleexample.

YoucanusetheparametersatmanyoperandpositionsinCDSviewdefinitions,notonly
behindWHERE.E.g.,youcanpassparameterstofunctionsoftheviewinordertocontrol
theirbehavior.

Infact,Iveshownthatinthecurrencyconversionexampleabove...
Like(0)

PaulHardyOct25,20147:47AM

AndwhilstIamaskingquestions.....

ACDSviewiswrittenin"DDL"(datadefintionlanaguage)

whilstastoredprocedureiswritteninSQLScript?

HaveIgotthatcorrect?

Theylookabitthesame,butIpresumethatSQLSCripthasamuchgreaterdepthoffunctionality
availablethansomethingwritteninDDL?

CheersyCheers

Paul
Like(0)

JacquesNomssiOct26,201412:58AM(inresponsetoPaulHardy)

HelloPaul,

1)youcanrestricttheselectionfromaCDSviewwithadditionalconditionsintheWHERE
conditions(ItestedthisonSP05).

2)youshouldbeabletousebothparametersandWHEREconditionsinaHANAsystem
withSP08(Ihavenottestedthis).

3)CDSisdatabaseindepedent.Myunderstandingisthatyoushouldbeabletodo:
DDL(DataDefinition)
QL(Query)
DML(DataManipulation)
DCL(Authorization)
onanysupporteddatabaseinthesameway,withtheaimistoeventuallycovertheSQL92
functionality.(cf.opensapcourseABAPonHANAslides)

4)AMDBisstoredinthelanguageofthedatabase.CurrentlyonlyHANADBissupported,
i.e.thelanguageisSQLScriptortheSAPinternalLlanguage.

SoinmyviewitisnativeSQL,butwithamuchbetterABAPintegration:
itisinyourtransportrequest
youjustcallanABAPmethod(withVALUEparameters)

SpecialDisclaimer:IamnotHorstKeller,soImightbewrongonallcounts.

regards,

JNN
Like(1)

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

6/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
PaulHardyOct26,20143:33AM(inresponsetoJacquesNomssi)

Firstoff,thanksverymuchforresponding.

IhadhopedthatyoucoulduseWHEREconditionswhenreferringtoaCDSview.
MyundertandingisthataCDSviewhastwofacesthenamethatappearsin
SE11whichistheSQLview,andthe"entity"namewhichistheoneyouare
supposedtouseinyourSELECTstatementsinyourABAPprograms.

ItwouldseemlogicalthatwhenreferringtotheSQLviewyoucoulduseextra
WHEREcoditions,butinalltheexamplesIhavethusfarseen,whenreferringto
the"entity"inanABAPSELECTnoparametersareevensupplied.

IfyoucaninfactuseWHEREconditionswhenreferringtothe"entity"(soundslike
analienmonsters)oramixtureofWHEREconditionsandparameters,thenIam
findingitdifficulttoworkoutthereasonfortheparametersinthefirstplacewhy
notjustusemoreWHEREconditions?Couldthisbesomethingtowithreferringto
aCDSviewwithinastoredprocedureorsomething?Iamjustguessing.

InapresentationbyRichHeilmanfromSAPheseemdtoimplythattheCDSview
wastheDDLsubsetofSQLSCRIPT(whichmightexplainwhyyoucreatean
artifactcalleda"DDL"fromtheABAPinEclipsewhencreatingaCDSview)butI
mayhavetotallymisunderstood.Again,inalltheexamplesIhaveseenofCDS
viewstheylooklikeonebigSQLstatement,albeitwithtonsoffancyfeatures.And
HorstseemstoimplythatonedaythenewextendedOpenSQLcapabilitiesin
ABAPwillcatchupwithwatispossibleinaCDSview,whichwouldseemtomake
itredundantinthelongterm.Again,Ihaveprobablygotallthiswrong.

Now,movingontoADMP,IthoughttheonlylanguagepossiblewasSQLSCRIPT
atthistimebutyoumentionalsotheinternalSAP"L"language.

OnreadingthisIthought"whattheL?"

IsthisjustalanguageSAPuseinhouse?
Like(0)

HorstKellerNov14,20149:19AM(inresponsetoPaulHardy)

HiPaul,

MostofyourquestionsareansweredbyJNNandPeter.

Tosummarize:

CDSviewsareentitiesoftheABAPCDSintheABAPDictionarythataremuchmore
advancedthantheclassicalSE11views.E.g.,youcaninfluenceCDSviewswith
parametersthatcanbeusedatdifferentpositionsoftheDCL.AsforclassicalSE11
views,foraCDSviewaplatformdependentruntimeobjectisgeneratedatthe
databasethatyoucanexamineinSE11.Whenaccessinga(CDS)viewwithOpen
SQL,thedatabaseinterfaceaccessesthisruntimeobject.AsalwaysST05canbe
usedtoanalyzesuchaccessesfurther.ACDSviewiscreatedwithasourcecode
basededitorinEclipseusingaDDL(thathasnothingtodowithSQLScript).For
technicalreasons,fromthesourcecodeaclassicalDBviewisgeneratedinSE11that
youcanaccesslikeanyclassicalview,butyoushouldn't.InsteadthesocalledCDS
entityshouldbeaccessedbecauseitcarriesmoremeaningthanthemeretechnical
DBviewandinvolvesnewkindofclienthandling.Inanupcomingreleasethedirect
accestotheDBviewofaCDSviewwillbedeclaredasobsolet.
YouuseCDStomodellargepartsofyourapplicationintheDictionaryandusesimple
OpenSQLSELECTsinABAPforreadaccessinsteadofhavingtocreatethe
respectivejoinsandsubqueriesineachABAPprogramoverandoveragain.Oneday
OpenSQLmighthavethesamepowerlikeCDSbutitdoesn'tmeanthatthoseare
redundant.AlreadybeforeCDSyouhadthechoicebetweencreatingareusableview
inSE11orprogrammingajoininOpenSQL.Asaruleofthumbyoucreatedaviewifit
isusedinmorethanoneprogramandprogrammedajoinwhenyouneededitonly
once.ThatisverysimilarforCDS,butwithmuchmorepossibilitiesformodeling
semanticallyrichmodelsforreuseinABAPprograms.
CDSismainlyopen.ItisnotrestrictedtoHANA(butperformancecanbedifferent!).
AMDPissimplyaframeworkthatfacilitatesthehandlingofNativeDBprocedures.Up
tonowonlyDBproceduresofHANAwritteninSQLScriptaresupported(thelowlevel
languageLisforSAPinternaluseonlypartsofSQLScriptareimplementedinL).
Otherplatformsmightfollow.
HavealookatmyFromADBCtoAMDPexample,thatshowstheevolution.From
generatingaDBprocedureyourselfwihADBCovercallingitwithCALLDATABASE
PROCEDUREwefinallycangenerateandcallitpurelyinABAP.Ofcourse,the
functionalityofthatexampleisnonsense,becauseyoucandothesamewiththesame
orevenbetterperformanceinOpenSQL.Anotherexampleismorerealisticin
showinghowaSQLScriptcurrencyconversionfunctionisusedonthedatabase
insteadofcallinganABAPfunctionmodule.Itisclear,thatworkingdirectlyonthe
databaseshouldperformbetterhere.
Best

Horst
Like(4)

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

7/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
JacquesNomssiNov14,20143:51PM(inresponsetoHorstKeller)

thankstoHorstKeller,documentalistextraordinaire!

andsomequestions

1)WillCDSviewwithparameterbesupportedonallcertifiedDBsoon?
Imean,checkingtheunderlyingdatabaseforavailablefeaturesisidiosyncraticfor
customdevelopments.

2)ShouldIexpectachangeinperformancewhilefetchingdatafromabaseCDS
entitywhenI
a)consumethebaseCDSentityinanABAPSELECTstatementwithWHERE
clause,comparedtowhenI
b)extendtheCDSentitywithaWHERErestrictionandthenconsumethe
extendedCDSentitywithoutWHEREclause.

bestregards,

JNN
Like(1)

HorstKellerNov17,20144:18PM(inresponsetoJacquesNomssi)

1)Thedatabasecolleaguesareworkingonitanditseemsthatwiththe
nextmajorrelease7.40,SP12alldatabasesystemswillsupport
parameterviews.

2)Idonotexpectdifferentperformance.Iexpectthedatabasesystemsdo
carryoutthesameSELECTinbothcases.
Like(0)

PaulHardyOct28,20141:21PM

OK,fromtherepliesthatJacquesandPeterhavebeenkindenoughtoshareitlookslikeinthe
higherlevelsof740wecanaddressthe"entity"(viewname)withnotonlyvariablesintheWHERE
parameter,butinSP08viewparametersaswell.

ThequestionIstillhaveiswhydoweneedboth?SAPwouldnothaveintroducedparameterstoCDS
viewsasajoke(Ihope)sotheremustbesomesortofusecaseforthemwhichcannotbeacheived
bythenormalWHEREparametersinABAP.

MyguessremainsthatthisissomethingtofowithusingaCDSviewinastoredprocedure.

AlsoIamstillwonderingaboutthis"L"language.....
Like(0)

PeterInotaiOct28,20141:31PM(inresponsetoPaulHardy)

EvenbeforeCDSyouhadthepossibilitytoaddconditionstotheviewinSE11(Selection
Conditionstab)ordoitviaABAPWHEREconditionintheSELECTstatement,soitdoesn't
reallybotherme.
CDSviewsarealsousedfornaiveHANAdevelopment,thiscouldbealsoareasonwhy
parametersareadded.
Guidelineswouldbegood,whichcasetousethemasinCDSorwhichcaseoutsidethe
CDS.
Like(0)

PeterInotaiOct30,20148:41PM(inresponsetoPaulHardy)

>AlsoIamstillwonderingaboutthis"L"language.....
It'smentionedinthe"ABAPDevelopmentforSAPHANA"book.
Onceit'smentionedthatit'sforSAPinternaluseonly(justlikeLanguageR).
Somewhereit'smentionedthatit'sanintermediaterepresentationfortranslatingSQLScript
intoC++language.
Like(0)

JacquesNomssiOct30,20149:10PM(inresponsetoPeterInotai)

HiPeter,

informationaboutLandevenacodesamplecanbefoundintheAMDBsectionof
theonlinehelp(ThanksHorstKeller).

OTOHtheRenvironmentisapowerfullsuitefordatamanipulationanddisplay.It
isafreeGNUprojectnotrelatedtoSAP.IunderstandyoucaninstallanRserver
onalinuxmachineandconnectittoaHANAsystem.

MyunderstandingisthattheDDLpartofCDS(Views)willcompletelyreplacethe
definitionofviewsinSE11.Youcanextendviews(Append),createassociations
(joinsondemand)anduseexpressions,soIcanimagineausecasewherethe
parameterisnotpartoftheprojectionlist,soyoucannotpassitasaWHERE
condition.

bestregards,

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

8/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

JNN
Like(1)

PeterInotaiOct30,20149:16PM(inresponsetoJacquesNomssi)

HiJNN,
Thanksfortheinfo!
Cheers,
Peter
Like(0)

PaulHardyOct30,201410:32PM(inresponsetoJacquesNomssi)

So,whenyoudefineaCDSviewyoustartoffwithalistofthefieldsfor
export,whichmatchesthelistoffieldsyouwoulddefineonthelefthand
sideofanSE11view.

ThereafterthesefieldsareavailableforuseinWHEREcondtiionsaftera
SELECTstatmementagainstthe"viewentity".

IfyoudeclaredaparameterthatwasNOTinthatlist,thenthatparameter
couldbeusedsomehowinsidethe"code"oftheCDSviewinawaythata
valuepassedinviaaWHEREclausecouldnot?

Ifso,couldyoubekindenoughttogivesomesortofexample,evenifthis
isnotactuallypossibleatthemomentinthecurrentlevelofHANA?
Like(0)

JacquesNomssiOct31,20141:07AM(inresponsetoPaulHardy)

fromtheABAPonHANAonlinecourse(Week03,Filtered
Association):

1)normalizedviewoftheEPMtexttable

@AbapCatalog.sqlViewName:'ZDDLS_CDS_33A'

defineviewzcdsv_adv_filter_example_base
asselectfromsnwd_texts
{
parent_keyasproduct_text_guid,
language,
text
}

2)Associationbetweentheproducttableandthetext
informationencodedinfirstview

@AbapCatalog.sqlViewName:'ZDDLS_CDS_33B'
defineviewzcdsv_adv_filter_example_l1
asselectfromsnwd_pdaspd
association[1..*]tozcdsv_adv_filter_example_baseastexts
ontexts.product_text_guid=$projection.text_guid
{
keypd.product_id,
pd.desc_guidastext_guid,
texts
}

3)consumetheassociationtextsexposedinsecondview,
filteringthelanguagetothegiveninputparametervalueora
defaultvalue

@AbapCatalog.sqlViewName:'ZDDLS_CDS_33C'
defineviewzcdsv_adv_filter_example_l2
withparameterslang:abap.lang
asselectfromzcdsv_adv_filter_example_l1asproduct
{
$parameters.langaslangu_filter_param,
coalesce(
product.texts[1:language=$parameters.lang].text,
product.texts[1:language='E'].text
)asproduct_description
}

Thefollowingisuntested,butIassumetheconsumptionofthe
3rdviewcouldlooklike

SELECT*FROMzcdsv_adv_filter_example_l2(lang=p_langu
)
WHEREproduct_idINso_prod
INTOTABLE@DATA(lt_result)

whereP_LANGUandSO_PRODcouldbeselectionscreen
parameter/selectoptions.
Like(1)

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

9/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

PaulHardyOct31,201411:35PM(inresponsetoJacques
Nomssi)

AsIsuspected,theparametergetspassedintosome
sortoffucntion,whichnaturallycannotbethecasewith
avalueinaWHEREclause.

YousaythisisastandardSAPexampleithastobe
saidtheyarestrugglingtofindapracticaluseforthis,
examplesshouldreallybealongthelinesof

1.Hereishowwedoitnow
2.Hereisanewwaytodoit
3.ThenewwayisbetterbecauseofXYZ

TheSAPlanguageexampledoesnotcutthemustard
asyoucanpassinSYLANGUinaWHEREclause.

Iftheexampleistryingtodosomethingmorethanjust
passbacktheproductdescriptiontwicethenmaybeI
ambarkingupthewrongtree.
Like(1)

JacquesNomssiNov1,201411:15PM(in
responsetoPaulHardy)

Foreachselectedproducttheexample
shouldreturnasingleproductdescriptionin
thedesiredlanguageifmaintained,otherwise
theproductdescriptioninthedefault
languageenglish.

SinceSP08youcanuseSQLexpressionsin
theCDSviewtoimplementlogicthatcannot
beachievedwithamereWHEREclause.
COALESCE(A,B)returnsAifnotNULL,
otherwiseB.
IguesswecoulduseCOALESCE()againon
theresulttoreturnaConstanttextifthe
descriptionisnotmaintainedinany
language.

ThisisIMOaverypracticalexample.Ican
rememberhavingtoimplementthislogicfor
MARAMAKTqueriesmorethanonce.With
thistheABAPlogicismuchsimplerandCode
PushDownisachieved.

JNN
Like(1)

MrMeNov17,201412:57PM

IfIunderstandcorrectlyIamabitunsure,sopleaseconfirmtransportingoftheCDSobjectandthe
ABAPcodingaccessingitremainseparate?

Whatabouttheotherwayaround,i.e.thepossibilitytoutilizeaclassicalABAPdictionaryobjectin
HANASQL?

InmyparticularcaseIamworkingwithan.hdbprocedureandwouldliketodeclareatableofatype
alreadyexistingintheABAPdictionary.Isthatpossible?

GreatpostBTW
Like(0)

HorstKellerNov18,20149:43AM(inresponsetoMrMe)

Hi,

ACDSviewasanABAPprogramoranyreposioryobjectisanormaltransportobject
governedbytheclassicaltransporttools.Ofcoursetheyaredifferentobjectsbuttheycanbe
transportedtogether.Nothinghaschangedherecomparedtoclassicaldictionaryobjects.
Infact,thatsonereason,whyABAPCDSisembeddedintheABAPDictionary.

Alsothesameasbefore.InNativeSQLyoucannotaccesstheABAPDictionaryasameta
datarepository,butyoushouldbeabletoaccesstheruntimeobjectgeneratedfromthe
dictionarydefinitiononthedatabase.

Horst
Like(1)

MrMeNov17,20149:20PM(inresponsetoHorstKeller)

Horst,

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

10/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
thankyouforyouranswerandclarification.
Unfortauntelyitisnotcleartomewhatyoumeanwith"youshouldbeableto
accesstheruntimeobjectgeneratedfromthedictionarydefinitiononthe
database".

Doesitmeanthatlocalvariablescanbedeclaredintheprocedurebasedone.g.
thetypesoftheprocedureparameters?Wouldittherebybepossibletodeclare
localtablevariablebasedoftypeBOOKINGSandCONFIRMATIONSinthe
examplebelow?

PROCEDUREDEMO(INp1BOOKINGS,OUTp2CONFIRMATIONS)
LANGUAGESQLSCRIPT
SQLSECURITYINVOKER
READSSQLDATA

AS
BEGIN

END

Thanx
Like(0)

HorstKellerNov18,201410:01AM(inresponsetoMrMe)

Hello,

DatabasetablesanddatabaseviewsdefinedintheABAPDictionaryare
createdonthedatabaseinthedatabaseschemaSAPsid.Forthis,native
DDLstatementsarepassedfromASABAPtothedatabasebythe
DatabaseInterface(DBI).

Youcanexaminetheseobjectsusingthedatabase'stoolsandinterfaces
andyoucanusetheprogramminglanguage(s)ofthedatabasetoaccess
them.IncaseofSQLScript,pleaserefertotherespectivedocumentation(
http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf),
howyoucanaccessthenativeviewsgeneratedfromanCDSsource.

ButmaybeitisabetterideatouseAMDPinthatcase.Whencreatingan
AMDPmethod,inABAP,youhavedirectaccesstotheDictionarytypes
usedinanCDSviewandyoucanlettheAMDPframeworkgeneratethe
actualdatabaseprocedureforyou.

Best

Horst
Like(2)

MrMeNov18,20146:59PM(inresponsetoHorstKeller)

ThanksforyouranswerHorst.

pleaserefertotherespectivedocumentation(
http://help.sap.com/hana/SAP_HANA_SQL_Script_Reference_en.pdf
howyoucanaccessthenativeviewsgenerated
fromanCDSsource.

Isearchedtheguidefor'CDS'and'native'butfoundnothing.Are
youreferingtoADBC?

Also:IamnotusingAMDPbecauseIhaveunderstoodthatfrom
anAMDPgeneratedproceduresonlyotherAMDPgenerated
procedurescanbecalled(i.e.notstoredprocedures).Thisis
oneofthereasonswhyIamnotgoingdowntheAMDProute.
Like(0)

HorstKellerNov19,20148:32AM(inresponsetoMrMe)

Isearchedtheguidefor'CDS'and'native'
butfoundnothing.
Ofcourse.SQLScriptisDBlevel.DBlevelisnative
fromtheABAPpointofview.DBleveldoesn'tknow
anythingabout'native'andCDS,sinceitisnativeitself
sotosay.Youhavetolookuptheartifactgeneratedby
theASABAPinHANAstudioandfindout,howto
handleitwithDBmeansifyoureallywanttodoso.But
thisisnotaquestiontoABAP.

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

11/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
IhaveunderstoodthatfromanAMDP
generatedproceduresonlyotherAMDP
generatedprocedurescanbecalled(i.e.
notstoredprocedures).

Whotoldyouso?AnAMDPprocedurecancallother
DBprocedures.

WhencallinganotherAMDPprocedure,thelatter
mustbelistedbehindUSING.
WhencallinganativeDBprocedureofthesame
DBschema,itmustbeinthenamespace
/1BCAMDP/(seeexample).Buthisshouldbe
restrictedtotemporaryprocedures.
Therearenosyntacticalrestrictionsincalling
nativeDBproceduresofotherDBschemas.But
ofcourse,youhavetotakecareyourself,thatthe
proceduresareavailableinanysystemandthat's
whyitshouldbedoneinexceptionalcasesonly.

Sothequestionsremains,whyyouwanttoaccess
ABAPfeaturesfromDBlevelatallandwhyyoudonot
wanttouseasupportingframework(AMDP)fordoing
so.
Like(0)

MrMeNov19,201411:42AM(inresponseto
HorstKeller)

Thanksforyourmanyanswerstomy
questions.

ThescenarioIamstrugglingwithis:Ihave
severalBWDSOtables(ABAPgenerated
artifacts,right?)whosecontentIneedto
manipulatebyAFL/PALfunctions(thrucalls
tocatalogprocedures).

Therearevariousoftheseprocedures
requiringdifferentcombinationsofinputand
outputparameters(alwaysatleastanINand
anOUTtable).

ThereasonbehindmyquestionsisthatIam
searchingforasolutionwhereIcanavoid
definingthestructureoftheDSOtables
manuallyonaDBlevel.Why?Doublework
ANDiftheDSOschangestheirstructurein
BW(ABAPAS)somebodymustremeberto
makethechangealsoonaDBlevel.

InitiallyItriedAMDP,butfounditabitlimited
forthereasonsyoumentionedaboveAND
thefactthatthesyntaxseemstoberestricted
visavisnormalprocedures(e.g.nolocal
temporarytablespermittedandother
restrictions).ThiswasthereasonthatIhave
beenlookingforanalternativebyusing
storedprocedures(thruBW'sHANAAnalysis
Process)fromwhichtheideawastocallthe
AFL/PALprocedures.

Iwilltakealookatthesimplestoption:user
exitlogicinBWtransformationwithloopover
anITABinsidewhichIfirstpreparethedata
andthenexecutecallstotheAFL/PAL
functions(whicharelocatedinanother
schema)bymeansofAMDP.Asyoustatethis
shouldbedoneonlyinexceptionalcases(I
normallytrytoavoidthose),butinmycaseit
seemsasifitcouldbethe'rightthing'todo.

Thanksagainforyourassistance.
Like(0)

UweFetzerJan9,20159:12PM

I'mcurrentlyplayingwiththeassociationexampleoftheABAPKeywordDocumentationandgettinga
warning"Association&caninfluencethecardinalityoftheresultingset".Thisalsohappensinallof
myownexamples.

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

12/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN

Doyouknowwhatthiswarningmeansandhowtopreventit?
(I'mon7.40SP9)
Like(1)

HorstKellerJan12,20158:28AM(inresponsetoUweFetzer)

ThepurposeofsuchwarningsinCDSsourcecodeistopointoutpropertiesofaviewthat
mightbeunexpectedfortheprogrammer.Warningscancomeeitherfromthesyntaxbut
alsofromtheABAPDictionary,wheretherespectivedatabaseviewisgenerated.An
exampleforthelatterwouldbe"allfieldsarekeyfields".Unfortunatelyuptonow,thereisno
waytohidesuchwarnings(noCDSpragmasyet)buttheproblemisknownandworkisin
progress.
Like(2)

AnitaDixitMar30,20158:22AM

Hi,
IhavecreatedasimpleABAPCDSview,usingoneinputparameterfordate.ButIneedtouseitin2
differentplacesinthe'where'condition.ButIamgettingthiserror.

Cananyonehelphereplease?

Like(0)

DominikRoschApr2,201512:41PM

Hieveryone,

I'mhavingcosmeticproblemswithmyCDSViews.IcreatedthemwithENasmydefaultlanguage
thoughIworkforagermancompanyinwhicheveryonesignsinusingDEasdefaultlanguage.

Iprovidetheshortdescriptionformyviewsusingthefollowingannotation:
@EndUserText.label:'<ShortDescription>'

WhenItrytolookupmyviewsinSE11usingF4HelpinDElanguage,therearenoshort
descriptions(duetothembeingwritteninEnglish?),whereaswhendisplayingtheviewinSE11,the
shortdescriptionisavailable.

DoyouhaveanyideaonhowtoprovidesaidF4HelpshortdescriptionsinDE?

Best,
Dominik

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

13/14

4/27/2015

ABAPNewsfor7.40,SP08ABAPCoreDataServi...|SCN
Like(0)

SiteIndex
Privacy

ContactUs
TermsofUse

SAPHelpPortal
LegalDisclosure

Copyright

http://scn.sap.com/community/abap/blog/2014/10/10/abapnewsfor740sp08abapcoredataservicescds

FollowSCN

14/14

Вам также может понравиться