Você está na página 1de 7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

GettingStarted Newsletters

Hi,Guest

LogOn

JoinUs

Store

SearchtheCommunity

Products

Services&Support

AboutSCN

Downloads

Industries

Training&Education

Partnership

DeveloperCenter

Activity

LinesofBusiness

UniversityAlliances

Events&Webinars

Innovation

Browse

Communications

Actions

DataServicesandDataQuality

UseofUserDefinedTransforminDataService4.Xfor
AccessingWebServicePart1
PostedbyTittoAntonyinDataServicesandDataQualityon10May201308:49:29
Share

Tweet

Like

InthisblogIwillbeexplaininghowtousetheUser_DefinedTransforminDataServices4.xfor
accessingWebServices.

UserDefinedTransform

TheUserDefinedtransformprovidesyouwithcustomprocessinginadataflowusingfullPython
scriptinglanguage.ItcandojustaboutanythingthatyoucanwritePythoncodetodo.Youcanuse
theUserDefinedtransformtogeneratenewrecords,populateafieldwithaspecificvalue,createa
file,connecttoawebsite,orsendanemail,justtonameafewpossibilities.UserDefined
TransformscomesundertheDataQualityTransforms.

Introduction

HereImdemonstratingaprocesswhereIwillbeaccessingawebserviceandmappingthe
responseandfromthewebservicetoatargettableusingtheuserdefinedtransform.i.e.keyfield
comingfromthesource(hardcodedvalue)ispassedtothewebserviceandtherequiredoutputis
extractedfromthewebserviceresponse.

Inthisprocessweareusingasimplerestfulwebservicethatwillbeacceptingthekeyvaluefrom
thesourceasaparameters

http://Server_Path:parameter1=value1?parameter2=Value2

OutputofthewebServiceisasimpleXMLStructurewhichwillbelike

<RootTag>
<name>OutputNeedtoMappedtoTarget</name>
</RootTag>

StepbyStepDetailsofProcessFollowed
1)CreateabatchjobandbuildthescenariointheDataflow.Forourscenariowehavetwoinput
rowsandvalueofthekeyfieldthatneedtobepassedtotheuserdefinedtransformisexplicitly
providedusingtheQuerytransform.

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

1/7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

2)MaptheinputtotheUserDefinedtransform.OpentheUserDefinedtransformandmap
inputfieldsfromtheschemaintotheschemaoutoftheTransformwhichneedtobedirectly
mappedtothetarget.InourcasewecanmaptheMAT_KEYfieldintheinputschematothe
schemaoutofthetransform.

2)3)TouseinputfieldinaPythonexpressioninyourUserDefinedtransform,wefirstneedto
mapittoarecognizedfieldnameintheInputtab.ForthatDraganddroptheinputfieldwhich
needtobeusedintheUserDefinededitorintotheinputtaboftheEditor.Soarewemappingthe
inputfieldMATNRintotheinputtaboftheuserdefinedtransform.

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

2/7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

3)4)InUserDefinedusercannoteditoptionsintheUserDefinedtransformeditor.Toedit
options,youmustusetheUserDefinededitor,whichisaccessedfromtheOptionstabintheUser
Definedtransformeditor.

4)5)TheUserDefinedtransformcontainsoptionsthatdeterminehowthetransformprocesses
data.Therearetwomodestoprocessthedatatheyare

Percollection:Appliestheexpressiontoentiredatacollection.Usethisoptionwhenaddingnew
records,whichdidnotexistbefore,intothedataflow.SelectingthisoptiondisplaystheGroup
Formingoptiongroup,inwhichyousetupbreakgroupsandcandidateselection.

Perrecord:Appliestheexpressiontoeachrecord.Youcannotaddnewrecordsintothedataflow
withthisoption.Thisoptionisthedefaultandwhatyouwillwanttousemostoften.
InthisdemonstrationweareusingtheperrecordDataprocessingmode

5)6)ClicktheLaunchPythonEditorbuttontoaccessthePythonExpressioneditor.

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

3/7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

6)7)InthePythonExpressioneditor,createandeditPythoncodeintheeditorpaneofthewindow.
ThePythonexpressionthatyoucreateheredependsonwhatyouneedtodowithUserDefined
transform.PythonExpressioneditorcontainThePythonAPItabwhichlisttheobjects,functions,
classes,andmethodsthatareavailableforthespecifictransformandprocessingmode.

