Introduction to Natural Construct

This document is intended for programmers who have never used Natural Construct. It introduces new users to the basic features and functions of the generation environment, as well as how Natural Construct works.

To get acquainted with the generation environment, follow the step-by-step instructions to create a simple menu program for an order entry application. If you encounter problems, try one or more of the following suggestions:

  • Display the online help as follows:

    • To view the help for a panel, press the help (PF1) key while the cursor is anywhere on the panel except an input field.

    • To view the help for an input field or select a parameter from a pop-up window, press PF1 or type "?" and press Enter when the cursor is in the field.

    If you do not specify a required parameter, or enter an incorrect one, Natural Construct will prompt you for the correct information.

  • Check relevant sections of Natural Construct Generation.

  • Visit our web site at to get timely product information, correspond with customer support representatives, or access related documents.

Although this guide deals mainly with the generation subsystem, Natural Construct contains two other subsystems. For information, see Help Subsystem, and Administration Subsystem.

This document covers the following topics:

What is Natural Construct?

Natural Construct is a powerful, easy-to-use, model-based application generator that helps you create and implement high-quality, robust Natural applications. It is built around and uses existing Natural facilities, which means that Natural Construct-generated applications can be deployed on most platforms or distributed across multi-tiered environments.

To Natural's production-oriented development environment and portable execution environment, Natural Construct adds:

  • a code generator (at a statement, as well as Natural object level)

  • a help maintenance system

  • a model maintenance system

These subsystems are described in the following sections.

Generation Subsystem

As a code generator, Natural Construct offers a wide range of reusable program structures, called models. These models allow even inexperienced programmers to generate fully functional applications using high-level, fill-in-the-blank specifications. And Natural Construct uses data defined in Predict, Software AG's data dictionary, to provide the default model specifications, such as local views and field prompts. You can also create your own verification or referential integrity rules in Predict for use with your Natural Construct-generated applications.

Help Subsystem

The help subsystem is designed for non-programmers. It separates the coding of an application from the creation of the online documentation. This separation allows business users or technical writers to write the online help information and programmers to concentrate on programming. In addition, the help subsystem supports multi-lingual help text. For information about this subsystem, see Natural Construct Help Text.

Administration Subsystem

The administration and modeling subsystem is used mainly by administrators. It allows them to modify the models supplied in the generation subsystem, create new models, and set security standards. For information about this subsystem, see Natural Construct Administration and Modeling.

Benefits of Using Natural Construct

There are many good reasons for using Natural Construct to create Natural applications. For example, you can:

  • Reduce development efforts by 50% (as reported by many customers)

  • Reduce training time and increase acceptance of new applications, as the generated programs have a consistent interface

  • Decrease the development time for complex applications and make fewer mistakes

  • Reduce checking and testing requirements; you can concentrate on the customized code

  • Reduce maintenance efforts by including business rules within the generated objects

  • Easily regenerate applications as requirements change

How Does Natural Construct Work?

Natural Construct is based on the premise that most applications have common functional blocks of code. These blocks of code became object templates, called models, which ensure that the required and expected aspects of each object type are incorporated into the generated object in a standard way.

Rather than re-engineering redundant routines each time you create an object, you can use the Natural Construct models to produce functionality-rich business applications that incorporate state-of-the-art technology.

Natural Construct uses the following information to generate an object:

  • The chosen model

  • The model specifications supplied by the programmer

  • Predict data, as required

  • Data coded in the user exits (optional)

For more information about designing or implementing a Natural Construct application, see Implementation Methodology or Design Methodology in Natural Construct Generation.

Choosing a Model

Natural Construct supplies more than 100 models, which are available through the Generation main menu. These models generate various programs, subprograms, helproutines, data areas, maps, Natural statements, etc. You can also invoke the statement models from the Natural and User Exit editors.

For client/server environments, Natural Construct provides a series of object maintenance and browse models (Object-Maint and Object-Browse models). In addition, Natural Construct supplies user exit models to assist you in writing user exit code.

Which model you choose depends on what you are doing. For example:

For help: Try:
Developing client/server applications Object-Maint and Object-Browse models (for information, see Generate a Business Object).
Remembering Natural syntax Statement models (for information, see Writing Natural Statements).
Testing Natural objects Driver or Maint models (for information, see Testing Subprograms and Helproutines or Creating Test Data).
Writing user exit code User exit models (for information, see Object-Browse Models in Natural Construct Generation).
Developing conventional applications (character-based interfaces) Maint model and/or models beginning with Browse or Browse-Select; also the Start, Menu, and Quit models.

