cancel
Showing results for 
Search instead for 
Did you mean: 

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

ramu_g4
Participant
0 Kudos

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!

former_member217029
Participant
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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;
	
}