cancel
Showing results for 
Search instead for 
Did you mean: 

Map array of strings to a string

Former Member
0 Kudos

Can anyone help me to do the following mapping:

Example:

From Array of strings

1234

test

ok

to 1 String

1234testok

it is the opposite of forum

I have some issues with the GlobalContainer in the java function. I see the result but anyhow he posts only the first value.

My function:

MappingTrace importanttrace;

importanttrace = container.getTrace();

importanttrace.addWarning("The value of incoming Pos :" + a + " text_line: " + b);

GlobalContainer gc = container.getGlobalContainer();

String totaltext = "";

String textmsg;

Object obj=gc.getParameter("TextMsg");

if (obj==null) textmsg = "";

else textmsg = (String)obj;

importanttrace.addWarning("The value of the textmsg is:" + textmsg);

totaltext = textmsg.concat(b);

importanttrace.addWarning("The value of the totaltext is:" + totaltext);

gc.setParameter("TextMsg", totaltext);

return totaltext;

the result in the test environment looks like:

Kompilierung von Mapping war erfolgreich.

Warning:The value of incoming Pos :01 text_line: 1234

Warning:The value of the textmsg is:

Warning:The value of the totaltext is:1234

Warning:The value of incoming Pos :02 text_line: TEST

Warning:The value of the textmsg is:1234

Warning:The value of the totaltext is:1234TEST

Warning:The value of incoming Pos :03 text_line: ok

Warning:The value of the textmsg is:1234TEST

Warning:The value of the totaltext is:1234TESTok

Ausführung war erfolgreich.

Thanks in advance for any idea.

Mike

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Michal,

thanks for the fast response but if i try your code i got an error

Quellcode hat Syntaxfehler:

301: concat(java.lang.String) in java.lang.String cannot be applied to (java.lang.String[])

totalValue = totalValue.concat(a);

^

1 error

sorry i am not the java geeky guy

what is wrong?

Thanks

Mike

MichalKrawczyk
Active Contributor
0 Kudos

the forum does not allow

to do show my examle:

totalValue = totalValue.concat(a"["i"]");

just remove all -> " from this line

Regards,

michal

MichalKrawczyk
Active Contributor
0 Kudos

glad it works

Regards,

michal

Answers (4)

Answers (4)

Former Member
0 Kudos

Michal,

it is working now

many thanks to you ...

also you did a lot of very good stuff here in this sdn area ... i really appreciate this ...

Mike

Former Member
0 Kudos

String totalValue = "";

for (int i = 0 ; i<a.length ; i++)

{

totalValue = totalValue.concat(a\i\);

}

result.addValue(totalValue);

gives the following error

13:40:06 Start of test

Source code has syntax error: F:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapa360eb2015d811dd8a1d001a4ba8d346/source/com/sap/xi/tf/_PM_CS_UpdateEquipmentsInGIS_MM_.java:106: illegal character: \92 totalValue = totalValue.concat(a\i\); ^ F:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapa360eb2015d811dd8a1d001a4ba8d346/source/com/sap/xi/tf/_PM_CS_UpdateEquipmentsInGIS_MM_.java:106: illegal character: \92 totalValue = totalValue.concat(a\i\); ^ 2 errors Source code has syntax error: F:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapa360eb2015d811dd8a1d001a4ba8d346/source/com/sap/xi/tf/_PM_CS_UpdateEquipmentsInGIS_MM_.java:106: illegal character: \92 totalValue = totalValue.concat(a\i\); ^ F:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapa360eb2015d811dd8a1d001a4ba8d346/source/com/sap/xi/tf/_PM_CS_UpdateEquipmentsInGIS_MM_.java:106: illegal character: \92 totalValue = totalValue.concat(a\i\); ^ 2 errors

13:40:07 End of test

any1 knows ?

thx Shai

Former Member
0 Kudos

wrong interpretation....sorry!!

Message was edited by: Priyanka Balagangadharan

MichalKrawczyk
Active Contributor
0 Kudos

Hi Mike,

do the removeContext (from node functions)

and then use this function (with queue)

String totalValue = "";

for (int i = 0 ; i<a.length ; i++)

{

totalValue = totalValue.concat(a<i>);

}

result.addValue(totalValue);

the result will only be one field - remember

then inside the totalValue you'll have the whole string

which you cna use later on somewhere

Regards,

michal

Message was edited by: Michal Krawczyk

Former Member
0 Kudos

Are you maaping 3 elements from input node of source message type to one element in the output node of destnation message type.

Thanks

Abinash

Former Member
0 Kudos

I have something like

<in>

<textbox>

<TEXT_ID>01</TEXT_ID>

<TEXT_LINE>1234</TEXT_LINE>

<textbox>

<textbox>

<TEXT_ID>02</TEXT_ID>

<TEXT_LINE>Test</TEXT_LINE>

<textbox>

<textbox>

<TEXT_ID>03</TEXT_ID>

<TEXT_LINE>ok</TEXT_LINE>

<textbox>

</in>

which should be mapped to

<out>

<Description>1234Testok</Description>

</out>

but it could be n-textbox but only one destination field.

Thanks

MichalKrawczyk
Active Contributor
0 Kudos

hi,

just use may example code

it will do the trick

Regards,

michal