on 02-22-2008 3:47 PM
Hi.
I've done a mapping with a java-function and when I get mutipel elements I only get the first node with elements and for the sacond element I get just the node wirth no elements in the target.
Ocurrences in source element are 0-unbounded
Target node are 0-unbounded and the elements in the target node are 0-1.
In the source element I get a textstring where the attributes and the with belonging data are splitted up by a space.
public void serachstring (String[] a,String[] b,String[] c,ResultList result,Container container){
int start_ind = 0,
end_ind = 0,
string_length = 0;
String item_string = "";
try {
start_ind = a[0].indexOf(b[0]);
if (start_ind<0) {
item_string = "No Value Present";
result.addValue(item_string);
return;
}
}
catch (StringIndexOutOfBoundsException ex){
}
string_length = b[0].length();
start_ind = start_ind + string_length;
try {
end_ind = a[0].indexOf(c[0],start_ind);
}
catch (StringIndexOutOfBoundsException ex){
}
try {
item_string = a[0].substring((start_ind), (end_ind)) + "";
}
catch (StringIndexOutOfBoundsException ex){
}
result.addValue(item_string);
}
The function should split the string in the element like this.
sourceelement = <1="abc" 2="def" 3="ghi">
Target should look like this.
Node
element1 = abc
element2 = def
element3 = ghi
If I only get one elemt it works but if I get 2 elements I get the following result.
sourceelement = <1="abc" 2="def" 3="ghi">
sourceelement = <1="jkl" 2="mno" 3="pqr">
target
Node
element1 = abc
element2 = def
element3 = ghi
Node
So I get the first node with elements and the second node without elements.
Does anybody know why?
Edit:
The mapping looks as follow.
source: Function: Target:
element No Node
element Yes element
element Yes element
element Yes element
In the mappings between the element the function gets called. I'm calling it with a=the whole string, b=the attributename matching the target element, c=".
BR
Kalle
Edited by: Kalle Persson on Feb 22, 2008 5:08 PM
Hello,
could be a context problem.
Try the standard function 'split-by-value' after your sourceelement.
Regards
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Kalle,
Can u confirm whether u r looking for the below expected output.
Source
<MT_Input>
<Records>
<Sourceelement attrib1="21" attrib2="34" attrib3="09">Test</Sourceelement>
</Records>
<Records>
<Sourceelement attrib1="abc" attrib2="def" attrib3="ghi">Test</Sourceelement>
</Records>
<Records>
<Sourceelement attrib1="ABC" attrib2="DEF" attrib3="GHI">Test</Sourceelement>
</Records>
</MT_Input>
Target
<MT_Output>
<Node>
<Element1>21</Element1>
<Element2>34</Element1>
<Element3>09</Element1>
</Node>
<Node>
<Element1>abc</Element1>
<Element2>def</Element1>
<Element3>ghi</Element1>
</Node>
<Node>
<Element1>ABC</Element1>
<Element2>DEF</Element1>
<Element3>GHI</Element1>
</Node>
</MT_Output>
If you are ok with the above results, could you tell us what is the Source element 3 Atrtibutes occurrences, is it optional or required
raj.
Hello,
please just try it with 'splitByValue'.
I guess your sourcefield is mapped two times to 'Node' (like you want it), but
without 'splitByValue' your complete source input goes in the first function call and there is no input for the second call (that's why the function isn't called a second time).
Regards
Patrick
Kalle,
R u looking for something like below results?
Variant -1 http://www.flickr.com/photos/23855877@N07/2284628426/sizes/o/
Variant-2 http://www.flickr.com/photos/23855877@N07/2284628438/sizes/o/
raj.
There will be a max number of attributes but all of them will not always be present in the string. That's why I have the test with No Present Value. There will only be one string in each element but the element can appear upto unbounded.
To se an example of an string look at message number one.
My source looks like
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MsgT_Incoming_file xmlns:ns0="http***">
<Line>
<SegmentA>TEST</SegmentA>
<SegmentB>080221</SegmentB>
<SegmentC><Sequence="1" Time="2006-09-12 12:12:00" Id="v012345" Role="Manager" Status=" Rejected" Comment="YES"/></SegmentC>
<SegmentC><Sequence="2" Time="2006-09-12 12:12:01" Id="v123456" Role="Java Developer" Status="Active" Comment="YES"/></SegmentC>
</Line>
</ns0:MsgT_Incoming_file>
And my target becomes like this.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MsgT_Outgoing_xml xmlns:ns0="http***">
<LineA>
<SegementA>TEST</SegementA>
</LineA>
<LineB>
<SegementB>2008/02/25</SegementB>
</LineB>
<LineC>
<Sequence>1</Sequence>
<Time>2006-09-12 12:12:00</Time>
<Id>v012345</Id>
<Role>Manager</Role>
<Status> Rejected</Status>
<Comment>YES</Comment>
</LineC>
</ns0:MsgT_Outgoing_xml>
Edited by: Kalle Persson on Feb 25, 2008 10:25 AM
Hi Patrick.
Between the element containing the string I have the following mapping.
SourceElement -> SplitByValue(Each Value) -> TargetNode
SourceElement, Constant(with the startstring to search for), Constant (with the endstring to search for) -> MyUserFunction -> TragetElement
(SE, C, C are inputs for my function.)
If I have 2 SourceElements then where the strings to search for are the numbers 1 and 2 the queue at my function looks as this.
Input 0 Input 1 Input 2 Output
String1 Constant Constant 1
String2 1
String2
How come that I just get the value in the first string?
The Strings are there for the input but not the constants. why?
I hope this is what you was asking for to get a better picture.
Are you sure about TargetNode?
I want the splitted string in the elements in the TargeNode...
Also I need to Ad so many constants then as inputs for the function.
Is it possibly to do it in some way that I described?
If I do it like you configure it don't I need to use global variables then?
Edited by: Kalle Persson on Feb 26, 2008 9:51 AM
Sorry -> targetElement !
BUT you need in both cases a splitByValue:
Here:
SourceElement -> SplitByValue(Each Value) -> TargetNode
And here:
SourceElement -> SplitByValue(Each Value) -> MyUserFunction
Constant1 -> MyUserFunction
Constant2 -> MyUserFunction
MyUserFunction -> TargetElement
Regards
Patrick
Hello,
guess i was wrong in one point!
please try the splitByValue ONLY before your function
NOT here:
SourceElement -> SplitByValue(Each Value) -> TargetNode
ONLY here:
SourceElement -> SplitByValue(Each Value) -> MyUserFunction
Constant1 -> MyUserFunction
Constant2 -> MyUserFunction
MyUserFunction -> TargetElement
Regards
Patrick
Just tried it. Worked perfect.
I think I tried this before but then my function was a queuedfunction and todasy I changed it to a contextfunction. Is that why it worked today and not before?
What's the differens between context and queued functions?
Thanks for all the help Patrick. You have som points coming...
Hello,
> Just tried it. Worked perfect.
Happy to hear that
> What's the differens between context and queued functions?
It's explained here:
http://help.sap.com/saphelp_nw04/helpdata/en/f8/2857cbc374da48993c8eb7d3c8c87a/frameset.htm
> Thanks for all the help Patrick. You have som points coming...
Thank you and regards
Patrick
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.