We all at certain point in development need to debug the AL Code. Debugging is useful in finding the bugs in our code, by doing debugging we can analyse the code step by step.
Usually like any other programming language AL language also contains functions(procedures), variables. Since AL programming is an object based language we have records, tables, pages etc which contains fields, these fields will have certain values.
Table: In business central table holds all the data.
Record: Each row in table is called as record.
Page: UI which shows the data which is in the table.
Report: This object is used to generate reports which will have comprehensive data.
Codeunit: This object is used mainly to have logic(code) inside it.
To start debugging we need to first understand about breakpoints, a breakpoint will be set on a specific line of code, which will stop execution of code at that line while debugging. We can start analysing the code from this point.
Breakpoint is set at line 12
To start debugging we can open command palette (Ctrl + Shift + P)When you select Publish with Debugging, this will publish the latest app(if you have any new changes) to the BC server and starts debugging.
Continue: When you press continue it will stop at the next break point in the process of execution.
Step Over: When you click on step over it will execute the current line of code(this code can be a function call, it will execute all the code) and goes to the next line of code.
Step Into: When you click on step into if the current line of code contains a function call then it will go inside that function, for example in the above image at line 12 we have a function call I,e we are calling the function CheckItemIsBlocked so if you press step into, it will go inside the function CheckItemIsBlocked
Example:
Now the debugger is inside the function CheckItemIsBlocked
Step out: When you do step out it will execute all the logic inside the current function and goes to line of code from where it is called.
Example: After clicking on step over
The debugger came back to line 12 where the function call was done. Now if you do step into it will go to next line because line 12 is already executed when did step into for the first time
Restart: This will restart the debugging session
Stop: This will stop the debugging
In the first image on the left side we have Variables, Watch, Call Stack, Breakpoints.
Variables: In AL Programming language we can have local and global variables. The variables which are global to the whole object can be seen in Global section, the variables which are local (I,e declared inside the function) if the debugger is inside a function we can see all the local variables of this function in local section. The variables related to BC database can be seen in Database Statistics.
Watch: If you do add to watch to any variable or record that will be shown in watch section
Comments
Post a Comment