Skip to Content
avatar image
Former Member

UDF question.


I have following code in UDF that pads string to 9 characters long (fills with leading spaces) and adds to SQL query. Please look at the following code.

public void getStatement(String[] companyId,ResultList result,Container container){

int len = companyId.length;

StringBuffer ids = new StringBuffer();

int totalLen = 9;

for (int i=0; i<len;i++)


<b> int len2 = companyId<i>.length();

StringBuffer paddedId = new StringBuffer(totalLen);

int pad = totalLen-len2;



paddedId.append(" ");





if(i != len-1)





result.addValue("selectemp_no, emp_name from employee where emp_no in ("ids.toString()")");


I tested above function using test mapping. The following is the output.

16:57:44 Start of test

Document start

Start tag [ns1:MT_Cma_Customer_Select_Request]

Add raw attribute [ xmlns:ns1=""]

Start tag [Statement]

Start tag [LawsonCustomer]

Add attribute: [action]=[SQL_QUERY]

Start tag [access]

Put value [<b>select emp_no, emp_name from employee where emp_no in(' 45632')</b>

Close tag [access]

Close tag [LawsonCustomer]

Close tag [Statement]

Close tag [ns1:MT_Cma_Customer_Select_Request]

Document end

Executed successfully

16:57:44 End of test

As you see the bold code is used to pad leading spaces and after test the I do not see leading spaces in the select statement.

Can some tell me what am I doing wrong?.

Thank you for the help.


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 24, 2007 at 11:02 PM


    What is the exact reqmt, for the company id length must be 9 ,if not pad with spaces am I right? why u are using Advanced UDF -Queue, you can use standard UDF iteslf. Can u give the reqmt, so that it could be easy to suggest.


    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Justin Santhanam

      Thank you all for suggestions. The original code I have is working, however I can't see when I tested mapping. I checked mapping queue as suggested by Raj and looks like the padding is fine.