2step-by-step guide to build an odata service ba
DESCRIPTION
oDATAfIORITRANSCRIPT
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 1/11
GettingStarted Newsletters Store
Products Services&Support AboutSCN Downloads
Industries Training&Education Partnership DeveloperCenter
LinesofBusiness UniversityAlliances Events&Webinars Innovation
LogOn JoinUsHi,Guest SearchtheCommunity
Activity Communications Actions
Browse
volker.drees
0 Tweet 1
Helloagain.
Inthe firstpart(1)wehavecreatedaservicethatconsistsoftwoentities(SalesOrderandSalesOrderLineItem)andtworelatedentitysets.TheruntimeartifactshavebeengeneratedandtheODataservicehasbeenregisteredandactivated.Inthispart(2)wewillmapbothentitysetstotherelateddataprovidersinourcasethe2EPMBAPIs.Whenitcomestodataprovidermapping/implementationofODataservicesyouusuallystartwiththeQuerymethodasthisisatypicalentrypointwhenconsumingaservice.Inourcasewewillfirstenablethequery:providemeallSalesOrdersthatexist.Inarealbusinesscaseyouwouldprobablymakesomefilteringmandatorytonotoverloadthebackendsystem.Butletskeepitsimpleforthetimebeing
1.AsmentionedwewillstartwiththeQuerymethodfortheSalesOrderCollectionentityset.ExpandthenodeServiceImplementation>SalesOrderCollectionandrightclickGetEntitySet(Query)andselectMaptoDataSource:
2.Inthemaptodatasourcewindow,enterthefollowingvaluesandchooseEnter:TargetSystem Local
DataSourceType RemoteFunctionCall
DataSourceName BAPI_EPM_SO_GET_LIST
StepbystepguidetobuildanODataServicebasedonRFCsPart2PostedbyVolkerDreesinvolker.dreeson26Oct201211:44:38
Share 4
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 2/11
3.ThemappinghasalreadydonebecausethedatamodelhasbeenbuiltbasedonthesameRFCinterface.Foreachproperty,settheMappingDirectiontoOutput.ChooseEnter:
NowwecanmoveonanddothemappingfortheReadoperation(GetEntity)oftheSalesOrderCollection.1.RightclickGetEntity(Read)andselectMaptoDataSource:
2.IntheMaptoDataSourcedialogbox,enterthefollowingvaluesandchooseEnter:TargetSystem Local
DataSourceType RemoteFunctionCall
DataSourceName BAPI_EPM_SO_GET_DETAIL
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 3/11
3.ThistimetherearenodefaultmappingsettingsbecausethedatamodelhasbeendefinedbasedonadifferentRFCmodule.ExpandtheHEADERDATAnodefromthetreeontherighthandside:
4.Drag&drop the following fields from the righthand tree to theDataSourceParameter columnof thegrid in themiddleofthescreen:
RFCField(righthandside) EntityProperty
SO_ID SoId
NOTE Note
BUYER_ID BuyerId
BUYER_NAME BuyerName
CURRENCY_CODE CurrencyCode
GROSS_AMOUNT GrossAmount
NET_AMOUNT NetAmount
TAX_AMOUNT TaxAmount
InanyReadOperationwealsoneedtoprovidetheprimarykeyoftheunderlyingentityasaninputparameter.Forthiswehavetomanuallyaddanewlinetothemappingscreen.1.ChoosetheAppendRowpushbutton:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 4/11
2.OnthenewlinepressF4toselecttheentitysetproperty.DoubleclickSoIdtoselecttheentry:
3.ExpandtheSO_IDnodefromthetreeontherighthandside:
4.Drag&DroptheRFCfieldSO_ID(fromnodeSO_ID)tothenewlycreatedline:
5.Thisperformsthemappingontheinputparameter(SalesOrderIDtofetchtheSalesOrderdetails):
NowwecanmoveonwithmappingtheQueryoperationfortheSalesOrderItementityset
1. Expand the nodeService Implementation > SalesOrderItemCollection and rightclickGetEntitySet (Query) andselectMaptoDataSource:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 5/11
2.IntheMaptoDataSourcedialogbox,enterthefollowingvaluesandchooseEnter:TargetSystem Local
DataSourceType RemoteFunctionCall
DataSourceName BAPI_EPM_SO_GET_DETAIL
3. There is again no defaultmapping because the datamodel has been built based on a differentRFCmodule.ExpandtheITEMDATAnodefromthetreeontherighthandside:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 6/11
4.Drag&drop the following fields from the righthand tree to theDataSourceParametercolumnof thegrid in themiddleofthescreen:
RFCField(righthandside) EntityProperty
SO_ID SoId
SO_ITEM_POS SoItemPos
PRODUCT_ID ProductId
NOTE Note
CURRENCY_CODE CurrencyCode
GROSS_AMOUNT GrossAmount
NET_AMOUNT NetAmount
TAX_AMOUNT TaxAmount
QUANTITY Quantity
QUANTITY_UNIT QuantityUnit
5.IntheDirectionColumnsetallfieldstoOutput.ChooseEnter:
6.ChooseAppendRowbutton:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 7/11
7.Fromtheinputhelp,selectSoIdforthenewline:
8.ExpandtheSO_IDnodefromtherighthandtree:
9.Drag&droptheRFCfieldSO_ID(fromnodeSO_ID)tothenewlycreatedline:
Nowwearedonewiththedataprovidermapping(atleastfortheQueryandReadoperationsweneed).NowwecanregeneratetheruntimeartifactsandrunourODataservice.1.ChoosetheGeneratepushbutton:
2.Verifythattheruntimeobjectshavebeengeneratedsuccessfully:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 8/11
3.StarttheGatewayClient(Transaction/IWFND/GW_CLIENT) inaseparatewindowtoruntheservice.ProvidethefollowingURItogettheSalesOrderCollection.ThisexecutesthequerymethodoftheSalesOrderentityset:/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection
4.ChooseanysalesorderentryandusetheURItonavigatetothesalesorderdetail,forexample:/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderCollection('0500000001')
5.GettherelatedsalesorderlineitemsviathefollowingURL:/sap/opu/odata/sap/ZGW100_XX_SO_SRV/SalesOrderItemCollection/?$filter=SoIdeq'0500000001'
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 9/11
AverageUserRating
(4ratings)
MyRating:
0 Tweet 1
TonavigatefromtheSalesOrderentitytotherelatedlineitems(EntitySet),youneedtoconstructtheURIyourself.Inthe nextpart(3)youwillseehowtodefineanassociationandanavigationpropertybetweenthetwoEntities.
19161Views Products:sap_netweaver_gatewayTopics:mobileTags:gateway,odata,netweaver_gateway,service_builder
Share 4
11Comments
Like(0)
MatteoSomensi09May201417:09
hi,Ifollowedstepbystepyourguide,butitdoesnotwork,theservicewhenIcallSalesOrderCollectionorSalesOrderItemCollectiongivesmeanerrorlikethis:
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 10/11
Like(0)
akshathlt14May201412:59(inresponsetoMatteoSomensi)
HiMatteo,CheckwithconnectionofNW&ECC(Backend)systemconnectedproperlyornot.OnceyoucrosscheckwithBASISteamifpossible.
Like(0)
ARSHADSHAIKH03Nov201412:45
HiVolker,Ifollowedyourblog.iamnotgettingerrorbut,/sap/ZSALES_ORDER_SRV/SalesOrderSetInVBAKihavemanySalesOrdersbutitshowonlyfirst2andwithoutanyotherdeailslikeNote,BuyerId,BuyerNameall.Tableentries.
IfIpasscorrectSalesorderid/sap/ZSALES_ORDER_SRV/SalesOrderSet('0000004975')Iamgettingthiserror
Canyouhelpmeoutinresolvingtheproblem.
VolkerDrees03Nov201416:51
HelloArshad,asmentionedinthefirstparttheBAPIsusedareaccessingtheEPMdemocontent.TheyarenotaccessingtheSDtables(likeVBAK).InsteadyoufindthesamplesalesordersofEPMintableSNWD_SO.Hopethishelps.BestRegards,
-
16/04/2015 StepbystepguidetobuildanODataServiceba...|SCN
http://scn.sap.com/people/volker.drees/blog/2012/10/26/stepbystepguidetobuildanodataservicebasedonrfcspart2 11/11
FollowSCNSiteIndex ContactUs SAPHelpPortalPrivacy TermsofUse LegalDisclosure Copyright
Like(0)
Volker
Like(0)
ARSHADSHAIKH04Nov201406:38(inresponsetoVolkerDrees)
ThanksVolker,canyousuggestmehowtoaccessthedatafromstandardtables(likeVBAK),IhavetocreatecompleteserviceforSalesOrderandPurchaseorder,BestRegards,ArshadShaikh
Like(2)
VolkerDrees04Nov201409:33(inresponsetoARSHADSHAIKH)
HelloArshad,I'dproposetoaccessstandardtablesviatherelatedBAPIs.E.g.forSalesOrdersthereistheBAPI_SALESORDER_GETLISTfunctionmodule.BestRegards,Volker
Like(0)
ShakeeluddinKhaja24Nov201413:46
Veryusefulinfo.ThanksVolker
Like(0)
PatrickDean27Nov201412:00
Superuseful!Thanksforthedetails!
Like(0)
saurabhvakil26Feb201513:31
Hi,Wehavefollowedyourfirstblog StepbystepguidetobuildanODataServicebasedonRFCsPart1andaretryingtoimplementthestepsmentionedinthisblog.Whileperformingthestep
1.ExpandthenodeServiceImplementation>SalesOrderItemCollectionandrightclickGetEntitySet(Query)andselectMaptoDataSource:wefindthatwhenwerightclickonGetEntitySet(Query)weseetheoptionMaptoDataSourceindisabledformat.Canyoupleaseletmeknowwhatmaybethereasonforthis?Regards,Saurabh
Like(0)
VolkerDrees27Feb201511:06(inresponsetosaurabhvakil)
HiSaurabh,areyoustillinEditmode?"MaptoDataSource"shouldbedisabledonlyinDisplaymode.BestRegards,Volker
Like(0)
VolkerDrees27Feb201511:37(inresponsetosaurabhvakil)
Orhaveyoualreadymappedadatasource?Inthiscasethemenuoptionisalsogreyedout.Regards,Volker