4.12.5 Use LANSA Debug Mode

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.

 

 EXAMPLE                    DEBUG EXAMPLE PROCESS                      

                                                                       

 Enter number of function or place cursor on same line and press enter 

                                                                       

   __ 1.  Add records to the name & address file                       

      2.  Display process or function HELP text                        

      3.  Display process main menu                                    

      4.  Select from list of available functions                      

      5.  Exit from system                                             

                                                                       

                                                                       

  Fnn=Help  Fnn=Exit  Fnn=Cancel  Fnn=Messages                         

 

 

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.

 

F@DEBUG02         Add Records to the Name and Address File             

                                                              Mode: DIS

Function ADDRECS is in debug mode. Choose from list below the commands

To be halted just prior to execution for display of debug information.

Position at Seq . . . . . ____                                         

Find . . .  _______________________________________________            

Debg Sq 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)                                 

  X  6     INSERT   FIELDS(#NAMESLIST) TO_FILE(DEMNAME)                

  _  7     GOTO     LABEL(L1)                                          

                                                                       

                                                                       

                                                                       

 F16=F/Fwd   F17=F/Bkwd   F20=Select All                               

 

 

 

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.

 

F@DEBUG02         Add Records to the Name and Address File             

                                                           Mode: DIS 

  Select Function Variables to be Displayed/Printed at Breakpoints     

                                                                       

  Search for Variable : __________                                   

                                                                       

 Act Field   RPG Name Description                        Type Len Dec 

  X  DEMAD1  DEMAD1   Address line 1                      A   25  0  

  X  DEMAD2  DEMAD2   Address line 2                      A   25  0  

  _  DEMAD3  DEMAD3   Address line 3                      A   25  0  

  X  DEMNAC  DEMNAC   Name Code                           A    6  0  

  _  DEMNAM  DEMNAM   Name                                A   25  0  

  _  DEMPCD  DEMPCD   Post Code                           A    4  0  

  _  IO$STS  IO$STS   LANSA database operation sts cde    A    2  0  

                                                                       

                                                                       

                                                                       

                                                                       

 

 

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.

 

 ADDRECS           Add Records to the Name and Address File    

 

 Name code       A00001                                                

 Name            ACME ENGINEERING AND CO                               

 Address line 1  121 AUSTRALIA STREET                                  

 Address line 2  NEWTOWN                                               

 Address line 3  SYDNEY, AUSTRALIA                                   

 Post code       2042                                                  

 

 Fnn=Help  Fnn=Exit  Fnn=Cancel  Fnn=Messages      

 

 

 

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.

 

 F@DEBUG02          Add Records to the Name and Address File           

                                                          Mode: DIS 

     Seq Lbl Command    Parameters                                     

       4 L1  CHANGE     FIELD(#NAMESLIST)  TO(*DEFAULT)                

       5     DISPLAY    FIELDS(#NAMESLIST)                             

       6     INSERT     FIELDS(#NAMESLIST) TO_FILE(DEMNAME)            

                                                                       

 Search For Variable : __________                                      

Enter action: D = normal display H = hex display P = Print C = change  

Act Field name  RPG name  Description                    Type Len Dec

 _  DEMAD1      DEMAD1    Address line 1                   A   25  0 

                       C: 121 AUSTRALIA STREET                         

                       Z: FFFFCEEEDCDCCFEEDCCE                         

                       D: 12101423913910239553                         

 _  DEMAD2      DEMAD2    Address line 2                   A   25  0 

                       C: NEWTOWN                                      

                       Z: DCEEDED                                      

                       D: 5563665                                      

 _  DEMNAC       DEMNAC   Name code                        A    6  0 

                       C: A00001                                       

                       Z: CFFFFF                                       

                       D: 100001                                       

                                                                       

                                                                       

 F10=Services  F11=Step Next  F15=Vars Y/N  F19=Hex Yes/No       

 

 

Some points to note about this display 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.

 

 F@DEBUG02          Add Records to the Name and Address File           

                                                            Mode: DIS 

     Seq Lbl Command    Parameters                                     

       4 L1  CHANGE     FIELD(#NAMESLIST)  TO(*DEFAULT)                

       5     DISPLAY    FIELDS(#NAMESLIST)                             

       6     INSERT     FIELDS(#NAMESLIST) TO_FILE(DEMNAME)            

                                                                       

                                                                       

 Search F .......................................................      

 Enter ac : F@DEBUG02  Add Records to the name and Address File :  e   

Act Field :                                                     :   Dec

 _  DEMAD : Select Debug Service Option and press Enter         :   0 

          :                                                     :      

          : _ 1. Review/Change Debug statements                 :      

          :   2. Remove ALL Debug statements                    :      

 _  DEMAD :   3. Review/Change Variables to display             :   0 

          :   4. Terminate Function                             :      

          :                                                     :      

          : F3=Exit Services                                    :      

 _  DEMNA :                                                     :   0 

          :.....................................................:      

                       Z: CFFFFF                                       

                       D: 100001                                       

                                                                       

                                                                       

 F10=Services  F11=Step Next  F15=Vars Y/N  F19=Hex Yes/No       

 

 

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.