Save_Main_File saves the main file.  You can use Save_Main_File to save additional non-related tables. You can also use Save_Main_File to process additional changes in your table.

Save_Main_File gets called for every table being saved in a DD operation. This method may get called even if there are no changes to save. In such a case, the physical save to the database will not occur even though the event is called.

In this example, we want to record a date-time stamp in every saved record. Since setting a date-time field value might cause an otherwise unchanged record to get saved, we will only change the value if the record is already changed. If the file buffer is changed, we will stamp the record.

Procedure Save_Main_File

    Boolean bChanged

    Integer iFile

    Get Main_File to iFile

    Get_Attribute DF_FILE_CHANGED of iFile to bChanged

    // only stamp the record if it is already changed. This assumes

    // that the functions Crnt_Date and Crnt_Time already exist.

    If (bChanged) Begin // if record is changed at all

        Get Crnt_Date to Vndr.Date_Stamp

        Get Crnt_Time to Vndr.Time_Stamp


    // now do the normal save behavior.

    Forward Send Save_Main_File


Normally, you will always want to forward-send this message. If the message is not forwarded, the save to the database will not occur.

This message is always called in a locked state. Do not perform user input in this event.

If an Error is declared, the transaction will be rolled back. Errors must be generated using the UserError message or the Error command. See Error Handling in Transactions for more information.

When accessing table values you should always access the global file buffers and not the DDO buffers (i.e., use “Move File.Field to var” syntax). See Understanding File Buffers and DDO Field Buffers for more information.

See Also

Defining Data Dictionary Events