Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Mappping error in UDF

Hi

I have to remove leading zeroes from an alphanumeric string. I used the code in this link

http://wiki.sdn.sap.com/wiki/display/Java/RemoveLeadingandTrailingZerosfroma+String

if (str == null){

return null;}

char[] chars = str.toCharArray();

int index = 0;

for (; index < str.length();index++)

{

if (chars[index] != '0'){

break;}

}

return (index == 0) ? str :str.substring(index);

}

I am using XI 7.1 and I am getting errors when I trried to run it in Message Mapping

Java:90: 'class' or 'interface' expected public void init(GlobalContainer container) throws StreamTransformationException{ ^

java:130: 'class' or 'interface' expected public static void main(String[] args) throws Exception(); st.testExecute(); }

java:131: 'class' or 'interface' expected }

Java:132: 'class' or 'interface' expected ^ 4 errors

Any idea why I am getting this error ?

Regards

Former Member
replied

use below code snippet

s is input argument to UDF.

String s1=s.replaceFirst("^0+(?!$)", "") ;
return s1;

Regards,

Raj

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question