Method B

LANSA

Method B
Access a File with Null Capable FieldsTo Execute this ExampleThe Things that Make Up this Example

Method B is to have a separate virtual field (a null flag field) for every null capable field on the file. This allows the LANSA program to differentiate between fields on the file that contain null (X’00’) and fields that contain the default value. When reading from the file, the LANSA function determines whether the field was null (X’00’) by checking the null flag field associated with the null capable field. When writing to the file, the LANSA function indicates that a field is to be set to null by setting the associated virtual field (the null flag field) to Y.

In this case the file S231PFB is defined as a LANSA OTHER file and a virtual field (null flag field) is added for every null capable field on the physical file. Virtual field logic is added to the C specs for reading from the physical file to set each virtual null flag field, based on whether its null capable counterpart contains the null character (X’00’). Virtual field logic is added to the C specs for writing to the physical file to indicate to the physical file that a null capable field is to be set to null (X’00’) whenever its associated null flag field is set to Y.

Define the file to LANSA as an OTHER file and load it.

Add virtual fields (null flag fields) for each null capable field on the file.



Edit the virtual field logic:
  • Edit “Calculations after input from file “C” specs” .
  • Edit “Calculations before output to file “C” specs”.
In each case, paste in the virtual field logic supplied: See Method B Virtual Field logic

Save and compile the file and ensure that the three conditions at the beginning have been met.