Skip to Content

need user define function for the message mapping structure

Hi All

I am new to XI.I need the java code for Udf for the following structure.

i have two input and one out put as error.

order_nos----


\

-


user define function-------error message

/

order_details----


num of orders---- i.e. 10

order_details------ i.e. whole order records details

1.i have to compare the 1st input with 2nd one means if the ist input contain 10 means there are 10 orders in 2nd input.if not then i have to give error message .

2.then i have to check the fields in 2nd input has no null values.if no values the output will be error message.

Edited by: Rohit Kumar on Dec 18, 2008 4:43 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Dec 18, 2008 at 11:26 AM

    Hi,

    Try like this

    int len = 0;
    if(a.length>b.length)
    len = a.length;
    else
    len = b.length;
    for(int i=0;i<len;i++)
    {
      if(b<i>.equals("") || (b.length != a.length))
    result.addValue("Error Message");
    else
    result.addValue("SUCCESS");
    }

    Dont forget to use removeContext before both the inputs to UDF and then use the UDF with advance mode.

    Thanks!

    Edited by: Sudhir Tiwari on Dec 18, 2008 12:28 PM

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Rohit,

      Your mapping will look like

      Num_Orders---------------------------------------------------------------->
                                                                                      UDF----->Target
      Order_ID(not detail)------>removeContext(Node Function)-->

      Also according to your requirement the UDF will be like

      int len = Integer.parseInt(a[0]);
      
      for(int i=0;i<len;i++)
      {
        if(b.length != len){
      result.addValue("Error Message");
      break;
      }
      else if(b<i>.equals(""))
      result.addValue("Error Message");
      else 
      result.addValue("SUCCESS");
      }

      Thanks!

  • Posted on Dec 18, 2008 at 11:23 AM

    Hi

    If your input is just the value of order no, then you wont need a UDF, you can do it with standard functions.

    First check if 2nd value has value or not, do that by using IF THEN using a blank constant if its true then

    Use another IF THEN and check if 1st input is = to 2nd, if true then pass the value of 2nd input to output.

    Hope this helps

    Thanks

    Saiyog

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 11:59 AM

    Hi,

    try the following UDF,

    if(Integer.parseInt(firstInput[0]) == secondInput.length)
    {
      for(int i = 0;i<secondInput.length;i++)
      {
        if(secondInput<i>.equals(""))
        {
         result.addValue("Error Message");
        }
        else
        {
          //logic to handle secondInput
        }
      }
    }
    else
    {
      result.addValue("Error Message");
    }

    -Rohit

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.