on 05-08-2007 4:32 PM
Hi
I am mapping from a IDOC to a flat structure.
Source side segments can repeat - based upon some other criteria like highest date - mapping is done to the target fields.
Problem is - sometimes the IDOC tags for some fields on which I have mapping - is not present - as in Source SAP - this field is blank.
In the mapping - sort by key is failing - as date field ( key) and the source field might be different in queue length - in such cases where source side xml tag is missing.
I know - node function if exists is there - and a empty tag can be created if case xml tag is missing - but I can not use that as a lot of context is used. I really can not go to the lowest context to check if that field is present or not.
Does anybody have any quick java code for creating empty tags if not present or any other solution for this problem?
Hi Bhavesh,
Normally mapWithDefault would work .
But as from my message above, I have already tried this and this does not work if we are using mapWith Default, Context changes , Sort by key for a particular field.
Need to sort based on values on a higher context.
Empty nodes cause an issue as Queues have different lengths.
Also, mapWithDefault has to be applied to every field. There should be a better way if you have 100s of fields on the source message.
Empty tags (nodes) should be added (filled) in one go for all fields.
Hoping a quick response.
Thanks,
Sudhin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is not working .
If the node is not in source XML / deleted, then this UDF does not work.
However, what I'm looking for is an empty tag/node to be generate d(by java mapping / UDF) so that I do not get exceptions in mapping.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi-
Try this
public String Check(String str){
if (str == null)
return "XXXX";
else
return str;
}
Here str is the string you are getting from Idoc
XXX is the value which you want to assign if the field is empty.
Let me know if you want any further help in this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sai / Satish,
Thanks for your input.
Unfortunately - if the Tag is not present at all in the source side - these UDFs are not returning tags
I want the an empty tag to be populated for all source fields where the tag do not exists.
Tried exists , map with default etc - no avail. Probably java mapping is the solution
Please help
Thanks
Sudhin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sudhin,
You write this UDF at context level with input 'a' and 'b'. This function checks whether a particular value is present in a context. If it is present then a value 'true' is passed, otherwise false
boolean found = false;
for (int i=0;i<a.length;i++) {
if (a<i>.equals(b[0])) {
found = true;
break;
}
}
if (found == true)
result.addValue("true");
else
result.addValue("false");
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
a is the input string, Use a simple UDF
public String Check(String a,Container container){
if (a==null)
return "";
else return a;
}
Regards,
Sai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.