The Browse and Browse-Select models are similar. Both models generate a browse (query) program that allows users to select and process a record, but the Browse-Select model provides more options. A generated browse program performs one pre-determined set of commands on a selected record (such as delete a record or modify a record); a generated browse-select program allows the user to specify which set of commands are performed.

Basically, the models can be grouped into four categories:

  • conventional

  • client/server

  • statement

  • user exit

Choose the model that provides the functionality you require. For example, to create the sample menu program later in this documentation, you'll use the Menu model. The following sections describe the most commonly used models in each category.

Conventional Models

These models generate non-distributed programs, subprograms, helproutines, data areas, and maps. The models in this category include:

Model Generates
Startup A startup program that initializes the application environment and invokes the menu and quit programs. It provides an easy way to set up initial global variables for an application.
Quit A quit program that releases application resources. It provides a common exit point from anywhere in an application.
Menu A menu program that controls the flow of work modules in an application.
Browse/Browse-Select A simple or complex browse program, subprogram, or helproutine that queries the database and allows users to browse through and select data for processing.
Maint An online maintenance program that allows users to select a record from the database and then perform a maintenance function (delete, for example). The program controls all data access and user interface requirements.
Map An external Natural map.
Batch A program that runs in batch mode to create a report or update the database.
Driver A driver program you can use to test and debug Natural subprograms and helproutines.
Shell A skeleton program you can use as a template when developing Natural programs.

For more information about these models, see the applicable section in Natural Construct Generation. For an example of using the Menu model, see Generate a Simple Program.

Client/Server Models

The models in this category generate the components required for a client/server application. They include:

Model Generates
Object-Maint-Subp An object subprogram that accesses data, performs updates, and enforces data integrity.
Object-Maint-Dialog An object dialog program that inputs the object map and invokes the object subprogram.
Object-Browse-Subp An object browse subprogram and the associated object PDAs, key PDAs, and restricted PDAs.
Object-Browse-Dialog A character-based dialog that works with an object browse subprogram.
Object-Browse-Dialog-Driver A driver program or helproutine that invokes an object browse dialog.

For more information about the client/server models, see the applicable section in Natural Construct Generation. For an example of creating an object maintenance process, see Generate a Business Object.

Statement Models

The statement models generate blocks of code containing one or more Natural statements, which you can use as building blocks when creating user exit code or specialized programs. Using the statement models assists you with the statement syntax and reduces the time required to write recurring code segments and test your code.

Typically, you invoke the statement models from the User Exit and Natural editors using a .g line command and the model name in brackets. For example, enter .g(view) to invoke the View statement model. Enter the .g commands in the same position as other line commands, such as the .i (insert) or .d (delete) command.

A few of the commonly used statement models are:

Model Generates
Callnat A Natural CALLNAT statement, which calls a subprogram for execution.
Decide-On A Natural DECIDE-ON statement, which specifies multiple actions to be performed (depending on the contents of a variable).
Get A Natural GET statement, which reads a record with a given Adabas ISN (internal sequence number) without initiating a processing loop.
View The definition of a view, as derived from Predict.

Natural Construct supplies more than 40 statement models. For information about these models, see Statement Models in Natural Construct Generation. For an example of using statement models, see Writing Natural Statements.

User Exit Models

These models generate text member modules containing the field layout specifications for an object browse dialog. The models are invoked from the User Exit editor using the User-Exit statement model. The user exit models are:

Model Generates
Input-Key Layout specifications for input fields and prompts on the dialog.
Export-Data-Fields Layout specifications for column headers and fields exported to an ASCII file on a PC.
Report-Data-Fields Layout specifications for column headers and fields routed to a printer.
Write-Data-Fields Layout specifications for column headers and fields displayed on a screen.

For more information, see User Exit Models and User-Exit Statement Model in Natural Construct Generation.

Defining the Model Specifications

Each model has at least one specification panel to collect specifications that are common to the code generated by that model. To help you fill in the parameters, most models supply default values for key fields. You need only specify any additional parameters the model requires to generate the appropriate code.

To create a menu program, for example, you must specify the following parameters:

  • A menu heading

  • The codes a user types to access options listed on the menu

  • Descriptions of the options

  • The name of the program executed to perform each option

