cancel
Showing results for 
Search instead for 
Did you mean: 

greater function(Arithmetic) not working in graphical mapping

venkatasap
Participant
0 Kudos

Hi SapAll.

in an Idoc To File Interface i have got a requirement where i need to compare occurance of two child segments G02,G02 Under parent Segment G01 and then determine the occurance of target Record Structure.

the IDOC structure is G01

G02

G03

MAPPING IS like G01->count->

greater(Arithmetic Function) IF THEN G02 else GO3 ->TARGET RECORD

G02->count->

when i use Equals(Boolean Function) then it is comparimg occurance of two child and if equals then created target node as per the occurance of source node G02 but when i use Greater(Arithmetic),its not working .

can any one help me how i can achieve this ?

regards.

Varma

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

If you are in XI3.0 then go through this blog..

/people/thorsten.nordholmsbirk/blog/2006/08/25/new-arithmetic-and-statistical-functions-in-message-mappings-in-sp18

Otherwise write an UDF with 2 input parameters and pass "G01 & 2->count->UDF"

if ( G01 > G02 )

{

return "true";

}

return "false";

now use if function and pass the output of UDF and based on that you map G01 and G02 to the target.

venkatasap
Participant
0 Kudos

Hi mr Sarvesh Singh.

i did as you said and tested in the message mapping but still iam getting the error as

====================================================================

= Root Exception ===================================================

====================================================================

Thrown:

com.sap.aii.utilxi.swing.framework.FrameworkException: Internal problem occurred

at com.sap.aii.utilxi.swing.toolkit.ExceptionDialog.init(ExceptionDialog.java:126)

at com.sap.aii.utilxi.swing.toolkit.ExceptionDialog.<init>(ExceptionDialog.java:98)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:206)

at javax.swing.JTabbedPane.fireStateChanged(Unknown Source)

at javax.swing.JTabbedPane$ModelListener.stateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndex(Unknown Source)

at com.sap.plaf.frog.FrogTabbedPaneUI$MouseGetter.mouseReleased(FrogTabbedPaneUI.java:245)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at com.sap.aii.utilxi.swing.toolkit.Guitilities$EventProcessor.dispatchEvent(Guitilities.java:320)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

at com.sap.aii.ib.bom.flib.FunctionLibrary.sortFunctions(FunctionLibrary.java:150)

at com.sap.aii.mappingtool.funclib.FunctionLibraryEditor.prepareSave(FunctionLibraryEditor.java:445)

at com.sap.aii.mappingtool.fwutil.api.ViewUtil.prepareSave(ViewUtil.java:110)

at com.sap.aii.ibrep.gui.mapping.xitrafo.XiMappingView.prepareSave(XiMappingView.java:271)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:200)

... 27 more

====================================================================

== Content from the LogHandler =====================================

====================================================================

#41 13:32:04 [AWT-EventQueue-2] FINE AutoLog.created.java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

at com.sap.aii.ib.bom.flib.FunctionLibrary.sortFunctions(FunctionLibrary.java:150)

at com.sap.aii.mappingtool.funclib.FunctionLibraryEditor.prepareSave(FunctionLibraryEditor.java:445)

at com.sap.aii.mappingtool.fwutil.api.ViewUtil.prepareSave(ViewUtil.java:110)

at com.sap.aii.ibrep.gui.mapping.xitrafo.XiMappingView.prepareSave(XiMappingView.java:271)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:200)

at javax.swing.JTabbedPane.fireStateChanged(Unknown Source)

at javax.swing.JTabbedPane$ModelListener.stateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndex(Unknown Source)

at com.sap.plaf.frog.FrogTabbedPaneUI$MouseGetter.mouseReleased(FrogTabbedPaneUI.java:245)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at com.sap.aii.utilxi.swing.toolkit.Guitilities$EventProcessor.dispatchEvent(Guitilities.java:320)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

#40 13:32:04 [AWT-EventQueue-2] DEBUG AutoLog.created.java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

#39 13:32:04 [AWT-EventQueue-2] FINE AutoLog.created.com.sap.aii.utilxi.swing.framework.FrameworkException: com.sap.aii.utilxi.swing.framework.FrameworkException: Internal problem occurred

at com.sap.aii.utilxi.swing.toolkit.ExceptionDialog.init(ExceptionDialog.java:126)

at com.sap.aii.utilxi.swing.toolkit.ExceptionDialog.<init>(ExceptionDialog.java:98)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:206)

