cancel
Showing results for 
Search instead for 
Did you mean: 

Unique IF Problem

Former Member
0 Kudos

Hello Guys,

I have a unique problem with my mapping.

There is a IF condition which checks for number of line items and maps accordingly to the target.

In the else part, if the number of line items is not matched as per a field, am calling an RFC lookup to update the error status into the table and further the mapping wont work.

But unfortunately, IDOC gets created and also the table gets updated with Error status.

Scenario 1:

Number of line items = 5

Actual Line items = 5

So this test scenario should successfuly create an IDOC.

The IDOC do gets created, but also the else parts gets executed.

Scenario 2:

Number of line items = 5

Actual line items in file = 3

So, in this scenario the idoc should not be created and only should update the error status. This scenario is working perfectly.

But am not able to understand why in scenario 1, it is acting weird by executing both the IF and the else condition.

Regards

KRish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Probably the IF clause is looped.

In the first scenario you'll have a case where 5 = 5, so the idoc is created, and other cases where 1 = 5, 2 = 5,... so the error update is created.

In the second case, you'll only have 1 = 5, 2 = 5 and 3 = 5, so the error message is created, but the idoc not.

br.

Former Member
0 Kudos

Hi Nichola,

How do we know that the IF is in loop.

Here, I take the ITEM which is in 1..unbounded and making remove context.

Regards

Krish

Former Member
0 Kudos

Hi,

is you if function a graphical function?

If yes you should use an if function inside of an UDF for your requirement.

Regards

Patrick

Former Member
0 Kudos

That's quite difficult to say, as I don't know what your mapping looks like...

If you do the check on ITEM level, this will normally be the case, because the mapping will go through each ITEM (and it should).

You should perform the check on header level.

Something like

IF NOT count (line items) = coung(Actual Line items) --> throw error
ELSE proceed

As I said, I don't know what your mapping and file structures look like, so it's quite hard for me to imagine what is going on.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

use UDF to do this operation

Graphical mapping if function is a known bug

Refer SAP note 1053706 and 1061202

Thanks

Gaurav

Former Member
0 Kudos

It could be because of a bug in Graphical IF node, in some XI/PI service pack levels the IF and ELSE branches are executed regardless of whether the IF condition is TRUE or FALSE.

Please refer the SAP Note: 1061202 - Function "if" evaluates both branches

Solution:

1. Apply the corrections mentioned in the SAP Note

(or)

2. Use UDF instead of standard IF node and do the condition checking inside the UDF

Regards,

Ananth Chinnaraj