0% found this document useful (0 votes)
246 views7 pages

Use of User-Defined Transform in Data Service 14 PDF

The UserDefined transform provides you with custom processing in a data flow using full Python scripting language. You can use the User Defined transform to generate new records, populate a field with a specific value, create a file, connect to a website, or send an email. In this blog i'm demonstrating a process where I will be accessing a web service and mapping the response and from the web service to a target table using The UserDefined transform.

Uploaded by

Pallavi Koppula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
246 views7 pages

Use of User-Defined Transform in Data Service 14 PDF

The UserDefined transform provides you with custom processing in a data flow using full Python scripting language. You can use the User Defined transform to generate new records, populate a field with a specific value, create a file, connect to a website, or send an email. In this blog i'm demonstrating a process where I will be accessing a web service and mapping the response and from the web service to a target table using The UserDefined transform.

Uploaded by

Pallavi Koppula
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like