cancel
Showing results for 
Search instead for 
Did you mean: 

Padright in XI

Former Member
0 Kudos

Hello Gurus,

I need to have a function in XI simular to PadRight. Padright fills a string value up to an certain amount of chars, for example:

PadRight('12345','0','10') outcome is 0000012345

I think it is doable with standard XI functionality but I am not shure because you have 3 situaties

PadRight('','0','10') returns 0

PadRight('1123456789','0','10) returns 1123456789

PadRight('12345','0','10') return 1234500000

But can I build a structure with actually a case secanario

Case length = 0 then

Case length = 10 then

Case length < 10 then

Or do I need a UDF ?

Best regards,

Guido Koopmann

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Use the standard function FormatNumber.

Regards,

Jai Shankar

Former Member
0 Kudos

I agree with Jai.

Use the standard format number ########## in graphical mapping.

Shabarish_Nair
Active Contributor
0 Kudos

format number works good, but try and test the mapping well before you confirm on it.

There has been several instances (even in the forum) where format number happened to throw exceptions (dnt remember exactly when n where). Anyway if u find any problem in it, use the UDF i mentioned above.

Former Member
0 Kudos

I am using format number with an if-statement, like the following

Value x -> length = 0 then return 0 else Value x -> format number

This works for now!

Answers (1)

Answers (1)

Shabarish_Nair
Active Contributor
0 Kudos

Try to make a UDF based on the logic below;

a sample code is;

String input = "1001";

int len = 10; //this is the maximum length that the field can take

StringBuffer sBuf= new StringBuffer(input);

while (sBuf.length() < len) {

sBuf.insert(0,'0');

}