Skip to Content
avatar image
Former Member

UDF error

I used the following UDF in mapping.It executed in IDE but not in XI mapping tool.Let me know how to resolve this.

public class simple {

public static void main(String[] args) {

String[] itemNum={"177-10080-NEW-01","177_10081_NEW-01","414-10945-NEW_01"};

String [] docField={};

String [] partField={};

String [] partNum={"414-10945-new_01"};

String[] docNum={"177-10080-NEW_01","177-10081-NEW-01"};

String[] result={};

String Jpart;

String Jsart;

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

System.out.println(i);

if (docField == null || partField == null) {

System.out.println("bye");

return;

}

for (int j=0;j<docNum.length;j++){

if (itemNum<i>.equals(docNum[j]))

// String Jpart = docField[j];

//result.addValue(Jpart);

System.out.println("HI");

}

for (int j=0;j<partNum.length;j++){

if (itemNum<i>.equals(partNum[j]))

System.out.println("Hey");

//result.addValue(partField[j]);

}

}

}

}

ERROR at XI:

RuntimeException in Message-Mapping transformation: Exception:[java.lang.ArrayIndexOutOfBoundsException: 1] in class com.sap.xi.tf._MM_AL4ECC_PROXY_ method parser$[com.sap.aii.mappingtool.tf3.CBufIter@2ee99bda, com.sap.aii.mappingtool.tf3.CBufIter@6af71d45, com.sap.aii.mappingtool.tf3.CBufIter@5a2d3e0, com.sap.aii.mappingtool.tf3.CBufIter@5041a04, com.sap.aii.mappingtool.tf3.CBufIter@5047ff2e]

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Oct 24, 2008 at 03:34 AM

    Hi

    there is no such main method in UDF when u write in XI.

    look sample udf

    Never, ever use XI's built-in arithmetic functions

    Testing User defined Functions for the XI Graphical Mapping Tool

    https://blogs.sap.com/?p=41211

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Dharamveer Gaur

      My UDF

      public void Mymethod(String[] itemNum,String[] docNum,String[] docField,String[] partNum,String[] partField,ResultList result,Container container){

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

      if (docField == null || partField == null) {

      return;

      }

      for (int j=0;j<docNum.length;j++){

      if (itemNum<i>.equals(docNum[j]))

      result.addValue(docField[j]);

      }

      for (int j=0;j<partNum.length;j++){

      if (itemNum<i>.equals(partNum[j]))

      result.addValue(partField[j]);

      }

      }

      }

  • avatar image
    Former Member
    Oct 24, 2008 at 03:42 AM

    Hi Prabhakar

    I think itemNum, partNum, docNum is your source message input to UDF. Remove the values and remove main method.

    Remove all the code like system.out.prinln and remove commenting before result.addValue as that may be required

    Thanks

    Gaurav

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 24, 2008 at 03:53 AM

    Hi

    you r have return parameter only in first case. so if first condition false then also it require return.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 29, 2008 at 02:29 PM

    Error is not actually in UDF,its because of CONTEXT for a particular field.I solved this issue.

    Thanks for your response

    Add comment
    10|10000 characters needed characters exceeded