cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping bug for exists-function in 7.1 ?

Former Member
0 Kudos

Hello,

following strange graphical mapping behaviour. Goal is to create a certain target segment only for those E1EDP05 source segments where field KSCHL exists.

And I need to align the KSCHL contexts with the E1EDP05 contexts (P05 occurence in P01).

Implementation: createIf (formatByExample ( exists(KSCHL), E1EDP05)

All works fine except when we have an input document which contains no P05 segment at all. In this case, the function exists(KSCHL) surprisingly returns a queue with one element (false), and not an empty queue. But the P05 parameter returns an empty queue, the result of formatByExample then is an error because the queues have not same length.

The funny thing is when the input document contains one P01 segment without P05 elements, and other P01 segments with P05 elements, it does NOT return that strange "false" value for the segment which does not contain P05 elements, but an empty queue (which is as expected).

I consider this a bug. In PI 7.0, the behaviour is ok, there we always have an empty queue.

We are on PI 7.11 Service Pack 07.

What can I do ? I tried several workarounds (e.g. mapWithDefault), but nothing worked.

CSY

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Christian,

its not the bug. Exist functionality is correct.

what is Exists function?

Exists function returns "true" if node exist, otherwise "false"

Till SP20 ( PI 7.0), If input is Suppress to Exists function then output is also Suppress

actually this is a bug but we are used to it and developed all the XI interfaces accordngly.

SAP has corrected the functionaly of Exists in later releases .. i can confirm this is available in SP26.

what is the new functionlaity?

If input is Suppress to Exists function then output is false. This is the correct behaviour, but unfortunately it will affect the already developed interfaces on old Exists functionality. the only solution to this is we have to rewrite the mapping.

Regarding your scenario, KSCHL-exists return false because there no P05 segments and the result coming to exists is Suppress

Regrading your second question, exists did not retun false beause there is a P05 segment in the of the P01

Cheers,

Hidayat

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Can you paste the SAP Note here for reference?

Regards,

Mark

Former Member
0 Kudos

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks for your help, problem solved now. The following works fine:

Regards,

CSY

Former Member
0 Kudos

In many cases, where the parent is not created and the child uses a formatbyexample, the standard formatbyexample creates a runtime exception since the inputs may have different queue lengths(usually when the second queue is all suppress and we have used a mapwithdefault for the first queue )

Type :- Queue function

Inputs :-

a[] :- Input to be formatted after mapped with default and removing contexts

b[] :- The queue based on  which the first queue has to be formatted

c[] :- The b[] queue itself except change its context to super-parent to make sure that there is atleast one value in the second queue.

Code:-

-------------------

public void CustomFormatByExample(String[] a,String[] b,String[] c,ResultList result,Container container){

                AbstractTrace trace =container.getTrace();

                if(c.length<=1)

                {

                                result.addValue(a[0]);

                }else

{

                                for(int i=0,j=0;i<b.length;i++)

                                {

                                                try {

                                                                if (b[i].equalsIgnoreCase("__cC_"))

                                                                {

                                                                                result.addValue(ResultList.CC);

                                                                }

                                                                else

                                                                {

                                                                                result.addValue(a[j]);

                                                                                j++;

                                                                }

                                                } catch (Exception e)

{

                                                }                             

                                }

                               

                }

}

Try using the above udf in place of standard function format by example and Let me know if this helps

Former Member
0 Kudos

Strange..i think you should provide more info on this as requested already...

Also notify in idea's place for fixing this..

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Can you provide a screenshot? Maybe we could help you more.

Regards,

Mark

Former Member
0 Kudos

Here are some screenshots to explain the problem in more detail:

the left queue shows the KSCHL field. We see that no value is present in the source data. But after the exists function is called, we have one "false" value in the queue (the middle queue), this I consider as bug. In the right queue we see that no E1EDP05 segment occurs in the source data (KSCHL is a field in this segment).

The consequence is that the formatByExample call fails with

Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Function formatByExample: Queues do not have the same number of values]

because input queue 1 has 1 value, but input queue 2 has 0 values.

What can I do as a workaround ?

CSY

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

It looks like a bug, but I can't replicate it in my system PI 7.11 SP08. Also there was a similar discussion here in sdn and I can't find the thread. Hmmmm... As a workaround, you can try using this mapping though:

Check if it is existing first before you use the formatByExample logic.

Hope this helps,

Mark

anupam_ghosh2
Active Contributor
0 Kudos

Hi Christian,

                        Java mapping can handle such problem easily. To proceed with java mapping  you need to post source XML and required sample target XML. Java mapping should be your last option, thus please wait for experts advice on the solution to this problem.

Regards

Anupam