at javax.swing.JTabbedPane.fireStateChanged(Unknown Source)

at javax.swing.JTabbedPane$ModelListener.stateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndex(Unknown Source)

at com.sap.plaf.frog.FrogTabbedPaneUI$MouseGetter.mouseReleased(FrogTabbedPaneUI.java:245)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at com.sap.aii.utilxi.swing.toolkit.Guitilities$EventProcessor.dispatchEvent(Guitilities.java:320)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

at com.sap.aii.ib.bom.flib.FunctionLibrary.sortFunctions(FunctionLibrary.java:150)

at com.sap.aii.mappingtool.funclib.FunctionLibraryEditor.prepareSave(FunctionLibraryEditor.java:445)

at com.sap.aii.mappingtool.fwutil.api.ViewUtil.prepareSave(ViewUtil.java:110)

at com.sap.aii.ibrep.gui.mapping.xitrafo.XiMappingView.prepareSave(XiMappingView.java:271)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:200)

... 27 more

#38 13:32:04 [AWT-EventQueue-2] DEBUG AutoLog.created.com.sap.aii.utilxi.swing.framework.FrameworkException: Internal problem occurred

#37 13:32:04 [AWT-EventQueue-2] ERROR com.sap.aii.utilxi.swing.toolkit.ExceptionDialog: Throwable

Thrown:

java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.

at com.sap.aii.ib.bom.flib.FunctionLibrary.sortFunctions(FunctionLibrary.java:150)

at com.sap.aii.mappingtool.funclib.FunctionLibraryEditor.prepareSave(FunctionLibraryEditor.java:445)

at com.sap.aii.mappingtool.fwutil.api.ViewUtil.prepareSave(ViewUtil.java:110)

at com.sap.aii.ibrep.gui.mapping.xitrafo.XiMappingView.prepareSave(XiMappingView.java:271)

at com.sap.aii.ibrep.gui.mapping.xitrafo.TabbedPane$TabChangeListener.stateChanged(TabbedPane.java:200)

at javax.swing.JTabbedPane.fireStateChanged(Unknown Source)

at javax.swing.JTabbedPane$ModelListener.stateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.fireStateChanged(Unknown Source)

at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndexImpl(Unknown Source)

at javax.swing.JTabbedPane.setSelectedIndex(Unknown Source)

at com.sap.plaf.frog.FrogTabbedPaneUI$MouseGetter.mouseReleased(FrogTabbedPaneUI.java:245)

at java.awt.Component.processMouseEvent(Unknown Source)

at javax.swing.JComponent.processMouseEvent(Unknown Source)

at java.awt.Component.processEvent(Unknown Source)

at java.awt.Container.processEvent(Unknown Source)

at java.awt.Component.dispatchEventImpl(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)

at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)

at java.awt.Container.dispatchEventImpl(Unknown Source)

at java.awt.Window.dispatchEventImpl(Unknown Source)

