cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal with 0...n or 1...n mappings?

Former Member
0 Kudos

Hi all,

I'm relatively new to BPM. I've already made several processes that are working fine. However, I'm now stuck because, for the life of me, I'm not able to understand how to deal with data mappings of nodes of a cardinality greater than 1...1.

I'm used to dealing with 0...n inputs of Web Services in Webdynpro Java and CAF Application services, using java code... but I just don't get how to deal with these in a BPM data mapping scenario.

Let's say you have a Web Service whose input is a node called "Employee", where you can add n Employee objects, like this:


   Employee (0...n)
      FirstName: String
      LastName: String

How do you:

1- map a 0...n context node from a Web Dynpro or Web Service output, already containing several employees, into this Employee 0...n WS input node?

2- map a 0...n context node from a Web Dynpro or Web Service output, containing NO employees, into this Employee 0...n WS input node, without getting an error and the BPM crashing because it says the employee element is not found?

Hopefully someone can help me with this, because I'm about to go the way of calling the web service n times, one employee at a time, instead of one time with a Employee object with n registries in it.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Alain,

You don't mention your release/support pack of NWDS?

As you mention you are a beginner... just to check where you are on your basic knowledge:

Have you been looking at the Built-in mapping functions i.e. when you double click on the mapping to edit it?

If you are on the current 7.3 release you should find functions such as:

Generic > isSet or nilled -- to help with checking if the array is empty before trying to pass it

Generic > filter, get, sort, count --- to help with mapping across an individual object of your array

You also have the Looping options in the Process Step properties to pass one object at a time from your array to the task.

Or if you want to pass the whole array to your web service you can either use the deep copy if you are mapping like to like or the n:m copy (i.e. map at the parent level, and then you can select which sub elements to map) if not. If you need to adjust this to cope with your nilled scenario double-clicking on the mapping relationship line will take you into the editor when you can add additional functions.

Otherwise, give us some more information on how you are attempting to define your mapping relationship and we'll see if we can help.

Regards,

Jocelyn

Former Member
0 Kudos

Hi Jocelyn!

Right! i forgot the NWDS version... I'm working with 7.2 SP 06.

Thank you for your reply, I was successfully able to pass the whole array to the input of the Web Service, using the deep copy.

Now I just need to deal with the nill scenario: how to deal with this, when the Employees node has no employees in it.

After I implemented the deep copy you suggested, when the Employees node has no employees in it, I get this weird error in the log:

while trying to invoke the method java.lang.Object.getClass() of an object loaded from field com.sap.mdm.ws.data.crud.SearchRecordsOperation._Employees of an object loaded from local variable 'this'

[EXCEPTION]

java.lang.NullPointerException: while trying to invoke the method java.lang.Object.getClass() of an object loaded from field com.sap.mdm.ws.data.crud.SearchRecordsOperation._Employees of an object loaded from local variable 'this'

commit():Caught exception while dispatching onCommit events: java.lang.NullPointerException

at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:881)

I'm guessing this nullpointer is due to input Employees node being empty. How can I can correct this?

Just to be clear, I don't want to avoid the WS call when the Employees node is empty, because when that happens the WS still returns a valid answer that I need to process... I just want to avoid this error so that the BPM can continue...

Edited by: AlainMore on Dec 14, 2011 4:21 PM

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Alian,

You can check for the null condition in your WD code when triggering the WS.

Regards,

Shilpa

Former Member
0 Kudos

Hi Shilpa,

Actually the WD and the WS are two separate steps in the BPM. First the WD is run and with its "output" y feed the WS's input. How could I validate the null condition in the WD so that the WS doesn't return me that error?

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Alian,

Do you trigger the WS through model in WD?

Regards,

Shilpa

abhijeet_mukkawar
Active Contributor
0 Kudos

I am not sure if this fulfils your purpose, but null element is not accepted in WS input, so, perhaps, if WD output is null, you can add an empty element to the node with all values "".. This will ensure WS gets an element.

-Abhijeet

Former Member
0 Kudos

No Shilpa, I trigger it in a separate step in the bpm, after the Web Dynpro finishes.

Former Member
0 Kudos

Hi Abhijeet,

i think i should have mentioned this earlier. My Employee node is inside another node. So, the actual input structure of the WS is this:


InputValues (1...1)
   Employees (0..n)
      FirstName: String
      LastName: String

This scenario works OK in BPM when mapping a 0..n node using deep copy as Jocelyn explained, but I still doesn't work if I want to pass an empty (not null) Employees array.

If I go to the WS Navigator and run this WS with the following parameters, it runs ok (I get an output message saying no employee was selected, which is how it should work):


InputValues -  "Is null" checkbox not activated.
   Employees - "Skip" checkbox not activated
      FirstName - "Skip" checkbox activated
      LastName - "Skip" checkbox activated

However, if instead of activating the checkbox of, say, "FirstName", I enter a "" value, I get an error from the WS saying that's not a vaild first name, which is also how it should work.

In java code, I would just pass an empty InputValues object to the WS, but I'm not sure how to do this in a BPM without it being considered null, and without having to set on of its String-child values to "".

Do you know how to achieve this?

mubeenmalik
Explorer
0 Kudos

Hi Abhijeet,

Is it possible to change the cardinality of a data object in process context from 1:1 to 0:1?

regards,

Answers (3)

Answers (3)

Former Member
0 Kudos

Not sure how complicated your mapping is, append(one of 3 options) should solve it, else take the size of that node and use iteration (index of) and append only if the value is not null.

Thanks

Manish

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi Alain,

Please check below thread it precisely addresses the same:

You can copy paste the XSD schema mentioned by Oliver in the thread and re-engineer it to check how it is created.

-Abhijeet

Former Member
0 Kudos

Hi Abhijeet,

That link seems helpfull, however, since I'm trying to call a WS, how can I modify the input XSD without breaking the whole model?

Shilpa_Shankar
Developer Advocate
Developer Advocate
0 Kudos

Hi Alain,

To map the 0n cardinality of WD context node to 0n multiplicity in WSDL follow these steps:

1. When creating new WSDL, you have input parameters. Add complext type say Employee. Double click on Employee complex type and add elements.

2. In the input parameters of WSDL add element which you have created as a complex type. You need to click on brose under type and select the complex type Employee.

3. This step is important. Set the multiplicity of the input parameter as 11 and the mutiplicity of complex type as 0n.

Then you can continue with mapping in BPM process.

In your webdynpro code you need to add teh elements to arraylist and then bind it to the input parameter of WS when calling the WS.