Monday, 6 April 2020

PeopleSoft - Writing Blanks when Field values are Null using PeopleSoft File layout





Ever wondered with an issue of writing a blank space for a field when its original value is null.
Peoplesoft by delivered produces null value when writes data using File layout.

The following code produces output file. But incase if any fields have no value (including blanks) , file layout will trim spaces into Null. This happens by default.

&outputFile = GetFile(&file, "W", %FilePath_Absolute);
&outputFile.SetFileLayout(FileLayout.FILE_LAYOUT);
&rsOutput = &outputFile.CreateRowset();
&rsApplicants.CopyTo(&rsOutput, Record.DATA_STG, Record.FILE_LAYOUT_STG);
&outputFile.WriteRowset(&rsOutput);


If the file needs to be produced with spaces instead of NULL.

use the peoplecode below.

&outputFile = GetFile(&file, "W", %FilePath_Absolute);
&outputFile.SetFileLayout(FileLayout.FILE_LAYOUT);
&rsOutput = &outputFile.CreateRowset();
&rsApplicants.CopyTo(&rsOutput, Record.DATA_STG, Record.FILE_LAYOUT_STG);
&outputFile.UseSpaceForNull = True;   
&outputFile.WriteRowset(&rsOutput);

By default UseSpaceForNull property is False for each file-layout. Setting it to True will make file Layout to write spaces instead of Null Values.





No comments:

Post a Comment