Tuesday, April 20, 2010

File layout converting spaces to blanks - UseSpaceForNull

Ran into a peculiar problem while writing to a file using File Layouts today. Fields that had
a space in the database was being converted to null while writing to the file. Did all the obvious
checks like ensuring the Trim Spaces and Strip White Spaces properties of the FileLayout were unchecked.
Then ran into the File Class property - UseSpaceForNull. This property was introduced in Peopletools 8.48 and does the neat job of ensuring that spaces are printed in the output file instead of nulls when attempting to print fields that indeed had a space in database. It is a read-write property and has to be used immediately after instantiating the file layout as shown below:

If &FILE1.IsOpen Then
If &FILE1.SetFileLayout(FileLayout.FL_NAME) Then
&FILE1.UseSpaceForNull = True;

2 comments:

Ranjan Patro said...

Hi,
This is a great post. Was a lot helpful. But my requirement is a few fields need to be " " while others need to remain "" in the same file.
Can you help me?

Ranjan Patro said...

Hi,

Thanks for the nice post.
I have a slightly different issue.
I want to print " " only for some fields.
Using UseSpaceForNull causes all fields with "" to be printed as " ".

I have tried other alternatives such as \32, \s with interpret back slash but none worked for me.