BusinessObjects Board

User Defined Transform - Python

Dear all,
I’m trying to test writing Python code on User Defined Transform. I used an example on http://wiki.sdn.sap.com/wiki/display/BOBJ/Previous+row+processing+via+User+Defined+Transform

to test for the feature. However, I experienced the following warninig message that prevents the job from running.

Any help on this would be appreciable. Thank you in advance!


s.soka (BOB member since 2012-02-07)

In order to use any input/output fields they need to be mapped under the I/O Fields tab. The labels used must match the strings used in the get & set fields expressions. (this is also case sensitive)

it can be a bit quirky at first, but after a couple years you’ll get the hang of it. :crazy_face:


jlynn73 :us: (BOB member since 2009-10-27)

Dear jlynn73,
Thank you for your reply! I’ve checked the case sensitivity against the I/O fields and python code. You are right! The problem was with the I/O field names. They were mis-speled in the record.GetField/SetField() methods. The warning message still persists but the job has successfuly run.

Thanks a lot!


s.soka (BOB member since 2012-02-07)

Hi
I experienced the following err when executing the job. I think the type casting from string to float was alright but I don’t know why I still get such an err.

The other thing is that how do I determine/specify the output data format? For example, if I want the floating point to be separated by . rather than ,.
Its always pleasing me to thank you in advance.


s.soka (BOB member since 2012-02-07)

the error is telling you that the value you’re trying to assign has a comma in it, which make me think its still a string. When it tries to assign it to the receiving field of type float, it doesnt know what to do with that comma.

DS does some dynamic typing which automatically converts the result of an expression into the target data type. So it even if you cast a string field to a datatype of float, if the receiving field is a string… it will convert it back. Be my first guess.


jlynn73 :us: (BOB member since 2009-10-27)

Hey, I fixed the problem modifying the module like this:

#order_number is same as previous, populate customer_ID and sum revenue
elif dct[u'Order_Number'] == record.GetField(u'ORDER_NUMBER'):
	prev_revenue = dct[u'RevenueSum']
	cur_revenue = record.GetField(u'REVENUE')
	dct[u'RevenueSum'] = unicode(str(float(prev_revenue.replace(',','.')) + float(cur_revenue.replace(',','.'))))

I added two local variables: prev_revenue and cur_revenue, which hold the previous & current revenue values. Then it was easy to find and replace the ‘,’ with ‘.’ using the replace method that in turn made it simple to convert string to float.

Thank you for your help!


s.soka (BOB member since 2012-02-07)

I am working on similar requirement.

I am getting below error. Anyone please help me out.It is working from browser but no from BODS.

22048 20044 DQX-058306 3/5/2014 8:29:36 PM Transform <Base_UserDefined>: Traceback (most recent call last):
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “EXPRESSION”, line 17, in
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 124, in urlopen
22048 20044 DQX-058306 3/5/2014 8:29:36 PM return _opener.open(url, data, timeout)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 383, in open
22048 20044 DQX-058306 3/5/2014 8:29:36 PM response = self._open(req, data)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 401, in _open
22048 20044 DQX-058306 3/5/2014 8:29:36 PM ‘_open’, req)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 361, in _call_chain
22048 20044 DQX-058306 3/5/2014 8:29:36 PM result = func(*args)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 1130, in http_open
22048 20044 DQX-058306 3/5/2014 8:29:36 PM return self.do_open(httplib.HTTPConnection, req)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM File “D:\SAP_BusinessObjects\Data Services\DataQuality\python\lib\urllib2.py”, line 1105, in do_open
22048 20044 DQX-058306 3/5/2014 8:29:36 PM raise URLError(err)
22048 20044 DQX-058306 3/5/2014 8:29:36 PM URLError: <urlopen error [Errno 10060] A connection attempt failed because the connected party did not properly respond after a
22048 20044 DQX-058306 3/5/2014 8:29:36 PM period of time, or established connection failed because connected host has failed to respond>.
22048 20044 DQX-058306 3/5/2014 8:29:36 PM |Data flow New_DataFlow7|Transform Base_UserDefined
22048 20044 DQX-058306 3/5/2014 8:29:36 PM Transform <Base_UserDefined>: : Error executing the expression.
22048 20044 DQX-058302 3/5/2014 8:29:36 PM |Data flow New_DataFlow7|Transform Base_UserDefined
22048 20044 DQX-058302 3/5/2014 8:29:36 PM Transform <Base_UserDefined>: DLL <udt_transformu.dll> runtime function failed with error <3>. More
22048 20044 DQX-058302 3/5/2014 8:29:36 PM detailed information may be obtained from previous errors.
16088 20412 DQX-058302 3/5/2014 8:29:46 PM |Data flow New_DataFlow7|Transform Base_UserDefined
16088 20412 DQX-058302 3/5/2014 8:29:46 PM Transform <Base_UserDefined>: DLL <udt_transformu.dll> runtime function failed with error <3>. More
16088 20412 DQX-058302 3/5/2014 8:29:46 PM detailed information may be obtained from previous errors.


itsvsk :india: (BOB member since 2011-05-04)

Check that your browser is configured to use a proxy server and that only that proxy server has access to the DMZ and the wider Internet?

Python 2.6.2, which Data Services uses, does not support tunnelling and will basically only work when a direct connection between the job server and the target web service/webserver/IP address.

We had a similar issue at another client, raised a SAP support call for this and SAP provided us with 2 replacement Python libraries for httplib and urlib2 - I believe these were taken from the Python 2.6.3 distribution which does support network tunnelling.


ErikR :new_zealand: (BOB member since 2007-01-10)

I tried to configure the URL IP in browser. But no sucess.

I will check with SAP on this. Thanks for information.


itsvsk :india: (BOB member since 2011-05-04)