Skip to Content
author's profile photo Former Member
Former Member

UDF for Not equals

Hey all

I am new to PI/java and I am trying to write a UDF, Here is the UDF requirements:

If account starts with an u201Cxu201D, replace with u201C4u201D. If account starts with 17**, and not equal to 1783 or 1784 or 1794 or 1795 or 1796 or 1797 or 1791 or 1799, replace with u201C1790u201D, ELSE map actual value.

I also want to note that the account numbers start in the position 4-8 in an array of 26 characters (so I know substring will need to be used) and also that I have to return the entire 26 charaters with the changes.

Can anyone help me?

Thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Jul 19, 2011 at 07:23 PM

    Hi Richard, how are you?

    That isn't a difficult issue and you shouldn't post it in the Process Integration Forum, that's a pure Java issue. You should investigate something about java coding.

    Regards,

    Juan.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 19, 2011 at 07:35 PM

    Solution for your first question

    String output=null;
    if(input.startsWith("X"))
    {
    output=input.replace("X","4");
    }
    else if(input.startsWith("17"))
    {
    if(! (input.equals("1783")||input.equals("1784")||input.equals("1794")||input.equals("1795")||input.equals("1796")||input.equals("1797")||input.equals("1791")))
    {
      output ="1790";
    }
    }
    else
    {
    output=input;
    }
    return output;

    Second question: Please elaborate... Your quesion is not precise.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 20, 2011 at 06:31 AM

    Hi,

    You can try it this way also :

    String code = "fpl179701105031052374666.dat";
    		StringBuffer buffer1 = new StringBuffer(code);
    		StringBuffer buffer = new StringBuffer(code.substring(3,7));
    		String accnt = code.substring(3,7);
    		System.out.println(accnt);
    		if(accnt.startsWith("x"))
    			buffer.replace(0, 1, "4");
    		else if(accnt.startsWith("17")){
    			if((accnt.equals("1783"))|| (accnt.equals("1784"))||(accnt.equals("1794"))||(accnt.equals("1795")));
    			else
    				buffer.replace(0, 4, "1790");
    		}
    		buffer1.replace(3, 7, buffer.toString());
    		
    		System.out.println(buffer1);

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 20, 2011 at 09:20 AM

    Hi Richard,

    This question is already answered in the thread below

    position-in-an-array

    regards

    Anupam

    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.