cancel
Showing results for 
Search instead for 
Did you mean: 

Right Align Target Field

Former Member
0 Kudos

I am having a IDOC to file scenario where I have to right align a couple of fields in the output flat file. I am unable to find an appropriate solution. Please help.

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos

I feel you should handle that in your mapping itself.

Write a Java function to handle the same.

ShaBZ

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Suresh,

Use this simple code.

This will work.

   return "<Spaces for Actual length of target field>"  .substring(0,<Actual length of target field>-a.length()).concat(a);

Regards,

Dhana

Former Member
0 Kudos

You can define a user defined function in your graphical user mapping..code that I generally use for padding is

String rJustify(String input, int len) {
	StringBuffer sBuf= new StringBuffer(input);
	while (sBuf.length() < len) {
		sBuf.insert(0,' ');
	}
	return sBuf.toString();
}

Former Member
0 Kudos

Hi,

you could write a java function which pads the required value with space.

<source>-> addspacefunction-> <target>

in the addspacefunction:

output value = " "+ inputvalue;

This should do the trick.

Regards,

Smitha.

Former Member
0 Kudos

I have already tried it but it is not working. Spaces are getting trimmed.( I have given Whitespace preserve in the data type too.)

Former Member
0 Kudos

Hi,

Make sure the length of the field is big enough.

Test the function after mapping, in the Integration Repository. Is the space added there?

Regards,

Smitha

Former Member
0 Kudos

Hi Smitha,

The field is big enough. And also, I am able to see the spaces in the Integration Repository, which are not reflected in the application server. In the data type the fields have been declared as string.

Former Member
0 Kudos

Check your content conversion then.

That is the only other place where any change might happen.

Regards,

Smitha.

Shabarish_Nair
Active Contributor
0 Kudos

Use the code that Amol provided in your mapping.

And once right allignment is handled in your mapping, during content conversion the fields will automatically be right alligned in your output file.

Can you test the end to end scenario and get back ?