on 06-09-2006 7:21 PM
Hi,
I have to face a concatenation between 2 fiels that occurs multiple times to only one string.
This functionality is used to insert values in an DB using JDBC and my structure contains others fields that are working properly but in this case only the first occurrence of those 2 fiels is inserted in DB.
Can anyone provide me some help ?!?!?
Thanks in advance.
JMMatos
Hi JMMatos,
I guess, without seeing the Source and target structure, its difficult to solve your problem. Could you answer the below quesions, so that I can try:
i. The two fields that you are trying to concatenate - Are they within the same node?
ii. Did you try using the Test Tool of Map - Does the testing result in a correct Target Message?
Rgds
RC
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi RC,
Thanks for your time ... about your questions ...
i. the two fields belongs to the same node
--> Atributos 1..unbounded
--> Codigo 1..1
--> Valor 1..1
my target structure is
--> string_atr 0..1
and it must only happens one time ...
ii. in the Test Tool it really doesn't work ... only the first occurrence of my source (Codigo+Valor) is mapped ...
Do you have any suggestion ???
Thanks again...
JMMatos
Hi Vijaya,
Sorry for delay of my response but I've been abroad ...
I understand what u mean but my target structure must only appear one time containing all the sets of my source structure.
The set (Codigo + Valor) should be repetead as many times it appears in the String field of my target structure separated by ;, like this:
Codigo;ValorCodigo;Valor ... Codigo;Valor
Thus this mean anything to u ??? thanks
JMMatos
Hi Jose,
If you have to map multiple occurences of your source structure element to a single element of the target structure, you need to write a User Defined function.
May be the following code sample would help you,
import com.sap.aii.mapping.api.*;
//Write your code here
StringBuffer message = new StringBuffer();
for(int i=0;i<a.length;i++)
{
if (!(a<i>.equalsIgnoreCase(ResultList.CC)))
{
message.append(a<i> + " ");
}
}
result.addValue(message.toString());
Regards,
Padmaja
PS: Pls reward points if you found my response useful.
Hey,
jus now tried ur scenario,it works fine
u need to write a user defined function.
first u concatenate Codigo and Valor,then in the resulting output do remove context,
so codigo--
valor -- concatenate---->removecontext
then use a user defined function with 2 inputs one as Atributos(the parent node) and the other as the output coming from removecontext,these two inputs will be defined as a and b in the user defined function respectively.
So for all the occurance of parent node,the values of codig and valor will be concatenated and sent to the string using this UDF
<b>
In the user defined function write the following code
<b>int i=0;
String s="";
for(i=1;i<a.length;i++)
{
s=s+(b[i-1] ";" b<i>);
}
result.addValue(s</b>);</b>
and from the userdefined function map the output to the target structure node String
just try.i tried it worked fine.
cheers
jithesh
Message was edited by: jithesh balakrishnan
Hi Jithesh,
Defining my UDF as you kindly indicated i get three errors in result test:
1)cannot resolve symbol symbol : variable length location: class java.lang.String for(i=1;i<a.length;i++)
2)array required, but java.lang.String found s=s+(b[i-1] ";" b);
3)cannot resolve symbol symbol : variable result location: class com.sap.xi.tf._MM_Servicos_Cria_Produto_BDC_ result.addValue(s);
Can u help me???
Regards,
JMMatos
Hi ,
In the following code when I executed its giving the below error
Code:
//Write your code here
StringBuffer message = new StringBuffer();
for(int i=0;i<a.length;i++)
{
if (!(a.equalsIgnoreCase(ResultList.CC)))
{
message.append(a + " ");
}
}
result.addValue(message.toString());
Error:
cannot resolve symbol symbol : method equalsIgnoreCase (java.lang.String) location: class java.lang.String[] if (!(a.equalsIgnoreCase(ResultList.CC)))
My Scenario is similar to this one where I
RootNode 0..unbounded
ChildNode 0..1
This root node will be repeated mutiple times and on the target I have to map to field for all the occurences of childNode into one element.
Thanks in advance...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Make sure that the target field occurance is 0 to unbounded or 1 to unbounded.
We would be able to help you better if you could provide the source and target structures here.
Regards,
Smitha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
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.