Skip to Content
0

Pad number of hyphen(_) on left side based on length of field value in PI

Feb 05 at 04:01 PM

39

avatar image

Hi Experts,

I have requirement like if the length of the field value is less than 11 then it should be pad with that many number of white spaces.

for example:

948243 --> -----948243 [since input length is 6 the output contains 5 hyphens]

Thanks!

10 |10000 characters needed characters left characters exceeded

Hello,

Use FormatNumber from Arithmetic functions in your Message mapping and provide 11 hyphens in number format. So that you will get your required output.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Feb 06 at 08:06 PM
0

You can create a simple UDF to insert the values

UDF Code

StringBuffer sb   = new StringBuffer(inputData);

int strLengthDiff = maxLength-inputData.length();


if(strLengthDiff > 0){
	
	for(int i=0;i<strLengthDiff;i++){
						
		sb.insert(0,charData);
										
	}
	
	return sb.toString();


}else{
	
	return inputData;
	
}

Share
10 |10000 characters needed characters left characters exceeded