on 11-10-2005 6:32 PM
I'm stuck with this mapping issue and cannot find a way out on my own. It seems rather simple to look at.
In my source file I have a REF tag with several qualifiers(field-type) such as AB, BC, CD, etc. I want to map the value stored in AB to my target field. It's quite possible that AB could be missing at times and in that case I need to map "".
If I use if(with else), with else mapping to "" it maps the next BC value 'cause there seems like no way to set 'keep suppress values' unlike statement if(without else). But if I use if(without else) it gives an error if AB is missing.
Right now my logic is I compare type = 'AB' using stringEquals and if true, then target field = str1. And before I map to target field I use removeContext and splitByValue. I have keeps = false. But this throws an error for the second item set since AB is missing. Only works when all Item nodes have AB present.
Can someone please tell how I can come out of this mess?
Here's my source file -
Source: x_MT
<?xml version="1.0" encoding="UTF-8"?>
<ns:x_MT xmlns:ns="urn:abc.com/IAM">
<Header>
<Label>H1</Label>
<str>00</str>
</Header>
<Item>
<REF>
<type>AB</type>
<str1>140152</str1>
</REF><Item>
<REF>
<type>BC</type>
<str1>562</str1>
</REF><Item>
<REF>
<type>CD</type>
<str1>345</str1>
</REF><Item>
</Item>
<Item>
<REF>
<type>BC</type>
<str1>562</str1>
</REF><Item>
<REF>
<type>CD</type>
<str1>345</str1>
</REF><Item>
</Item>
</ns:x_MT>
Hi,
You can try the Java function assertNotNull(REF) before going for stringEquals. I have not tried that, though. You may also try any other way to check if the value is Null instead of space or "".
Cheers,
Bhanu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Parimala,
Use standard Exists function to check if source value exists or not.
sourcevalue->exists->(true or false)ifwithelse->ValueMapping->target.
in ifwithelse (requires three inputs)
1.if - output of exists function
2.then - source value
3.else -constant, say " "
the output of ifwithelse can be used as a input for your value mapping logic(which you have explained in your first post).
http://help.sap.com/saphelp_nw04/helpdata/en/db/83f7b88528424c9113b15d5e0fb516/content.htm
Regards
Anand
Anand,
It seems like Exists only checks if a node exists not the node value. When I use this, I get true whether the type is AB, BC or CD. It seems like its checking only if node type exists.
I pass type = AB to stringEquals which serves as input to Exists which then is paased to ifwithelse like you mentioned. When I display queue shows 5 true(s) between the 2 items.
I may need a little more assistance.
thanks,
Pam
Hi Parimala,
Directly pass your source field to exists function.
sourcevalue->exists->(true or false)ifwithelse->'ValueMapping'->target.
in ifwithelse (requires three inputs)
1.if - output of exists function
2.then - source value
3.else -constant, say " " (space)
Define a adavanced user defined function say 'ValueMapping'(input for this is ifwithelse output) with one input parameter.
for(int i = 0; i < a.length; i++ ){
if(a[ i ].equalsIgnoreCase(" ")||
a[ i ].equalsIgnoreCase("") ) {
result.addValue(" ");
}else{
result.addValue(a[ i ]);
}
}
Also set the context of your source field to x_MT.
Regards
Anand
Message was edited by: Anand Torgal
No you don't need any specieal imports...
it works fine for me...
Did you choose create Adavanced user defined function or the simple user definede function...
You need to create adavanced user defined function...
check this and remove hash(#) while copying.
for(int i = 0; i < a.length; i++ ){
if(a[#i#].equalsIgnoreCase(" ")||
a[#i#].equalsIgnoreCase("") ) {
result.addValue(" ");
}else{
result.addValue(a[#i#]);
}
Regards
Anand
Message was edited by: Anand Torgal
Anand, sorry to bug you but I get syntax error with cut and paste...after removing #. By the way I did choose advanced function with one argument.
I must be doing something really stupid.
Source code has syntax error: /usr/sap/XI0/DVEBMGS70/j2ee/cluster/server0/./temp/classpath_resolver/Map0ee86b50523811dac6e300306e4b43ce/source/com/sap/xi/tf/_x_to_y_.java:625: illegal start of expression public static void main(String[] args) throws Exception{/!_$ClNRep_/_x_to_y_ st = new /!_$ClNRep_/_x_to_y_(); st.checkParams=false;st.testExecute(args); } ^ /usr/sap/XI0/DVEBMGS70/j2ee/cluster/server0/./temp/classpath_resolver/Map0ee86b50523811dac6e300306e4b43ce/source/com/sap/xi/tf/_x_to_y_.java:626: ';' expected } ^ /usr/sap/XI0/DVEBMGS70/j2ee/cluster/server0/./temp/classpath_resolver/Map0ee86b50523811dac6e300306e4b43ce/source/com/sap/xi/tf/_x_to_y_.java:627: '}' expected ^ 3 errors
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.