Montag, 25. Januar 2016

Siebel: Setting the NavCtrlPR to Transalte causes clients not to load ("blank screen")

Just a quick note on a behavior I recently discovered in Siebel 8.1.1.14 with OpenUI:

When in a multilingual environment, you may have noticed that the values offered in Behavior / Navigation Control appear in ENU and your local language(s).

This is because the underlying LOV (NavCtrlPR) does not have the translated flag set. However, after setting the translation flag (and restarting the server) the clients that access the object manager of your local language show a "blank screen". (The menu bar appears, but without any text. The toolbar sets up - but nothing else is displayed).

In the javascript console of your browser, an error appears that looks like this:


Die Uncaught TypeError: Cannot read property 'Show' of undefined
@
navctrlmngr.js?_scb=8.1.1.14_SIA_[23044]_DEU:39
  
In other browsers the error message could be different. The error also differs from time to time. For example, I had also errors saying that the method ShowUI() of undefined cannot be executed.


After some debugging I saw that the error appears right after a business service (that initializes the navigation) was called from javascript. The assumption is, that the Javascript relies on english values to be provided and thus, the UI crashes when receiving something different - but I did not verify this.

However, resetting the translate flag of NavCtrlPR to false solved the problem. I only know of 2 variants now how to display the navigation control:

  • Display the values of all installed languages
  • Display only ENU languages
    • You can achieve this by setting the inactive flag of the local entries in the LOV so only the ENU values remain active
If somebody knows an alternative way (or maybe even a solution) to cope with this problem, please feel free to leave a comment.

Dienstag, 5. Januar 2016

Implementing the Fibonacci Numbers

The fibonacci numbers are a sequence of integers defined as follows.

Let F(n) be the n-th fibonacci number, then:
  • F(1) = 0
  • F(2) = 1
  • F(n) = F(n-1) + F(n-2) for all n>2
Thus, the first 10 fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

Since the definition of the fibonacci numbers is already recursive (using a so called recurrence relation), their recursive implementation is taken as example for recursive programming in a lot of basic programming courses.

The naive approach to write a recursive function calculating the n-th fibonacci number would look like this:

Function fib(n)
   IF n=1 THEN

      RETURN 0
   ELSE IF n=2 THEN

      RETURN 1
   ELSE
      RETURN fib(n-1) + fib(n-2)

Because of the last line of the above code, multiple computations of already computed fibonacci numbers are performed over and over again. To calculate F(5), we need to calculate F(4) and F(3). To calculate F(4) we need to calculate F(3) (again!) and F(2) and so on. For example, in a call of fib(15) the following numbers are calculated:

Fibonacci numberCount of calculations
F(15)1
F(14)1
F(13)2
F(12)3
F(11)5
F(10)8
F(9)13
F(8)21
F(7)34
F(6)55
F(5)89
F(4)144
F(3)233
F(2)377
F(1)233

(By the way, this is a perfect example for practical usage of the fibonacci numbers: Think about the count of calculations and if and why these values look familiar to your eyes :) )

In the following video I'll introduce an iterative approach (implemented recursively!) to calculate the numbers in javascript without redundant computation. The pseudo code looks like this:

Function fib(n)
   IF n=1 THEN

      RETURN 0
   ELSE IF n=2 THEN

      RETURN 1
   ELSE
      RETURN fibInner(n, 3, 1, 0)

Funciton fibInner(n, iter, prev, pprev)
   IF iter=0 THEN
      RETURN prev+pprev
   ELSE
      RETURN fibInner(n, iter+1, prev+pprev, prev)

Here we actually have a function fibInner that gets as its parameters the values of the two previous fibonacci numbers. We are therefore storing the information we need to calculate the next number without the need of calculating them again.

If you are interested in a more detailed explanation or in the javascript implementation, have a look at the video here:



Last but not least, here are some great links to further information about recursion/iteration and how to cope with some problems that can occur when using recursion - taken out from the book Structure and Interpretation of Computer Programs
The fibonacci numbers are a very well studied sequence. To see what kind of stuff math gurus do with them, have a look at the wikipedia article.


Introduction

Hello World!

Parallel to my youtube channel LiveYourCode, I'm starting this blog about one of my favourite things to do: Writing source code :-)

I'll start with a couple of easy recursive algorithms but there is no overall great plan on what I'll post here. It will be anything related to programming, algorithms, software architecture and whatever comes to my mind :)

I apprechiate any feedback!

Cheers,
Steve