cancel
Showing results for 
Search instead for 
Did you mean: 

Condition in switch step is not getting checked

Former Member
0 Kudos

Hi Friends,

My requirement is to send the input msg to two receivers based on a condition and get the response. If the condition is true it will either goto both or anyone of the receiver.

I defined two branches in a switch step. In each branch i defined condition using XPath. Under that branchs i defined the sync send step to send the msg to receiver and get response.

If i give input that is true for any one of the receiver, it executs successfully. But if my input satisfies the condition of both branchs, instead of sending the message to two receivers it is sending the msg to only receiver.

Pls help me in resolving this issue.

Thanks & Regards,

Senthil.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Senthil,

Pease be aware that only "one" condition can be valid.

Why not add another entry to your switch and check on Both values to be true.

This way you make a If....then.....else if.....then....else construction.

Greets

Former Member
0 Kudos

Senthil,

Please confirm your process looks like this:


    /-- item name CE 'X' -- [send] --\    /-- item name CE 'Y' -- [send] --\
---                                    --                                    ---
    \--------------------------------/    \--------------------------------/ 

Or, if you follow patrick's suggestion


     /-- item name CE 'X' AND item name CE 'Y' -- [send] -- [send] --\
    /                                                                 \
---   -- item name CE 'X' -- [send] ---------------------------------   ---
    \                                                                 / 
     \---------------------------------------------------------------/

Kind regards,

Koen

Former Member
0 Kudos

My process is exactly what u have mentioned. Two switches, each has a branch. One switch for 'X' and the other for 'Y'.

My Item Name has more than one occurences. So instead of giving condition to that field, i gave to a field which has exactly one occurence, and it is working fine. It is executing in two switches and send the response to two receivers.

But as per my requirement i need to use Item Name for condition...

Pls guide me in solving this issue.

Thanks.

Regards,

Senthil.

Former Member
0 Kudos

Senthil,

Please post a sample message and the exact contents of the expression editor for the switch that's not working.

Kind regards,

Koen

Former Member
0 Kudos

My sample payload:

<Header>

<DocType>TA</DocType>

<SalesOrg>Z999</SalesOrg>

<DistriChannel>Z9</DistriChannel>

<Division>Z9</Division>

</Header>

<PONumber>12345</PONumber>

<ItemDetails>

<Item>

<ItemName>Z-990</ItemName>

<Plant>Z999</Plant>

<ItemQty>4</ItemQty>

</Item>

<Item>

<ItemName>Z-991</ItemName>

<Plant>Z999</Plant>

<ItemQty>6</ItemQty>

</Item>

</ItemDetails>

Former Member
0 Kudos

<Header>

<DocType>TA</DocType>

<SalesOrg>Z999</SalesOrg>

<DistriChannel>Z9</DistriChannel>

<Division>Z9</Division>

</Header>

<PONumber>12345</PONumber>

<ItemDetails>

<Item>

<ItemName>Z-990</ItemName> > Fall into first switch, If ItemName = "Z990" send it 'X' receiver.

<Plant>Z999</Plant>

<ItemQty>4</ItemQty>

</Item>

<Item>

<ItemName>Z-991</ItemName>> Fall into second switch, If ItemName = "Z991" send it 'Y' receiver.

<Plant>Z999</Plant>

<ItemQty>6</ItemQty>

</Item>

</ItemDetails>

Since the payload satisfies both conditions, it shud send both but it is sending only to 'X'.

If i use <PONumber> for cond, say if PONumber = 12345 in both the branchs, it is sending output two receivers....

Pls let me know if u require any more info.

Thanks & Regards,

Senthil.

Former Member
0 Kudos

Please also provide the exact expression as entered in the condition for your switch.

Former Member
0 Kudos

Skeleton of my BPM sceanrio:

/---Switch1--


\

Start-----Receiver ->Fork>----| -


End

*\----- Switch2----


