cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping

Former Member
0 Kudos

Hi,

In my Source structure iam getting values as

100.00- ( minus sign after the number)

and in the target structure iwant the value as

-100.00 (minus sign before the number)

is there any way we can do it in Mapping.

Thanks

Srinivas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Here is the solution without UDF

https://weblogs.sdn.sap.com/weblogs/images/17804/TestImg.JPG

replace name with your number.

regards

Sameer

Former Member
0 Kudos

The above UDF functions are not working.

Please help me in resolving this issue.

Thanks

Srinivas

Former Member
0 Kudos

Hi,

Please try this

String strNew = "";

int strIndex = strInput.indexOf("-");

String newStr = "-"+ strInput.substring(0,strIndex);

This will work for sure.

Thanks

Amit

Reward points if solution works

Former Member
0 Kudos

Hi,

Full function will be like this

Re: Message Mapping

Posted: Jun 16, 2008 4:53 PM in response to: Srinivas Manda E-mail this message Reply

function myudf(String strInput,Container container)

{

int strIndex = strInput.indexOf("-");

String newStr = "-"+ strInput.substring(0,strIndex);

return newStr ;

}

Thanks

Amit

GabrielSagaya
Active Contributor
0 Kudos

function myudf(String a,Container container)

{

int ind = a.indexOf("-");

if (ind >= 0)

{

String ret="";

ind = a.indexOf("-");

ret = "-" + a.subString(0,ind);

return ret;

}

return a;

}

Former Member
0 Kudos

Hi Gabriel,

when iam using ur UDF iam getting the following error

Source code has syntax error: /usr/sap/DHX/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map80938c803d5911ddc30e001125a5ce17/source/com/sap/xi/tf/_mm_ZMATMAS_to_ZMATMAS_MANAGE_DPM_.java:7029: cannot resolve symbol symbol : method subString (int,int) location: class java.lang.String ret = "-" + a.subString(0,ind); ^ 1 error

Help me inresolving this error.

Thanks

Srinivas

Former Member
0 Kudos

Use below UDF: only change is instead of subString use substring

function myudf(String a,Container container)

{

int ind = a.indexOf("-");

if (ind >= 0)

{

String ret="";

ind = a.indexOf("-");

ret = "-" + a.substring(0,ind);

return ret;

}

return a;

}

Gaurav Jain

Reward Points if answer is helpful

Former Member
0 Kudos

Hi Gaurav/Gabriel,

The UDF is working with no syntax errors.

is this statement is correct if (ind >= 0)

i want to convert the values from (suppose 100.00- to -100.00)

Thanks in Advance

Srinivas

Former Member
0 Kudos

Hi,

Yes this statement is correct. If you just put if(ind>0) , then also it will work. It means that if "-" exists then only convert else return back the same value whatever it is at the input.

Thanks

Amit

Reward points if answer helps

Former Member
0 Kudos

Hey,

Have you checked Sameer' reply. It should work fine without UDF right.

replace the '-' with space and then use concantenate function and concatenate '-' ,replaced string and pass it to the target field.

Thanks,

Vijaya.

Former Member
0 Kudos

Yes, Value is correct.

Test it from your side.

Gaurav Jain

Reward Points if answer is helpful

Answers (5)

Answers (5)

Former Member
0 Kudos

Thank you to all of you,

The UDF given by Gabriel and Gaurav is working.

Thanks

Srinivas

Former Member
0 Kudos

Hi Srinivas,

Just curious to know. Was the code provided by me didn't worked?

Thanks

Amit

GabrielSagaya
Active Contributor
0 Kudos

function myudf(String a,Container container)

{

String d = a.subString(a.length-1);

if (d.equals("-"))

{

String ret=null;

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

if ( ! a[<i>] == '-')

ret = ret + a[<i>];

ret ="-"+ret;

return ret;

}

return a;

}

Former Member
0 Kudos

hi,

u can achieve the same using graphical mapping also. If the value is lt 0. then replace - sign with space and concat the value with -.

Reward if find useful

former_member181962
Active Contributor
0 Kudos

Hi,

YOu may have to write a UDF in JAVA.

sample code:

String abc = "100.00-";

int length = abc.length;

String numberString = abc.substr(length-1);

return "-" + numberString;

Regards,

Ravi Kanth Talagana

Former Member
0 Kudos

you can write a UDF as

take source as input parameter to this UDF

String StrNew = null;

for (i=0;i<strInput.length();i++){

if ( ! strInput<i> == '-')

{

Strnew = StrNew + strInput<i>;

}

StrNew = "-" + StrNew; /// to concatenate - and StrNew

}