4 12 5 Use LANSA Debug Mode

LANSA for i

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:

  • Find a particular sequence number. To do this, enter the sequence number required in the 'Position at Seq' field and press enter. If the sequence number entered is beyond the range of sequence number, the last sequence number will be displayed.
  • Find forwards. To find a particular string of characters enter them into the 'Find' field and select command key 16. If the string is found, the cursor will position on the first character. Please note that words split over lines will not be found.
  • Find backwards. To find a particular string of characters in the RDML prior to where the cursor is currently, enter them into the 'Find' field and select command key 17. If the string is found, the cursor will position on the first character. Please note that words split over lines will not be found.
  • Select all RDML lines. To select all the available RDML statements for breakpoint, use command key 20. The Select Variables screen will then be displayed.
  • When RDML statements are selected, they will automatically be retained, along with any selected variables. When the function is run again under debug mode, the previous RDML statements selected will be indicated as selected. This will occur within the duration of a job. The retained breakpoints will be lost after signing off and also if the function is recompiled since they were selected.

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 data base 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:

  • search for a variable. To do this, enter the required variable name into the 'Search for Variable' field and press Enter.
  • Select all variables. To select all the available variables for display at breakpoint, use command key 20. The next screen will then be displayed.

 

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:

  • The statement about to be executed is indicated at the top of the screen and is highlighted. It is possible to roll through the top display of three RDML lines to show statements which come before and after the current statement.
  • The bottom half of the screen displays all the fields that were selected from Step 5. Shown are the LANSA field name, the RPG field name, the description, Value of the fields (in Character, Zone and Decimal formats), type and length. If the LANSA field name is more than 6 characters long it will be different to the RPG field name. LANSA internally renames fields that are more than 6 characters long so that the RPG program will compile.
  • The "Search for Variable" allows input for a variable name to be searched for against the list of variables that were requested to be displayed from Step 5. The Search if found will position the Cursor against that variable or in the case of a Generic search the cursor will be positioned against the first variable meeting the Generic search criteria.
  • 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.

 

  • The function key "F10=Services" allows the various Debug service options to be actioned from a POP UP style services menu. This will be explained in Step 8.
  • The function key "F11=Step Next" allows the execution of the current statement and then halt at the next statement to be executed.
  • The function key "F15=Vars Y/N" allows the display to be shown with:
  • variables and only three lines of RDML or
  • without variables but a full screen of RDML lines.
  • The function key "F19=Hex Yes/No" allows the display to be shown with hex values or without hex values.

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:

  • Review/Change Debug statements.
    This allows the review of statements that have been selected to halt the function to either add further statements or remove current statements. This process and the resulting display is identical to Step 4.
  • Remove ALL Debug statements.
    This will automatically remove all statements that have been selected from Step 4 which will allow the function to continue processing without being halted.
  • Review/Change Variables to display.
    This allows the review of Function variables that have been selected to be displayed at selected debug statements. This process and resulting display is identical to Step 5.
  • Terminate Function.
    This allows the function to be terminated and return control to the current process menu. Function key 3 will Exit from the "Services Menu" and return to the display as in Step 7.

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.