Other parameters allow you to include optional features in your program.

When creating your specification documents, you can use the fields on the specification panels as a checklist to determine which parameters may be required.

Defining the Predict Data

Predict is a data dictionary system that centrally stores and manages all information about the metadata (data about data) for an organization. Natural Construct can use the metadata to accurately and consistently generate application code. Although a Natural Construct-generated application can be executed without Predict, the code generator relies on this metadata.

The main advantage of using Predict is that you can change the metadata and then regenerate the code to reflect the changes. For example, you can change a relationship between files in Predict, regenerate the code, and the new relationship is automatically incorporated.

Natural Construct uses the Predict metadata that describes:

  • File relationships, such as restricted or cascade delete constraints

  • File layouts

  • Field attributes, such as maximum occurrences, redefinitions, edit masks, validation rules, and headings

  • Field descriptions (for online help)

The help subsystem and Natural Construct-generated applications can be implemented in an existing Natural environment without Predict. To do this, you add the standard helproutine (CDHELPR) to the Natural map for which help is required. For more information, see Providing Online Help for Your Applications.

You can also create Predict metadata by documenting generated Natural objects. This option is available when you generate an object.

For more information about using Predict with Natural Construct, see Use of Predict in Natural Construct and Defining Objects and Relationships in Natural Construct Generation.

Defining User Exits

When specific customizations are required to fulfill your business needs, you can add additional code in a user exit. User exits are strategic points in the model outline, such as at the start of the program or after input. You choose which user exit you want based on the location of the exit within the code. If you are unsure of the location of a user exit, you can generate and edit the Natural object. The position of each user exit is shown in comments that begin with ** SAG Exit Point followed by the name of a user exit. For example:

** SAG Exit Point Change-History

These pointers indicate where the exit will be located in the generated code.

You enter user exit code in the User Exit editor, which you can access from the last specification panel for a model or when you enter U in the Function field on the Generation main menu. If you forget to choose an exit, you can display a list of available exits by entering "SAMPLE" on the command line in the editor.

You can place any Natural code within a user exit. The user exit code becomes part of the object's source code. If you regenerate the object, changes to the user exit code are always preserved.

Many models supplied with Natural Construct have user exits available. When you're creating an object, select the user exits you require and supply the appropriate code for each user exit. Natural Construct uses both the model specifications and the user exit code to create an object.

For more information, see User Exits for the Generation Models in Natural Construct Generation.

Generate a Simple Program

You're now ready to use Natural Construct to generate your first program the main menu for an order entry system. A main menu provides users with a selection of functions available within a system, such as the Generation main menu.

After generating the menu, you'll make a few changes to the specifications and regenerate the program.

The following diagram shows the modules used for the sample menu program:

Modules used for the sample menu program

Before You Begin

The sample menu, as well as other sample programs described in this guide, require access to several modules used in the Natural Construct demo system. The demo system is a fully functional order entry system that was generated using the Natural Construct models (see Natural Construct Demo System in Natural Construct Generation). Natural Construct supplies the following demo systems:

  • SYSCSTDE (Adabas)

  • SYSCSTD2 (DB2)



Examples in this guide refer to the SYSCSTDE demo system.

Before beginning this procedure, use the Natural SYSMAIN utility to copy the following modules from the demo library into your user library:

Module Description
MYMAP Map used by the object maintenance dialog example.
NCGDA Global data area (GDA) containing global variables. NCGDA is a modified copy of CDGDA, the standard global data area for Natural Construct-generated applications.
NCOSCSTO Drill-down browse subprogram invoked from NCOSCUST when the user selects an order.
NCOSCUST Browse program for the Browse Customer Orders option.
NCOSODET Subprogram used in the Callnat statement model example.
NCTFWHS1 Map used by the browse subprogram.
NCTFWHSB Browse subprogram invoked from NCTFWHSE when the user enters "B" in the Action field.
NCTFWHSE Maintenance program for the Maintain Warehouses option.

If you encounter problems trying to access the demo system or files (files beginning with NCST), your environment may not be set up. Contact your system administrator to set up the environment.

Generating the Menu Program

This section describes how to use the Menu model to generate a menu program.

Before beginning the procedure, ensure that the required modules have been copied to the current library. For a list of modules, see Before You Begin.

