Skip to Content

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

Mappping error in UDF


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

if (str == null){

return null;}

char[] chars = str.toCharArray();

int index = 0;

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


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



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 ?


Former Member

use below code snippet

s is input argument to UDF.

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



0 View this answer in context

Helpful Answer

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