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”.
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; } |