at java.awt.Component.dispatchEvent(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at com.sap.aii.utilxi.swing.toolkit.Guitilities$EventProcessor.dispatchEvent(Guitilities.java:320)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

can you help me in this.

regards.

Varma

Former Member
0 Kudos

Which system you are using, XI3.0 or PI7.1 and what is the SP level?

Use below UDF code.. where a & b are two input parameters for G01 & G02.

int  n1 = Integer.parseInt(a);
int  n2 = Integer.parseInt(b);

 if(n1 > n2)
{
return "true";
}
return "false";

venkatasap
Participant
0 Kudos

Hi Sarvesh.

i also used the above code but its still not working,i mean iam still getting the same error.

iam using PI 7.11.

will be waitng for your response.

regards.

Varma

Former Member
0 Kudos

From the error it seems you are not passing the correct values to the UDF. Just to test the UDF pass smoe constant values and see if it works. Once you make sure the UDF is working fine look at your original source G01 & G02 and set the context to IDOC or use RemoveContext just after G01 & G02 and then pass these values to count function.

venkatasap
Participant
0 Kudos

Hi Rodrigo Alejand & Sarvesh Singh.

it seems like the problem is not with Greater(Arithmetic) Function ,the problem is with IFThenElse(Boolean Function).

i also tested with the UDF for greater instead of greater(Arithmatic) Function but still the same result.

as per the condition defined in Greater (Arithmatic or User defined Function) the IfThenElse conditon should create Target Record Structure for multiple times as per the occurance of G02 or G03 in the Source IDOC but its creating the target Record only for one time.

but if replcaed the IFThenElse with IF Then (Boolean) and also changed the greater function so as to check if the IF Then can create target record structure for multiple times and it was creating target structure for multiple times .

so finally i observed that if i use the IfThen Else (Boolen)condition with greater function ,when i click on display queue of If Then Else Function it is displaying IF:in 0 as 9 rows,If:in1 as 2 rows with true value,If:in 2 as 8 rows,If:out as 2 rows(but it should display if out as 9 rows(as per the condition defined in greater).

so can any of u describe me the reason why the IfThenElse(Boolean) Condition is unable to produce the target node for multiple times as like If then is creating.

will be waiitng for the good answer.

regards.

Varma

Former Member
0 Kudos

> it seems like the problem is not with Greater(Arithmetic) Function ,the problem is with IFThenElse(Boolean Function).

No, IFThenElse function's behaviour is correct. It will pass only those many output values as may true values will be there. Since in this particular case you will ALWAYS get only 1 true or false therefore there will be only one output. So, there is nothing wrong.

For this particular case you have to write an UDF where you will first check if G01 > G02 then loop on G01 and return all values else return G02.. need not to use the IfThenElse function here..

venkatasap
Participant
0 Kudos

Hi Sarvesh.

if so,can you please provide me the code for UDF to populate the target node for multiple times as per hte occurance of either G02 or G03 based on the specified condition.

will be waiitng for a good answer.

regards.

Varma.

Former Member
0 Kudos

Look into this picture for mapping.. and set your last 2 input parameters (c & d ) with segments G02 & G03 (in picture I have mapped G01 & G02 to c & d input parameters).

http://www.flickr.com/photos/23639237@N02/4986310396/sizes/z/in/photostream/

and here is the UDF code..

create the UDF with 4 input parameters (a,b,c & d) and set the cache as "Queue".

int n1 = Integer.parseInt(a[0]);
int n2 = Integer.parseInt(b[0]);
 
 if(n1 > n2)
{
	for(int i = 0; i <c.length; i++)
	{
	result.addValue(c<i>);
	}
}
else
	{
	for(int j = 0; j <d.length; j++)
	{
	result.addValue(d[j]);
	}
	}

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

Hi,

i think that no UDF is neccessary, your mapping should be

G01>Count>(greater(G02>Count)>IFTrue(G03)--->ELSE (G04)

all context of the fields must be setted to IDOC.

by way you will have many occurance in the target node as per as the number of the occurrance of G03 or G04

Former Member
0 Kudos

>

> Hi,

> i think that no UDF is neccessary, your mapping should be

>

> G01>Count>(greater(G02>Count)>IFTrue(G03)--->ELSE (G04)

>

> all context of the fields must be setted to IDOC.

>

> by way you will have many occurance in the target node as per as the number of the occurrance of G03 or G04

Don't think just try it.. It will not work.

Answers (2)

Answers (2)

RKothari
Contributor
0 Kudos

Hi,

From the error description >> java.lang.IllegalArgumentException: the length 0 of the array 'sortedFunctionKeys' is not equal to the number 1 of functions.<< it seems that u have created the UDF in Definition tab and not Functions tab in the message mapping. When a udf is created in the Definition tab directly it does not get reflected in Functions tab. And hence the error.

Try creating the UDF in Functions tab and check if number of UDFs in Definition and Functions tab are same.

Regards,

Rahul

Edited by: Rahul on Sep 13, 2010 1:13 PM

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

the IDOC structure is G01

G02

G03

MAPPING IS like G01->count->

greater(Arithmetic Function) IF THEN G02 else GO3 ->TARGET RECORD

G02->count->

your mapping should be

G01>Count>Greater (count G02)--> IF THEN G02 else GO3 ->TARGET RECORD

but remember to change the context (to IDoc) of G01 and G02 . to do this in the mapping editor press right click>Context node>Name of the IDoc

if you dont do this the count of both will be always 1.

refer to

/people/rohit.kalugade/blog/2009/02/09/context-and-queue-in-message-mapping-udf-150-part2

/people/rohit.kalugade/blog/2008/12/08/context-and-queue-in-message-mapping-udf

Edited by: Rodrigo Alejandro Pertierra on Sep 10, 2010 10:33 AM