Use of Begin-End in BC D365

Use of Begin-End in BC D365:

(1) It is the “AL Compound Statement” which is enclosing the statements between the “BEGIN & END”.

(2) “BEGIN-END” structure is also known as a block.

(3) When BEGIN follows THEN, ELSE, or DO, it should be in the same line.

(4) Syntax of “BEGIN-END”-

Begin 
<Statement 1>; 
<Statement 2>;
<Statement 3>;
    .. 
<Statement n>; 
End

(5) Let’s take an example to find the record in the table with “AL Compound Statement”.

find the record in the table with AL Compound Statement in d365 bc

Source Code:

codeunit 50001 “Custom Functions-01”
{
    trigger OnRun()
    begin
 
    end;
 
    local procedure HowToCountNoOfRecordsInTableinBCD365()
    Var
        ApplyFilteronSalesHeader: Record “Sales Header”;
        Counter: Integer;
    begin
        ApplyFilteronSalesHeader.reset;
        if ApplyFilteronSalesHeader.FindSET then begin //Use BEGIN-END statement in AL
            message(‘Record find.’);
        end;
    end;
}

Use of REPEAT-UNTIL in Dynamics 365
Skip Purchase Order Document deletion when it is fully posted
How to change Caption or Name of existing Field in D365 BC
How to add or show new field in existing Page in D365 BC
AL Control Statements– Microsoft Docs

Leave a Reply