on 10-31-2008 6:02 PM
Hello sdn
I want to convert this udf into context udf : i have opened a new thread as previous thread was growing too big.
requirement is:
Eg : if source text field value is : ST - 102RP34;RP - 234ST89;VT - 90789ST;
Then in target side i want to create a sement for qualifier RP and its corresponding field should have a value : 234ST89
In the below context function ,a is being passed,qualifier is returned. but these are single values although we need to pass and retrun an array of values.
public void qualifier(String[] input,ResultList result,Container container)
{
String element, qualifier ="";
StringTokenizer token1 = new StringTokenizer( input, ";");
while (token1.hasMoreTokens())
{
element = token1.nextToken();
StringTokenizer token2 = new StringTokenizer( element, "-" );
qualifier = token2.nextToken();
result.addValue(qualifier);
}
}
}
Thanks
Hello,
Could you please reply us your source and target structure with occurrences? It will be more helpful to suggest the soln.
Thanks,
raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will give shot for last time..modify the UDF as below..
public void qualifier(String[] input, ResultList result,Container container)
{
String element, qualifier ="";
StringTokenizer token1 = new StringTokenizer( input, ";");
while (token1.hasMoreTokens())
{
element = token1.nextToken();
StringTokenizer token2 = new StringTokenizer( element, "-" );
qualifier = token2.nextToken();
if ( qualifier.equals("RP")) // or u can pass constant that will have this qualifier
{ value = token2.nextToken(); //
result.addValue(value);
}
}
}
}
GUI looks like this.
Text Element ---> UDF ---> PR Element
Edited by: Anand on Oct 31, 2008 7:17 PM
Error message :
cannot resolve symbol symbol : constructor StringTokenizer (java.lang.String[],java.lang.String) location: class java.util.StringTokenizer StringTokenizer token1 = new StringTokenizer(a, ";");
cannot resolve symbol symbol : variable value location: class com.sap.xi.tf._MAP1_ { value = token2.nextToken(); //
cannot resolve symbol symbol : variable value location: class com.sap.xi.tf._MAP1_ result.addValue(value);
>
> Error message :
>
> cannot resolve symbol symbol : constructor StringTokenizer (java.lang.String[],java.lang.String) location: class java.util.StringTokenizer StringTokenizer token1 = new StringTokenizer(a, ";");
>
import java.util.StringTokenizer; //add this line beginning of the function.
>
> cannot resolve symbol symbol : variable value location: class com.sap.xi.tf._MAP1_ { value = token2.nextToken(); //
>
>
> cannot resolve symbol symbol : variable value location: class com.sap.xi.tf._MAP1_ result.addValue(value);
value = token2.nextToken();
change to
String value = token2.nextToken();
Dear Guest,
Thanks for your understanding! Could you please let me know whether you are looking to achieve something like below?
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Source xmlns:ns0="urn:xitest">
<E1EDL43>
<SEGMENT>
<TDID>ST-102RP34;RP-234ST89;VT-90789ST;</TDID>
</SEGMENT>
</E1EDL43>
<E1EDL43>
<SEGMENT>
<TDID>ST-555RP34;RP-777ST89;VT-34589ST;QT-987RP34;</TDID>
</SEGMENT>
</E1EDL43>
</ns0:Source>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Target xmlns:ns0="urn:xitest">
<MSG>
<D_108>234ST89</D_108>
</MSG>
<MSG>
<D_108>777ST89</D_108>
</MSG>
</ns0:Target>
Thanks,
raj.
Edited by: Raj on Oct 31, 2008 2:57 PM
Hello Raj
Yes I am looking for something like this.
Just that currently E1EDL43 is not repeating.
Source
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Source xmlns:ns0="urn:xitest">
<E1EDL43>
<SEGMENT>
<TDID>ST-102RP34;RP-234ST89;VT-90789ST;</TDID>
</SEGMENT>
</E1EDL43>
</ns0:Source>
Target one more MSG segment: MSG segment is created for each qualifier : ST,RP and VT
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Target xmlns:ns0="urn:xitest">
<MSG>
<D_108>102RP34</D_108>
</MSG>
<MSG>
<D_108>234ST89</D_108>
</MSG>
<MSG>
<D_108>90789ST</D_108>
</MSG>
</ns0:Target>
Thanks
Please follow the below logic.
Create two UDF's
UDF1 - gen_MSG
Cache : Queue
Argument :TDID
int count =0;
for(int i =0;i<TDID.length;i++)
{
StringTokenizer st = new StringTokenizer(TDID<i>, ";");
count = count+ st.countTokens();
}
for(int i=0;i<count;i++)
{
result.addValue("");
}
UDF2 - gen_element
Cache : Queue
Argument :TDID
String temp1="";
String temp2="";
for(int i =0;i<TDID.length;i++)
{
StringTokenizer st = new StringTokenizer(TDID<i>, ";");
while(st.hasMoreTokens())
{
temp1 = st.nextToken();
temp2= temp1.substring(temp1.indexOf("-")+1, temp1.length());
result.addValue(temp2);
}
}
Mapping Logic
TDID [Change Context to higher node] --->Trim[ Standard Text Function]---> gen_MSG[UDF1] --->MSG
TDID [Change Context to higher node] --->Trim[ Standard Text Function]---> gen_element[UDF2] --->D_108
I've checked the codes and it's working fine.
I hope it helps!
Thanks,
raj.
Edited by: Raj on Oct 31, 2008 3:17 PM
Hello Raj
The above code works.
Just that had to add splitbyvalue in field level mapping.
Another req is that if we add one more field in target
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Source xmlns:ns0="urn:xitest">
<E1EDL43>
<SEGMENT>
<TDID>ST-102RP34;RP-234ST89;VT-90789ST;</TDID>
</SEGMENT>
</E1EDL43>
</ns0:Source>
Target one more MSG segment: MSG segment is created for each qualifier : ST,RP and VT
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Target xmlns:ns0="urn:xitest">
<MSG>
<D_107>ST</D_107>
<D_108>102RP34</D_108>
</MSG>
<MSG>
<D_107>RP</D_107>
<D_108>234ST89</D_108>
</MSG>
<MSG>
<D_107>VT</D_107>
<D_108>90789ST</D_108>
</MSG>
We need another udf for this D_107 which needs the qualifier ?
Thanks
Yes you are correct. Please follow the below logic.
UDF3 - gen_element2
Cache : Queue
Argument :TDID
String temp1="";
String temp2="";
for(int i =0;i<TDID.length;i++)
{
StringTokenizer st = new StringTokenizer(TDID<i>, ";");
while(st.hasMoreTokens())
{
temp1 = st.nextToken();
temp2= temp1.substring(0,temp1.indexOf("-"));
result.addValue(temp2);
}
}
raj.
Hello Raj/Anand/Gaurav
Thank You.
Raj :It works : For D_107 :
Even the below line of code was working
temp2= temp1.substring(temp1.indexOf("-") -2, temp1.indexOf("-"));
I have one issue though,I dont know whether it is related to udf or something else ( Cache)
if i have xml :
Source:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Source xmlns:ns0="urn:xitest">
<E1EDL43>
<SEGMENT>
<TDID>Ab-102RP34;RP-234ST89;ST-St01;RP-234ST89</TDID>
</SEGMENT>
</ns0:Source>
In the above xml : when i run the test tool in mapping,it fails for the first time. If i remove the ST-St01,it is successfull or even if i delete the"-" and put again the"-" it works. Is this some general issue with XI /cache or something with the udf? The "-" seems to be the problem ,if i delete it and put it again ,it runs fine?
The combination of ST-St01 gives problem.
Any suggestions?
Thanks
Edited by: Guest1 guest on Oct 31, 2008 11:31 PM
Hi
I understand there r no issues with the udf.
i activated ,closed XI and opened again too.
I guess in the IDOC when it comes ST-Sto1,it looks like a "-" but it might be some other symbol.
How i make it to work is : by deleting the "-" in ST-St01 and putting again the "-".Can we automate this ? it is only happening at ST-St01,other segments work fine.
Symbol might be different although it looks like a "-"
Any suggestions ,how i could check or some quick fix?
Thanks
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.