Troubleshooting and Debugging

If you encounter problems while using Natural Construct, there are a few things you can try before contacting your Natural Construct administrator. This document describes some of the methods you can use to troubleshoot and/or debug your applications.

Note:
Many of these methods are applicable to any Natural program, not just Natural Construct-generated programs.

Natural Construct provides several utilities you can use to trace and debug Natural modules. For information about these and other utilities, see Supplied Generation Utilities in Natural Construct Generation.

This document covers the following topics:


Specifying Parameters

This section contains suggestions you can try if you encounter problems when specifying the model parameters.

Check the Online Help

Before contacting your administrator, check the online help available from each model specification panel. For example, many required fields have active help available. If you press the help PF-key when the cursor is in the field, a window is displayed listing valid entries for that field.

For more information about using the online help, see Getting Online Help in Natural Construct Generation.

Look at the Demo System

Another suggestion is to look at the demo system supplied with Natural Construct. The demo system is a fully functional order entry application generated using Natural Construct.

There are two ways you can use the demo system for troubleshooting your programs. You can:

  • display the model specification panels to see what values were entered for a similar program in the demo system

  • look at the generated code to see how a similar program is structured

  • invoke the demo system to see how the programs run and interact

The following sections describe each of these options.

Display the Model Specification Panels

Start of instruction setTo display the model specification panels for a program in the demo system

  1. Logon to the demo (SYSCSTDE, for example) library.

  2. Enter "ncstg" at the Natural Next prompt. The Generation main menu is displayed.

  3. Enter "L" in the Function field. The Select Module window is displayed:

    CSGLIST                   Natural Construct                   CSGLIST0  
    Oct 22                      Select Module                       1 of 1  
    
      Module                Model                        Title              
    ---------- -------------------------------- -------------------------   
    CUSBRSUB   OBJECT-BROWSE-SUBP               Object Browse ...           
    CUSBR020   OBJECT-BROWSE-STATIC             Object Browse Static ...    
    CUSTN      OBJECT-MAINT-SUBP                Customer Maintenance        
    EMPLBR     OBJECT-BROWSE-SUBP               Employee Browse Object      
    MENU       STARTUP                          Demo System Startup Pgm     
    MYMENU     MENU                             Menu ...                    
    MYORDSUB   OBJECT-MAINT-SUBP                Order Maintenance Subprog   
    MYORMSA    OBJECT-MAINT-PDA                                             
    MYORMSR    OBJECT-MAINT-PDA-R                                           
    NCCFCSTB   BROWSE-SUBP                      Browse Customer File        
    NCCFCUST   OBJECT-MAINT-DIALOG              Customer Maintenance        
    Module ... ________  Model .... ________________________________        
    Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11  
          help  retrn                         bkwrd frwrd                   
    Position cursor or enter screen value to select

    This window lists the modules contained in the demo library. It shows the module names, the type of model used to generate the modules, and a brief description of each module.

    Note:
    For more information about this window, see List Generated Modules Function in Natural Construct Generation.

  4. Move the cursor to the line containing the module for which you want to see specifications.

  5. Press Enter. You are returned to the Generation main menu.

    The name of the module you selected is displayed in the Module field and the name of the model used to generate the module is displayed in the Model field.

  6. Enter "M" in the Function field. The first specification panel for the selected module is displayed. Continue pressing Enter to display all specification panels for the module. Press Enter again to return to the main menu.

  7. Enter "U" in the Function field. The user exits for the selected module are displayed.

Display the Generated Code

Start of instruction setTo display the code generated for a program in the demo system

  1. Logon to the demo library (SYSCSTDE, for example).

  2. Enter "ncstg" at the Natural Next prompt. The Generation main menu is displayed.

  3. Enter "L" in the Function field. The Select Module window is displayed.

  4. Move the cursor to the line containing the module for which you want to see generated code.

  5. Press Enter. You are returned to the Generation main menu.

  6. Enter "E" in the Function field. The code generated for the selected module is displayed.

Invoke the Demo System

Start of instruction setTo display the model specification panels for a program in the demo system

  1. Logon to the demo library.

  2. Enter "menu" at the Natural Next prompt. The main menu for the demo system is displayed.

Generating Programs

This section contains troubleshooting suggestions you can try if you encounter problems when generating programs.

Display the Embedded Statements

When you generate a module from the Generation main menu, a status window is displayed showing the progress of the generation. If a problem occurs, you can optionally regenerate the module and display the embedded statements that perform the generation processing. You can then determine where in the problem occurred.

