Once LANSA debug mode has been turned on it can be used to aid in the location and correction of logic errors in the RDML commands that define what processing a function should perform.
To illustrate the use of LANSA debugging mode a process called EXAMPLE that has one function called ADDRECS is used. Function ADDRECS is to be debugged.
The RDML commands that define function ADDRECS follow and are used to add records to a name and address file named DEMNAME:
Seq | Lbl | Command | Parameters |
|---|---|---|---|
1 | GROUP_BY | NAME(#NAMESLIST) | |
FIELDS(#DEMNAC #DEMNAM #DEMAD1 #DEMAD2 #DEMAD3 #DEMPCD) | |||
3 | SET_MODE | TO(*ADD) | |
4 | L1 | CHANGE | FIELD(#NAMESLIST)TO(*DEFAULT) |
5 | DISPLAY | FIELDS(#NAMESLIST) | |
6 | INSERT | FIELDS(#NAMESLIST) TO_FILE(DEMNAME) | |
7 | GOTO | LABEL(L1) |
|
Debugging the RDML commands in ADDRECS is described in detail in the following steps.
Step 1
Turn LANSA debugging mode on. This has already been described.
Step 2
Select the option to use process EXAMPLE. This is exactly the same as electing to use process EXAMPLE in the normal way. This results in the menu associated with process EXAMPLE being displayed. Function ADDRECS is the first entry on the menu.
|
|---|
|
Step 3
Elect to use function ADDRECS from the display in Step 2. This is exactly the same as electing to use function ADDRECS in the normal way. The resulting display is the first "interruption" to the normal flow of events.
.......................................................
: F@DEBUG02 Add Records to the Name and Address file :
: :
: Select DEBUG option and press Enter :
: :
: _ 1.DEBUG Interactively :
: 2.TRACE All/Selective statements :
: 3.COUNT statements :
: :
: F3=Exit :
: :
:.....................................................:
This screen states that function ADDRECS is in debug mode and requests for the debug option to be selected. The DEBUG options have been previously described in this chapter.
If Options 1 or 2 were selected then the following displays will be shown requesting the relevant selections to be made. If Option 3 was selected then the function will immediately start to execute and act as if it is not in DEBUG mode i.e. no DEBUG interaction.
Step 4
For Options 1 and 2 only, the resulting display is the second "interruption" to the normal flow of events.
|
|---|
|
This screen states that function ADDRECS is in debug mode and requests that the RDML commands that are to be halted before execution are selected.
Note: On this screen it is possible to:
In this case statement 6 has been chosen. DEBUG will stop the function just before executing statement 6. (i.e. just before attempting to insert a new record into the name and address file).
Step 5
For Options 1 and 2 only, the resulting display is the third "interruption" to the normal flow of events.
|
|---|
|
This screen states that function ADDRECS is in debug mode and requests that the Function variables (if any) that are to be Displayed or printed at an execution halt is to be selected.
Note: On this screen it is possible to:
If no RDML commands were selected in Step 4 then this display will not be shown.
In this case the Function variables DEMAD1, DEMAD2 and DEMNAC have been chosen to be displayed/printed at execution halt, in this example the variables will be displayed/printed just prior to the execution of statement 6.
Step 6
Function ADDRECS now begins to execute. Statements 3 and 4 are executed. When statement 5 is executed the normal display results.
|
|---|
|
Into this screen, details of a new name and address are entered.
Step 7
When Enter is pressed in the preceding step function ADDRECS completes execution of statement 5. However, since debug is on it should halt before executing statement 6. If Option 1 from Step 3 was selected then the following debug display results otherwise the function continues processing.
|
|---|
|
Some points to note about this display are:
The "Act" column allows a number of actions to be taken on any of the fields displayed. These are:
D | Display the contents of the field. |
H | Display the contents of the field in hexadecimal form. |
P | Print the contents of the field. |
C | Change the contents of the field. |
When enter is pressed on this screen and assuming that no extra statements were added to halt execution via the "Edit Services Menu", the function ADDRECS will execute statement 6 and statement 7 which causes statement 4 to be executed again. When statement 5 is executed the display described in Step 6 will result again.
So the function continues to execute - stopping whenever requested to display or change the contents of fields.
Step 8
If Function key 10 is used the "Edit Services" Menu will be displayed.
|
|---|
|
The various options are:
The "Edit Services" menu is only ever available when the debug mode is on, debug option is DEBUG Interactively and when the function is at a debug statement halt.
Step 9
The final step in this example is to turn debug mode off and to display or print the Debug TRACE or COUNT report if selected.