on 12-13-2011 10:25 PM
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.