Start of instruction setTo display the embedded statements

  1. Prior to generating the module, press PF5 (optns) on the Generation main menu. The Optional Parameters window is displayed:

     CSGOPTS             Natural Construct             CSGOPTS0 
     Oct 25             Optional Parameters              1 of 1 
    
       Status window ................ X                         
                         Step ....... _                         
                         Text ....... _                         
       Embedded statements .......... _                         
       Condition codes .............. _                         
       Post-generation modifications  _                         
    
       Specifications only .......... _                         
       Document in PREDICT .......... _                         
     Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9- 
           help  retrn quit
  2. Mark the Embedded statements field.

  3. Press Enter.

  4. Enter "G" in the Function field. The status window is displayed, showing the progress of generation.

    When generation is complete, enter "E" in the Function field. The embedded statements are displayed in the generated code.

    The following example shows the first 25 lines of code generated by the Object-Maint-Dialog model. An embedded statement is displayed on line 0040:

    0010 **SAG GENERATOR: OBJECT-MAINT-DIALOG              VERSION: n.n.n        
    0020 **SAG TITLE: Order Maintenance Dialog                                   
    0030 **SAG SYSTEM: MYLIB                                                     
    0040 **> Trace ...... --> SAVE CUOMS                                         
    0050 **SAG GDA: CDGDA                                                        
    0070 **SAG DESCS(1): This program is used to maintain the order business     
    0080 **SAG DESCS(2): object.                                                 
    0090 **SAG HEADER1: Order Entry System                                       
    0100 **SAG HEADER2: Maintain Customer Orders                                 
    0110 **SAG DIRECT-COMMAND-PROCESS:                                           
    0140 **SAG OBJECT-NAME: MYORDSUB                                             
    0150 **SAG ACTIONS: 0101010101010000                                         
    0160 **SAG ACTION-LENGTH: 2                                                  
    0190 **SAG ACTIONS-AS-PUSH-BUTTONS: X                                        
    0200 **SAG MAX-WINDOWS: 1                                                    
    0210 **SAG MAP-NAME(1): MYMAP                                                
    0220 **SAG UPPER-BOUNDS(1,1): 00030                                          
    0230 **SAG UPPER-BOUNDS(1,2): 00010                                          
    0240 **SAG UPPER-BOUNDS(1,3): 00020                                          
    0250 **SAG SCREEN-OCCURS(1,1): 001

    After determining where the error occurred, contact your system administrator.

    Note:
    The problem may have occurred in a code frame, a block of code that performs a specific function. The Natural Construct models use code frames, as well as subprograms, in the generation process. For example, the C--BAN9 code frame supplies the standard banner that appears at the top of all generated modules.

Working in the Editor

This section contains troubleshooting suggestions you can try if you encounter problems while working in the Natural editor.

Determine the Last Command Issued

While working in the editor, you may not always remember which command was issued when an error occurred. If this happens, you can display the name of the last command by typing an asterisk (*) on the command line and pressing Enter.

To display a list of the last 10 (or less) commands issued, type "LAST *" and press Enter:

                  LAST                   
    _  NPC CSGMENU                       
    _  NPC CSGMAIN                       
    _  NPC      CSGMAIN                  
    _  RENUMBER                          
    _  STOW                              
    _  NPC      CSGMAIN                  
    _  RENUMBER                          
    _  STOW                              
    _  ? NAT0247

Note:
This functionality is only available in the Natural editor (not the User Exit editor or Help Text editor).

Viewing Error Messages

This section contains information about viewing Natural error messages.

Determine The Last Error

Sometimes you require the number of the last Natural error that occurred. One method of determining the error number is to enter "TECH" at the Next prompt.

Note:
You can also issue the TECH command on the command line in the Natural editor.

A series of three windows is displayed:

 23:05:21                                       01-10-22  

 User ................. SACAPR                            
 Library .............. MYLIB                             

 Version / SM Level ... 2.3 / 0004                        
 Startup Transaction ..                                   
 NATURAL SECURITY ..... Yes                               
 Operating System ..... MVS/ESA                           
 Oper. Sys. Version ... SP6.0.5                           
 Machine Class ........ MAINFRAME                         
 Hardware ............. 7060                              
 TP Monitor ........... COMPLETE                          
 Device Type .......... COLOR                             
 Terminal ID .......... 1      3                          

 Last Command ......... STOW

This window shows information about the current settings, such as the user and library names, the operating system, and the terminal ID. It also lists the name of the last command issued. Press Enter to display the second window:

 23:05:53                                       01-10-22 

 Last Error                                              
   Error Number ....... 247                              

   Error Line ......... 1950                             
   Object ............. MYORDDIA                         
   Object Type ........ Program                          
   Level .............. 0                                
   Library ............                                  
   DBID/FNR ...........                                  

   Error Class ........ System                           
   Error Type ......... Syntax                           
   Error Time ......... 2001-10-22 23:05:01              

   Error Transaction ..

This window shows the number of the last error, as well as the error line, class, type, and time. In the example above, 82 is displayed in the Error Number field. Since error numbers consist of four digits, the actual error number is 0082.

Press Enter again to display the last window:

 23:06:26                                       01-10-22 

   Steplib   DBID  FNR       Object   Type Level         
   --------  ----- -----     -------- ---- -----         
   SYSTEM    196   4                                     
   SYSTEM    196   3

This window shows information about the steplib chain, database ID, and file number.

Note:
The steplib chain indicates the order in which libraries are searched in the current library. The current library is searched first, then the first steplib, second steplib, etc., up to the eighth steplib (if present). The SYSTEM library is searched last.

Once you know the error number, you can use the method described in the following section to view the error message.

Display a Natural Error Message

Once you know the number of a Natural error, you can display the associated error message text.

Start of instruction setTo display the message text

  1. Type "?" and the four-digit error number at the Next prompt (? 0247, for this example).

    Note:
    You can also issue this command on the command line in the Natural editor.

  2. Press Enter. The following window is displayed:

    23:08:00               ***** NATURAL HELP UTILITY *****                01-10-22
    Library MYLIB         - NATURAL System Message NAT0247 -               Page 1  
    
       Error in automatic parameter :1: for map.                                   
    
    Tx *** Short Text ***                                                          
    
       Error in automatic parameter ... for map.                                   
    
    Ex *** Explanation ***                                                         
    
       A parameter which is included for a constant input map or write map         
       without explicit parameter specification is invalid or undefined.           
    
    Ac *** Recommended Action ***                                                  
    
       Correct error in program.

    After reading the text, you can determine what to do next.

Using the Natural Debugging Tool

To help debug your Natural programs, you can also use the Natural debugging tool. This tool allows you to place break points and watch points at strategic locations in your code.

The procedure to run this utility differs depending on the platform. For more information, see the Natural documentation for your platform.