Start of instruction setTo generate the menu program

  1. At the Natural prompt, logon to your Natural Construct library.

  2. Enter "ncstg". The Generation main menu is displayed:

    CSGMAIN              N a t u r a l   C o n s t r u c t                 CSGMNM0 
    Oct 22                       Generation Main Menu                       1 of 1 
                       R  Read Specifications                                      
                       M  Modify Specifications                                    
                       U  User Exit Editor                                         
                       G  Generate Source                                          
                       T  Test Source                                              
                       E  Edit Source                                              
                       S  Save Source                                              
                       W  Stow Source                                              
                       L  List Modules                                             
                       C  Clear Edit Buffer                                        
                       ?  Help                                                     
                       .  Return                                                   
    Function ......... _  Module ............. ________ Panel ...... __            
    Model ............ ________________________________ Type .......               
    Command .......... ________________________________ Library .... MYLIB         
          help        quit        optns                                     lang

    Typing "M" on the main menu is the equivalent of Create New.

    For more information about the Generation main menu or the Generation subsystem, see Using the Generation Subsystem, in Natural Construct Generation.

  3. Specify the following:

    M Function field
    MYMENU Module field
    Menu Model field

    If you do not specify a model name, Natural Construct displays a selection window.

  4. Press Enter. The Standard Parameters panel for the Menu model is displayed. Notice that some of the fields are filled in for you, based on values you specified on the main menu:

    CUMNMA                           MENU Program                          CU--MA0 
    Oct 22                       Standard Parameters                        1 of 2 
     Module ............. MYMENU__                                                 
     System ............. MYLIB___________________________                         
     Global data area ... CDGDA___                                                 
     With block ......... ________________________________                         
     Title .............. Menu ..._________________                                
     Description ........ This menu ...__________________________________________  
     First heading ...... ________________________________________________         
     Second heading ..... ______________________________________________________   
     Command ............ _                                                        
     Message numbers .... _                                                        
     Password ........... _                                                        
    right help  retrn quit                                            right main
  5. Type "First Heading for My Menu" in the First header field.

    We aren't using the remaining fields on this panel. If you're curious about what these fields are used for, you can type "?" and press Enter to invoke Natural Construct's online help or see General Model Specifications in Natural Construct Generation.

  6. Press Enter. The Additional Parameters panel is displayed:

    CUMNMB                           MENU Program                          CUMNMB0 
    Oct 22                      Additional Parameters                       2 of 2 
      Map layout ......... ________ *                                              
         Code  Functions____________________________________  Program Name         
        ------ --------------------------------------------- --------------        
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          __   _____________________________________________   ________ *          
          help  retrn quit        optns attr                    left  userX main

    For this example, leave the Map layout field blank. This allows Natural Construct to create a default (internal) map layout. If you've created an external map layout tailored to your shop standards, you could type the name of that map in this field.

    For more information about this panel, press PF1 (help) to invoke the online help or see Additional Parameters Panel in Natural Construct Generation.

  7. Specify the following:

    MW 1st Code field
    Maintain Warehouses On line to the right of the 1st Code field
    NCTFWHSE 1st Program field
    BC 2nd Code field
    Browse Customer Orders On line to the right of the 2nd Code field
    NCOSCUST 2nd Program field

    These parameters specify the codes the user enters to invoke the corresponding menu functions, the names of the functions, and the names of the programs invoked to perform the function.

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

  9. Enter "G" in the Function field. A confirmation message is displayed, indicating that the generation was successful.

  10. Enter "W" in the Function field. A confirmation message is displayed. Your menu program is now generated and stowed.

    For more information about these functions, see Generate Source Function and Stow Generated Source Function in Natural Construct Generation.

    To see the code generated by the Menu model, enter "E" in the Function field.

    To see what the menu will look like to users, enter "T" in the Function field. The following menu is displayed:

    MYMENU              ***** First Heading for My Menu *****                      
    Oct 22                                                                 5:18 PM 
                   Code Functions                                                  
                   ---- -------------------------                                  
                    MW  Maintain Warehouses                                        
                    BC  Browse Customer Orders                                     
                    ?   Help                                                       
                    .   Terminate                                                  
                   ---- -------------------------                                  
              Code: __                                                             
          help  retrn quit        flip                                      main
  11. Press PF2 (retrn). You are returned to the Generation main menu.

    You've successfully created a sample menu program. Next, you'll see how easy it is to change a few of the specifications and regenerate the menu program.

    If you have any problems creating the menu, see Troubleshooting and Debugging for possible reasons.

