Step 2. Use Breakpoints
WAM055 - Using LANSA Debug
1. Open WAM iiiSecMaint in the editor. Set a breakpoint on the WebRoutine name(Begin) statement. To set the breakpoint, select the line and then use F9 or use the context mouse menu option option. Breakpoint lines are highlighted in red.
Your source code should now look like the following:
2. Open the WebRoutine Begin in . Run the WAM in debug mode using the button on the ribbon, or use the menu option from the Toolbar Menu button:
Note: You can use the button on the Home ribbon, to run a WAM/WebRoutine executed earlier.
3. When the WAM starts in debug mode in the browser, it will immediately switch focus to the LANSA Editor, because WebRoutine Begin is run immediately, and it has a breakpoint defined, the breakpoint WebRoutine statement will be highlighted in yellow. This is the statement that is about to be executed as shown:
Note: in debug, program variables are shown on the
tab, in the left hand side pane, including working lists.
A
ribbon is shown at the top of the editor:
a. Use the
button or F5, to run straight through this WebRoutine.
The initial page will be displayed in the web browser.
b. Start typing into the department code input box and notice that debug stops at the AutoComplete WebRoutine:
This happened because Debug has a general setting to
. To check this, select on the menu:
c. Select the Debug icon.
d. Uncheck the
Press F5 to continue running the WAM.
e. With a valid department such as ADM or AUD entered, click the
button. Focus will return to the WebRoutine statement for Begin in the editor and it will be highlighted in yellow as before.f. Use the
button or F8, to step through the WebRoutine one line at a time. If necessary use F5 to run through to the end of the Begin WebRoutine.g. Use the
button to run all code up to the cursor position. To try this, press F5 to run through to the end of the WebRoutine. Enter a department code and click the button. In the Editor, position the cursor on the following statement in the Begin WebRoutine. Click the button. You should run all code up to the SELECT statement and then stop.SELECT FIELDS(#sec_list) FROM_FILE(sectab) WITH_KEY(#deptment)
h. Use the
button to run the code up to next breakpoint. In the editor set the SELECT statement to be a breakpoint and run the Begin WebRoutine again. Now use the button to execute the routine up to the SELECT statement. You could also have used the F5 key to achieve this. Use F8 to run around the SELECT loop. Notice the changing values of the variables shown in the tab. That is, the value of variables DEPTMENT, SECTION, SECDESC etc. If necessary now use F5 to run to the end of the WebRoutine.i. Use the
button to execute the procedure called by the current line and break at the line following the current line. is identical to except when the current statement contains a call to a procedure, executes this procedure as a unit and then steps to the next statement in the current procedure.j. Use the
button on the ribbon. In the web browser, enter a department code and click the Select button. In the LANSA Editor, clear the breakpoint on the SELECT statement. To do this, select the SELECT line, and use the F9 key, or the button on the ribbon to clear this breakpoint.4. Set a breakpoint on the line
ADD_ENTRY TO_LIST(#sec_list).
Use the right mouse menu and select
, and set the pass count to 3 and press OK.
5. Remove the breakpoint from the Begin WebRoutine statement.
a. Press F5 twice to run to the end of the WebRoutine.
b. When focus returns to the LANSA Editor, expand the SECT_LIST entry in the tab.
Note: The list SECT_LIST contain 2 entries currently.
Also notice the
tab shows a passcount of 3 for this breakpoint. i.e. the ADD_ENTRY statement is about to be executed for the third time.
If the
tab is not visible, select it from the ribbon / gallery.d. Press F5 to continue running. Note that each time the program breaks, 2 more entries have been added to the list (the third entry is about to be added).
5. Click OK to save the condition and press F5 to continue running the WAM. The breakpoint will next occur when SECTION has the chosen value.