/*

Under each switch i'll have a send step.

For Condition,

1) I created a condition variable. (say "var")

2) Assigned XPath exp to that var. (var = /p1:PO_MT/ItemDetails/Item/ItemName)

3) In the cond editior i have given the cond. ( var = "Z-990")

I am using PI 7.1.

Thanks & Regards,

Senthil.

Former Member
0 Kudos

Sorry for the typo.

The switches are in the branches of Fork.

Former Member
0 Kudos

Is var a multiline variable?

Former Member
0 Kudos

No it is not a multiline variable...

Former Member
0 Kudos

Senthil,

This means that var can only hold 1 value. In this case, it will be populated with the first value in the xpath query /p1:PO_MT/ItemDetails/Item/ItemName, which is Z-990. Therefore, the second switch condition (var = 'Z-991') will never resolve to true.

To resolve this, make var a multiline variable and change the expressions to var CE 'Z-990' resp var CE 'Z-991'

Kind regards,

Koen

Former Member
0 Kudos

Thanks a lot, Koen....

I made it as multiline and it is working fine.

You were very helpful and thanks once again..

Answers (7)

Answers (7)

Former Member
0 Kudos

Senthil,

Why do you use a Switch here in this case.

You can also include your created "var" in the async "send Context" as a parameter and do the condition determination in the Integration directory.

There you use in the context editor "ProcessStep" variable and from here on determine the receivers.

In this case you make your BPM as clean as possible.

Greets.

Sorry for my late reply, i was out yesterday.

Former Member
0 Kudos

Senthil,

Do you use a n:1 mapping before getting into the switch.

It seems like you only refer to the 1st entry in the payload.

else make a small screencapture of the BPM used.

greets

Edited by: Patrick Pot on Feb 19, 2009 3:14 PM

Former Member
0 Kudos

Senthil,

In my opinion you create a loop over the Items and ItemName would be the condition. But Where is your destination determined.

If you do use a loop then for each Item the ItemName would be taken as reference. But there is no 'x' or 'y' in there.

What is the reference PER line towards the send step.

<ItemDetails>

<Item>

<ItemName>Z-990</ItemName>

<Plant>Z999</Plant>

<ItemQty>4</ItemQty>

</Item>

<Item>

<ItemName>Z-991</ItemName>

<Plant>Z999</Plant>

<ItemQty>6</ItemQty>

</Item>

</ItemDetails>

Greets

Former Member
0 Kudos

My destination('X' or 'Y') will be determined by send step (will use Receiver Determination of ID). Based on the sender interface i created diffrentiate receiver determinations. So Send step will use right one.

Thanks & regards,

Senthil.

Former Member
0 Kudos

Senthil,

Can you please copy in your condition statement.

Because if i create a multiline mapping and loop over the entries all works well.

i use the following construction

item

-- Name

-- Client

item

-- Name

-- Client

when creating the branch (par for each) and create a switch in there it works.

item[0]:Name equals 'y'

item[1]:Name equals 'x'

What in your case is different.

greets

Former Member
0 Kudos

Hi Senthil,

Instead of switch step, Use a fork which splits your message and goes to two branches.

Now use send step with condition as usual.

Hope this works.

Regards,

Pranav.

Former Member
0 Kudos

Senthil,

As prateek indicates, only one of the branches will be executed.

You can resolve this in several ways:

1: Create a switch with one branch containing one send step for condition x and another branch with two send steps for condition y

2: Create two switch statements after each other: one that sends to receiver a for condition x, one that sends to receiver b for condition y.

Kind regards,

Koen

Former Member
0 Kudos

Thanks Prateek and Koen.

However, i am getting the same problem again. I defined two switches one after another. One switch is for say condition X and the other for condition Y. But, It is not sending the msg to both the receivers if i give payload that will be true for both the switches.

Pls tell me where i am going wrong..

Thanks again.

Regards,

Senthil.

Former Member
0 Kudos

Senthil,

Can you give more details on the expression you enter in the condition for both switches and the behavior you see now?

Kind regards,

Koen

Former Member
0 Kudos

I have used XPath for condition.

My incoming message has header and many line items.

Condition for first switch is, item name = 'X', under that branch i'll send the msg to first receiver.

Simillary, for second switch cond. is, item name = 'Y', and under that branch i'll send the msg to second receiver.*

My payload has both the items (X & Y). For this payload it has send the output to two receivers but it is sending the output only to Item Y's receiver, so it means the condition i havr defined for first switch is either not executing or returning false.

Let me know if you any queries on this.

Thanks.

Former Member
0 Kudos

Senthil,

I suppose that item name is a multiline element. Instead of using '=' for the comparison, try the same expression but then with 'CE' (see also [saphelp - Define a Condition|http://help.sap.com/saphelp_nwpi711/helpdata/en/44/15981541f7648ee10000000a1553f7/frameset.htm]).

Kind regards,

Koen

Former Member
0 Kudos

I tried with the changes suggested by you,Koen. But still getting the same problem. Still only one branch is executing, dont know where i am going wrong!!

Thanks & Regards,

Senthil.

Former Member
0 Kudos

>

> Still only one branch is executing, dont know where i am going wrong!!

This is also what you would expect. In a switch, always only one (the first one for which the condition matches) gets executed. Can you clarify?

Kind regards,

Koen

former_member181985
Active Contributor
0 Kudos

have you reimported the IP in configuration after the changes to IP.

Former Member
0 Kudos

Actually it is still executing only one switch case...

Sorry for the confusion.

Regards,

Senthil.

Former Member
0 Kudos

Did you also verify that, after making the changes, the process was activated successfully? Check the status in transaction sxi_cache. This should be '0'.

Regards,

Koen

Former Member
0 Kudos

I have reimported the changed IP into ID. but still the problem continues...

Thanks & Regards,

Senthil.

Former Member
0 Kudos

Yes Koen, i did chk that. The activation was successful & the return code is 0....

Thanks & regards,

Senthil.

prateek
Active Contributor
0 Kudos

Switch statement is like "if" statement. If one branch is successful, other won't get executed. Better to put both the conditions together with an OR statement.

Regards,

Prateek