Regenerating the Menu Program

This section describes how to change some of the specifications for the menu and then regenerate the program. The procedure begins at the Generation main menu.

Start of instruction setTo change the specifications and regenerate the menu program

  1. Enter "M" in the Function field.

    "MYMENU" and "Menu" should be displayed in the Module and Model fields.

    The Standard Parameters panel is displayed, showing the specifications you entered when you created the menu.

  2. Enter "Second Heading for My Menu" in the Second header field. The Additional Parameters panel is displayed.

  3. Select the word "Functions" and type "Options". On the generated menu, Options will be displayed instead of Functions.

  4. Enclose the words "Maintain" and "Browse" within angle brackets (for example, <Maintain>Warehouses and <Browse>Customer Orders).

    Angle brackets are the default intensify characters for Natural Construct. They indicate that the enclosed text is highlighted on the generated menu screen.

    Notice that the intensify characters are placed in the space between words; they do not take up a physical space.

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

  6. Enter "G" in the Function field. Natural Construct regenerates the menu program, incorporating your changes.

  7. Enter "W" in the Function field. Your menu is now regenerated and stowed.

  8. Enter "T" in the Function field. The following menu is displayed:

    MYMENU              ***** First Heading for My Menu *****                      
    Oct 22                 - Second Heading for My Menu -                  5:21 PM 
                   Code Options                                                    
                   ---- -------------------------                                  
                    MC  Maintain Warehouses                                        
                    BW  Browse Customer Orders                                     
                    ?   Help                                                       
                    .   Terminate                                                  
                   ---- -------------------------                                  
              Code: __                                                             
          help  retrn quit        flip                                      main

    You've successfully changed the specifications and regenerated the menu program. Now that you're familiar with the generation subsystem, see Natural Construct for New Application Development for information about creating a Natural Construct business object.

Creating Specification Documents

A common task an analyst performs is writing the specifications for a new program. Natural Construct can help create a list of questions you can use to create these documents.

  • The first question is whether the program will be used in a client/server environment or as a stand-alone program. This answer restricts the range of models you should use.

  • The next question is whether the program will query or maintain data, which further restricts the model selection.

Once you've selected a model, you can use the fields on the model specification panels to determine what parameters may be required. For example, the following figure shows the first specification panel for the Menu model:

 CUMNMA                           MENU Program                          CU--MA0 
 Oct 22                       Standard Parameters                        1 of 2 

  Module ............. MYMENU__                                                 
  System ............. MYLIB___________________________                         
  Global data area ... CDGDA___                                                 
  With block ......... ________________________________                         

  Title .............. Menu ..._________________                                
  Description ........ This menu ...__________________________________________  

  First heading ...... ________________________________________________         
  Second heading ..... ______________________________________________________   

  Command ............ _                                                        
  Message numbers .... _                                                        
  Password ........... _                                                        

 right help  retrn quit                                            right main

Use the fields on this panel to determine what information is required to create the menu program. For example:

  • What is the name of the menu program? This question is important if you must adhere to standardized naming conventions.

  • What will it do?

  • What is the first heading on the menu screen?

  • What is the second heading?

  • Will the menu allow users to access the Natural command line?

  • Will the menu be implemented in different languages?

  • Will the menu require security restrictions?

Press Enter to display the Additional Parameters panel and use the fields on that panel to determine other questions you need to answer. Once you have the answers to all these questions, you can easily write the specification document for the menu.

Utilities Supplied with Natural Construct

Natural Construct supplies many utilities to aid in the application development process. These utilities are described in different Natural Construct guides, depending on their function. The following table lists each guide and some of the utilities it describes:

Guide Describes utilities to:
Natural Construct Administration and Modeling

Transfer data across dissimilar platforms

Print a list of all code frames

Compare two source modules

Compare modules in two libraries

Convert Natural Construct components to uppercase

Natural Construct Generation

Transfer data across dissimilar platforms

Export models to a work file

Import models from a work file

Insert all INCLUDE statements into generated code (used for debugging)

Submit JCL

Convert the contents of the source buffer to uppercase

Regenerate multiple modules (either online or in batch)

Trace and debug Natural modules

Natural Construct Help Text

Print a copy of help text members

Unload members to a work file

Load members from a work or PC file to the help text file

Save the contents of the source buffer to the help text file