Editar

Compartir vía


Record.Consistent(Boolean) Method

Version: Available or changed with runtime version 1.0.

Marks a table as being consistent or inconsistent.

Syntax

 Record.Consistent(Consistent: Boolean)

Parameters

Record
 Type: Record
An instance of the Record data type.

Consistent
 Type: Boolean
The mark to be set on the table. If this parameter is true, the table is marked as consistent. If this parameter is false, the table is marked as inconsistent.

Remarks

Usually this method is only used for accounting routines. If your accounts do not balance, then the accounts are inconsistent. This method makes sure that inconsistent changes are not made in your accounts.

If an attempt is made to commit a write transaction when a table is marked as inconsistent, then a message is displayed and all updates that were made in the write transaction are ended.

A typical example of an inconsistency occurs when the sum of all the entries in a table that contains general ledger entries does not balance - is not equal to zero.

In this example, your application includes a method object that is named ChangeAmount. This method is used to withdraw amounts that were put into the General Ledger Entry table in your application. When an amount is withdrawn from an account, the system is inconsistent until a corresponding amount is put in. The following code example illustrates the ChangeAmount method. The ChangeAmount method has one parameter, Amount, which is a Decimal data type.

Example

var
        GLEntry: Record "G/L Entry";
        Balance: Decimal;
        Amount: Decimal;
        Consistent: Boolean;

    begin
        GLEntry."G/L Account No." := '1000';  
        GLEntry.Amount := Amount;  
        GLEntry.Insert;  
        Balance := Balance + Amount;  
        if Balance = 0 then
            Consistent := true
        else  
            Consistent := false;
            GLEntry.Consistent(Consistent);  
    end;  

The method uses the variable Balance to express the change in balance. For example, when the method is used to withdraw $100, the Balance variable will reflect this as -$100.

When you use the method to put in one or more amounts whose total equals +$100, the Balance variable then equals zero and the table is marked as consistent. This means that if an attempt is made to put in an amount and end the write transaction - commit the change - without withdrawing a corresponding amount, an error occurs and the write transaction is canceled.

Record Data Type
Get Started with AL
Developing Extensions