Skip to Content

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

UDF - Right justification

Hi,

I need to create UDF for the right justification of the characters. I've one sample UDF that does the same job but in that UDF the lenght of the string is fixed (20 char). In my requiremens the lenght of the input string is varying.

Please can anyone suggest me how to do this? what are the changes requires in the sample UDF?

Or if anyone has that UDF available please post it or send me.

Here is the sample UDF :

String padChar = " ";

int maxLen = 20;

{

int padLen = str.length();

int sLen = (maxLen - padLen);

if (padLen >= maxLen)

return str;

StringBuffer sb = new StringBuffer(sLen);

for (int count = sLen; count > 0; count--)

{

sb.append(padChar);

}

str = sb.toString() + str;

return str;

}

Regards,

Chintan

Helpful Answer

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