Showing posts with label Oracle ?. Show all posts
Showing posts with label Oracle ?. Show all posts

Saturday, March 30, 2019

BIP: Number to Text , complex version



Oracle never ceases to amaze me. I recently saw this question being asked again on stackoverflow.

Basically, this is an RTF template supposed to print a check. And the amount has to be converted to text, to be printed on the 'Amount' line on the check. BIP provides a function for this called xdofx:to_check_number.
It is documented over here. The function can print the output text in different locales, and decimal number settings. But the number to be printed has to be in an XML node. It only accepts simple XPATH notations, and the value itself cannot be a result of a sum() function, or the result of any mathematical operation.
Which means, if you have an XML like this:

<root>
     <amt>3243243</amt>
     <amt>6436464</amt>
     <amt>243</amt>
     <amt>445454</amt>
     <amt>67676</amt>
</root>


And you want to print the output as the sum of all the 'amt' elements, that cannot be done.

<?xdofx:to_check_number(sum(amt),'EUR')?>

Outputs:
Zero and xx/100



Which leads me to say: WTF Oracle ?

I had solved this problem years ago, but I couldn't remeber how. So I deep dived, again, into the same problem.


Using the RTF template, I exported the XSL-FO stylesheet out:




This extracts the intermediate XSL file BIP uses to generate the final report output.
Search for "to_check_number" in this XSL:



It can be seen that although there is a for-each loop there, the template itself is not called recursively.  It access the element 'amt' without a proper XPATH, and then does a stupid (.///)[1]  whatever that means.

But if you pass a string with the number into the function to_check_number, this works out perfectly.


For the foe-each loop to sum up all the values, it has to call itself recursively. Obviously, this function is broken.

But is there a way to fix this ?

Turns out, there is. Look two lines lower in the XSL file.



It can be seen that the XSL finally invokes another hidden function xdoxslt:toCheckNumber. This namespace is unique, I am guessing it is shared between the XSL and XDO name spaces.

So I tried using this 'hidden' function directly in the template.

Like this:



<?xdoxslt:toCheckNumber($_XDOLOCALE, sum(amt), ('EUR'))?>


Which produces the output:



Voila !!

So in case you have to convert a dynamically generated number to text, use the toCheckNumber function directly.


Which leads to the question, why have the xdo function in the first place ?

But do bear in mind, that this is an undocumented function, which works for now.


Tuesday, September 15, 2015

Fusion HCM: Integration woes

 

Looks like Oracle does not want customers/consultants to integrate other applications to its new fusion cloud based applications. There is close to NO documentation available on Oracle SupportWeb about setting up and invoking webservices, the only information available is on some Oracle blogs, and even they don't cover the full extent of APIs. Some Oracle champs have shared information on using REST services of some Oracle cloud apps, but it is clear that each of Oracle's cloud offerings have a different topology and architecture driving the integrations. I have been playing around with the Fusion HCM webservices for some time now, and I have to say that Oracle definitely needs to work on their documentation.

All of Oracle's cloud apps are following a standard approach: they will not (read cannot) consume a WSDL of another system, but they expose a WSDL/REST service of their own, which has to be invoked from outside to get the integrations working.

Consider the Fusion HCM Wsdl, the location of which has to be taken from Oracle repository. Using the get/find methods in the WSDL proved easy, but using the create/update methods proved to be a different challenge.

Problem 1: Every element in the WSDL is optional !. Check out the CreateWorker service, which is meant to be used to create the employee records in the HCM system. Usually the XSD/WSDL gives a good understanding of the structure of the system's data model, the required fields are marked so the end system has an idea of what fields to send to create a record. In  Oracle's Fusion HCM wsdl, every element is marked as optional, even the name elements. This means the developer/consultant has to have an in-depth knowledge of the HCM system to start using the wsdls. cleartext.blogspot.com

tmpE738

Really, Oracle ? cleartext.blogspot.com

Problem 2: No useful/meaningful validation me ssages. As soon as one starts triggering the methods of the HCM wsdl, the errors come back. Or, shall we say, NO errors come back. Looks like Oracle developers have not handled every exception properly.

tmpBF7D

WTF is  "JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null: null" supposed to mean ?

cleartext.blogspot.com

Problem 3: No documentation whatsoever. Oracle has two kind of cloud applications running now. One is the group of apps they have acquired, like Taleo, Rightnow CX etc…The other are cloud applications built by Oracle from ground up, from square one. For the former group of apps, the original developers have , thankfully, provided considerable documentation of the APIs. But for Oracle's own offerings, they have decided that less is better, and there is no detail documentation of the APIs. On these new cloud applications, the APIs are the only way to interact with the system, in traditional On-Premise systems, you could always have access to the application, filesystem and even database.

 

cleartext.blogspot.com