AnditalsocontainstheI/OFieldstabdisplaystheinputfieldsandoutputfieldsthathavebeen
mappedintheUserDefinedtransform.wecanalsoadd,delete,andeditthepropertiesofuser
definedinputandoutputfieldsfromthistabbyrightclickingInputFieldsorOutputFieldsand
selectingInsert,Delete,orProperties.

7)8)NextwewillbecreatinganoutputfieldwithanameDESC_OUTbyrightclickingtheOutput
fieldsandselectingInsert.Outputofthetransformismappedtothisfieldinourpythoncode.

8)9)PythonExpressioneditorisusedtocreateourpythonexpressionfordoingtherequired
transformationlogic.InourcasewehavetobuildtheWebServiceURLbyappendingtheInput
keyfieldandcallthewebserviceforgettingtheresponseandextracttheoutputfieldfromthe
response.Pleasefindbelowthepythonexpressionwebuiltforhandlingtheabovementioned
process.Moredetailsexplanationthepythonexpressionwillbegiveninthepart2foryour
reference

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

4/7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

9)10)Afterthecreatingthepythonexpressionwecanvalidatetheexpressionbyclickingthe

ValidatebuttoninthePythonExpressioneditor.ThesyntaxcheckermakessurethatthePython
codehasrequiredcolon(:)characters,stringliteralclosingcharactersandCorrectindentation.

1011)OncomingbacktotheUserdefinedtransformyouhavespecifytheoutputfieldsthatneedto
bemappedtotheoutputofthetransform.Theseareusefulifyourepeatedlyuseatransformwith
differentandinputandoutputfields

1112)NextwehavetomaptheoutputoftheUserDefinedmappingtothetargettableandrunthe
job.Hereinmytargettablethefieldvaluecomingfromtheuserdefinedtransformismappedto
DESCfieldinthetarget.

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

5/7

5/9/2016

UseofUserDefinedTransforminDataService4...|SCN

1213)Pleasefindtheinputandoutputgenerated

ThesearetheStepsthatarefollowedtoaccessawebserviceusinguserdefinedtransform.By
usingtheaboveapproachwecanaccessawebservicewhichcannotbeaccessedusing
conventionalwaysavailableintheBODS.

4322Views
Products:sap_businessobjects_business_intelligence_platform_4.0Topics:business_intelligenceIndustries:professional_services
Tags:rest,python,webservice,bods,data_quaity,user_defined_transform,restful_webservice,access_webservice,website_access,
sap_bods_webservice,soap_webservice,sap_bods

AverageUserRating
(11ratings)

Share

Tweet

Like

6Comments
TittoAntony17May201313:22

pleasevisit http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefined
transformindataservice4xforaccessingwebservicepart2fordetailsonpythoneused.
Like(2)

MikhailBudilov01Dec201323:41

AddsupportPython3.3.xinDS:ViewIdea
Like(1)

TittoAntony19Sep201414:06(inresponsetoMikhailBudilov)

Done

Mikhailniceinitiativeanditsuseful..
Like(0)

PanCheng19Sep201415:52

Niceone..
Like(1)

Shaneel25May201507:58

Hi,

DoesthewebservicehavetobeconfiguredbyaSAPBasispersonorcanitbedonebya
Developer?

Alsowouldyoubeabletohelpmeonwhatchecks/configurationsneedtobedonetogetthe
WebServicetowork?

IamcurrentlytryingtoconsumeaSharePointWebService,andIamnewtoSAP.

ThankYou,
Shaneel.
Like(0)

TittoAntony28Jun201519:26(inresponsetoShaneel)

Youcandirectlyconsumethewebserviceifitisaccessibleformthejobservermachine.
Like(0)

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

6/7

5/9/2016
SiteIndex
Privacy

UseofUserDefinedTransforminDataService4...|SCN
ContactUs
TermsofUse

SAPHelpPortal
LegalDisclosure

Copyright

http://scn.sap.com/community/dataservices/blog/2013/05/10/useofuserdefinedtransformindataservice4xforaccessingwebservicepart1

FollowSCN

7/7

Você também pode gostar