cancel
Showing results for 
Search instead for 
Did you mean: 

1:n Mapping with Conditions

Former Member
0 Kudos

Hello everybody,

I am using PI 7.31 and have to implement the following scenario:

Source is an .xml File containing lots of IDOCs.

Target shall be single Messages containing only one IDOC, in some cases two. But not every IDOC in the source message shall be created as target message - only those, that meet certain conditions shall be transformed into a target message. And: I do not know how many IDOCs will be contained in the source file.

I have tried to display my requirement graphically:

I have already implemented a 1:n MultiMapping which works fine when there are no conditions involved (a source message containing five IDOCs is split into five single target messages correctly).

To test for my conditions, I have created a UDF which returns true if the conditions are met. I have put this UDF before a createIf standard function. If the first IDOC in the source message fulfills condition A, one target message is created (correct behaviour). However, if the second IDOC in my source message also meets condition A (or condition B - that does not matter), a second target message is not created. Additionally, if the first IDOC in the source message does not meet any condition, PI stops message processing with error: Split message created no messages.

So, I guess I have to implement some kind of loop to test every single IDOC in my source message for the conditions and prevent PI to stop message processing when the first IDOC does not meet any condition. But how can I do this?

Is it possible to use UDF or maybe Java mapping? I would very much like to avoid using ccBPM.

I appreciate any help!

Thanks a lot,

Miriam

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Miriam, try inserting a context change after each source IDoc in order to to invoke your UDF for each IDoc in the soruce.

In order to avoid the error in case no IDoc meets the condition, there are plenty of threads on this issue here on SCN. Search for the error message and you will find a solution

Regards, Martin

Former Member
0 Kudos

Hi Martin,

your response sent me on the right track: I changed the context for the fields I was testing in my UDF to the context of the complete message (root element) and now the UDF is evaluated for each single IDOC. The error in case that the first IDOC does not meet the condition is solved with this approach as well.

If no IDOC meets the condition, the file won't be transferred to PI due to a condition in the Receiver Determination.

So, all works fine now! Thanks a lot!

Miriam

Answers (2)

Answers (2)

nabendu_sen
Active Contributor
0 Kudos

Hi Miriam,

After the IDoc source node, add 'mapWithDefault' and 'removeContext'. Write the UDF with "All values of the Queue". In your If Logic where you are validating your condition, add <result.addValue("");>  before end of If block. Do not need to mention else because you dont need to perform anything but just to skip. Remove 'createIf' and add 'SplitbyValue' after the UDF.

former_member201264
Active Contributor
0 Kudos

HI Miriam,

Try with RemoveContext and SplittByValue and CollaspeContext in your condition to IDOCs.

Try with RemoveContext and SplittByValue in your condition to IDOC's Fileds.

keep posting to solve the issue.

Regards,

Sreeni.