Version 8.2.7
 —  Using NaturalONE  —

Working with Objects in a Natural Project

This document covers the following topics:


Creating Natural Objects

In the Eclipse workspace, you can create a Natural object in different ways:

Start of instruction setTo create a new Natural object using a wizard

  1. In the Navigator view or in the Natural Navigator view, select the Natural library in which you want to store the new object.

  2. From the File menu, choose New > object-type, where object-type can be one of the following:

    Program
    Subprogram
    Subroutine
    Function
    Copycode
    Helproutine
    Text
    Global Data Area
    Local Data Area
    Parameter Data Area
    Map
    DDM

    Or:
    Invoke the context menu and choose New > object-type.

    Tip:
    When you invoke the context menu in the Natural Navigator view, the items under New are grouped according to the plug-ins by which they are provided.

    A dialog box appears for the selected object type. For example:

    Create Natural program

  3. Specify the following information:

    Option Description
    Project The project in which the object is to be created. If you have selected a library before invoking this dialog box, the project name is automatically shown in this text box. However, if you have not selected a library (or if you have invoked the dialog box, for example, in a new empty workspace), you have to enter the name of a project to be created.
    Folder The folder in the file system in which the object will be created. Using the Browse button, you can select a different folder.
    Library The library in which the object is to be created. If you have selected a library before invoking this dialog box, the library name is automatically shown in this text box. However, if you have not selected a library, you have to specify the library yourself. The dialog box that is invoked by choosing the Browse button only offers Natural libraries for selection. Other folders on the same level which are not recognized as Natural libraries are not offered for selection.
    Use new folder as library folder Only enabled when you have specified a new folder name. If you want to store the new object in a new library folder, enable this check box. In this case, a new library is created as a library folder. It is important that you specify the new folder name as shown in the following example:
    /TUTORIAL/mylibfolder

    Do not omit the slashes and the library name.

    Load library properties from secured environment Only enabled when Natural Security is active in the associated Natural environment. When enabled, this check box is automatically activated when you add the object to a library which does not yet exist in your workspace. In this case, the library properties for the newly created library are loaded from the server. If a corresponding library does not exist on the server, the properties from the logon library of that server are used. If the associated Natural environment is not accessible, a dialog box appears. In this case, you can either cancel or continue the operation. If you continue, the properties are set to the defaults of the selected project.

    When Natural Security is active and this check box is deactivated, the properties for the newly created library are set to the defaults of the selected project.

    Object type Read-only. Indicates the object type that will be created.
    DDM name Only shown when you create a DDM. This is the long name of the DDM as it is used in a program.
    Object name A name for the new object. This name must correspond to the Natural naming conventions.
    File name The name that you enter as the object name is automatically provided as the file name. If you want, you can enter a different file name for this object.

    As long as both the object name and file name are identical, a file name is not used. The file name is only shown in the Navigator view or in the Natural Navigator view when it is different from the object name. This enables you to use a file name which does not adhere to the Natural naming conventions (for example, when it contains lowercase characters).

    File location Read-only. Shows the path where the new object will be created in the file system.

    The path that is shown here depends on the setting of the Group new objects by object type option in the project properties. When this option is not selected, this path may include the special folder SRC or a library folder. When this option is selected, the path includes the appropriate group folder for the current object type. For further information, see Group Folders.

    The notation ".../" which is shown in front of the path is used to indicate that the project name and, if used, the name of the library root folder are also part of the path. For example, ".../" can stand for "/MyFirstProject/Natural-Libraries/".

    Programming mode Select either Structured or Reporting. The programming mode as specified in the project properties is provided as the default value (see the description of the parser options). For further information on the programming modes, see the Programming Guide in the Natural documentation for the appropriate platform.

    Note:
    A programming mode cannot be specified when you create a new DDM or text. The corresponding drop-down list box is disabled in these cases.

    Note:
    When you create a new DDM, additional pages are available in the wizard. See Creating a DDM for further information.

  4. Choose the Finish button.

    The new object is created in the specified library and the associated editor is automatically invoked. See Using the Natural Editors for further information.

    Note:
    When you create a new Natural object which uses the source editor, a skeleton which is typical for this type of object is automatically provided in the source editor. If you want to change a skeleton, see Object Templates in Setting the Preferences.

Top of page

Changing the Object Properties

Some of the object properties (such as programming mode and code page) are stored in the source header.

Start of instruction setTo change the object properties

  1. Select the object in the Navigator view or in the Natural Navigator view.

  2. Invoke the context menu and choose Properties.

  3. In the tree of the resulting dialog box, select the Natural node.

    The following property page is shown (example for a program).

    Object properties

    If available, the long name of an object is shown. For a DDM, the database ID and file number are also shown.

    Note:
    If the object is currently open in an editor and if the editor content has been changed but not yet saved (indicated by an asterisk in the editor tab), the options on this property page are disabled. It is only possible to change the options when the editor content does not contain unsaved changes (that is when the editor tab does not contain an asterisk).

  4. Make all required changes.

    Option Description
    Object name

    The object name must adhere to the Natural naming conventions. When a file name has been defined, you can only change the object name in the object properties.

    Note:
    The file name is defined by renaming the object directly in the workspace.

    With the default label decorations, the new object name is shown in parentheses in the Navigator view or in the Natural Navigator view, directly behind the file name.

    Important:
    When you change the object name in the properties, make sure to adapt this name in the code of all other Natural objects which reference this object.

    Programming mode

    Structured mode is intended for the implementation of complex applications with a clear and well-defined program structure. It is recommended to use structured mode exclusively.

    Reporting mode is only useful for the creation of ad hoc reports and small programs which do not involve complex data and/or programming constructs.

    For further information on the programming modes, see the Programming Guide in the Natural documentation for the appropriate platform.

    Server encoding

    This drop-down list box provides for selection the same code pages that are available in the properties of the corresponding project. Select the code page that is to be used when the object is stored on the server. For further information, see Unicode and Code Page Support.

  5. Choose the OK button to save your changes and to close the dialog box.

Top of page

Editing Objects

When you edit a Natural object, the appropriate editor is invoked.

Start of instruction setTo edit Natural objects

  1. In the Navigator view or in the Natural Navigator view, select the object(s) that you want to edit.

  2. Invoke the context menu and choose Open.

    Or:
    Double-click each object that you want to open.

    An editor window appears for each selected object. See Using the Natural Editors for further information.

Top of page

Saving Objects

Object sources are saved using the standard Eclipse functionality.

Note:
In the Natural preferences, you can specify that all changes to an object source are automatically updated on the server. See also Updating the Objects in the Natural Environment.

Start of instruction setTo save an object

  1. Activate the editor window for the source that you want to save.

  2. From the File menu, choose Save.

    Or:
    Press CTRL+S.

Top of page

Printing Objects

You can print object sources in two different ways, either directly from the source editor or from the Natural Navigator view.

When you print an object source from the source editor, the Eclipse functionality is used. The printout always contains the same information which is currently shown in the editor. This includes the source header, expanded and collapsed nodes, and, if enabled, line numbers.

When you print an object source from the Natural Navigator view, the printout contains Natural-specific information. It has a header containing the object name and object type, and the date and time of printing. The printout always shows the complete Natural code, without line numbers and without the source header.

Start of instruction setTo print an object from the Natural Navigator view

  1. In the Natural Navigator view, select the object that you want to print.

  2. From the File menu, choose Print.

    Or:
    Invoke the context menu and choose Print.

    Or:
    Press CTRL+P.

  3. In the resulting Print dialog box, specify all required information and choose the Print button.

Top of page

Executing Objects

To execute a Natural program with NaturalONE, you must first compile it in your Natural environment in order to create a generated program in this environment. See also Updating the Objects in the Natural Environment.

The library in which a generated program is executed is determined by the mode you have defined for the project (either shared mode or private mode). See Steplibs in Changing the Project Properties for further information.

Important:
On a Natural server, Web I/O must be enabled. Otherwise, the output of an executed program cannot be displayed.

This section covers the following topics:

Executing an Object

When using the local Natural runtime, you can immediately execute an object without having to define a launch configuration. However, if you want to execute an object on a Natural server, a launch configuration is used (see Creating a Launch Configuration for Execution).

Start of instruction setTo execute an object

  1. In the Navigator view or in the Natural Navigator view, select the program that you want to execute.

  2. Invoke the context menu and choose NaturalONE > Execute.

    The object is executed in your Natural environment (either the local Natural runtime or a Natural server). The output is either shown in the internal browser or in an external browser, depending on the settings in the Natural preferences or in the launch configuration that you have created (see below). Example for the internal browser:

    Output

Creating a Launch Configuration for Execution

In the Eclipse environment, a so-called "launch configuration" is supplied for execution and debugging purposes. A launch configuration describes the environment that is used during execution/debugging. It also includes the name of the object to be executed/debugged. A launch configuration is defined once for each object which is used to start an application.

The first time you execute an application on a Natural server, you must make sure that the appropriate information is defined in the launch configuration. This is not required when you execute objects with the local Natural runtime.

You can create a launch configuration as described below. However, if you are developing your application mainly for one platform, there is an easier way: you define a default configuration in the Natural preferences (see Natural I/O > Runtime in Setting the Preferences). If you have already defined a default configuration in the Natural preferences, you can skip the following instruction and execute the object immediately as described above.

Note:
The launch configuration for execution uses the same information that you specify for debugging. See Debugging Natural Applications.

Start of instruction setTo create a launch configuration for execution

  1. In the Navigator view, select the program that you want to execute.

  2. From the context menu, choose Run As > Run Configurations.

    The Run Configurations dialog box appears.

  3. Expand the Natural Application node.

  4. Choose the "New" button (shown on top of the tree) to create a new launch configuration.

    Or:
    Select the Default Launch entry.

    Note:
    The Default Launch entry is only available after you have executed (or debugged) a program. It always contains the information that was used with the last execute (or debug) operation.

    Default launch configuration

    Make sure that the appropriate information is specified on the following pages:

  5. Choose the Apply button to save your changes.

    You can now choose the Run button to execute your program.

Defining a Different Start Library for Execution

When designing an application, the startup program is sometimes located in a steplib, and the main program which is invoked by the startup program is located in a different library. In order to run the startup program directly from the steplib, you have to define a different start library in the launch configuration of the startup program, using the option Start in library. This option corresponds to the Natural system command LOGON which is available with Natural for Mainframes, UNIX, OpenVMS and Windows.

If you define a different start library for a program, you must always start this program using the Run As > Run Configurations or Run As > Natural Application command. If you use the Execute command instead, a new default launch configuration is always created which automatically uses the current library. See also Which Configuration is Used for Execution?.

Example

Suppose your application has the following structure: The project properties define the library STEP as the steplib for all libraries within your project. The library MYLIB contains the main program named MYPROG, and the library STEP contains the startup program named MENU. The program MENU calls the program MYPROG which is located in a different library.

Example

When you try to run the application by executing the program MENU, an error will occur because the program MYPROG cannot be found in the current library STEP. To avoid this error, you have to define a different start library as described below.

Note:
When working with Natural itself (for example, with Natural for Mainframes), this would not be a problem: You would define STEP as a steplib of MYLIB so that the program MENU can be found in the steplib. Then you would simply LOGON to the library MYLIB and EXECUTE the program MENU.

Start of instruction set To define a different start library (example)

  1. Select the program MENU and from the context menu, choose Run As > Run Configurations (see also Creating a Launch Configuration for Execution).

  2. Select the Natural Application node and create a new launch configuration for the program MENU.

  3. Go to the Natural Server page.

  4. Change the preset value in the Start in library text box from STEP to MYLIB.

    Natural server

  5. Choose the Apply button to save your changes.

  6. Choose the Run button.

    The changed launch configuration now causes a logon to the library MYLIB so that MYPROG in that library can be executed.

    Once the new launch configuration for the program MENU exists, you can always invoke it by choosing the Run As > Natural Application command.

Which Configuration is Used for Execution?

The following table lists the different commands that can be used to execute an object and describes the type of configuration that is used with each of these commands.

Command Description
Execute

With each Execute command, a new launch configuration is automatically created which handles the current execution. This new launch configuration is named Default Launch; it overwrites an existing Default Launch launch configuration.

The necessary application server information is taken from the Natural preferences, and the Natural server information is taken from the project properties.

If no Execute or Debug command has been performed within the current environment, no Default Launch configuration is visible in the Run Configurations or Debug Configurations dialog box.

When a Default Launch entry exists in the above dialog boxes, it describes the last execute or debug command that has been performed.

Run As > Run Configurations Using this command you have the possibility to create a new launch configuration or to reuse an existing configuration. You have to select the desired configuration manually (see also Creating a Launch Configuration for Execution).
Run As > Natural Application This command first checks whether a launch configuration exists. When a launch configuration is found, it is used to execute the program. When a launch configuration does not yet exist, this command performs the same steps as described above for the Execute command: it creates a new launch configuration named Default Launch.

Top of page

Copying and Pasting Objects and Libraries

You can use the commands Copy and Paste in the Navigator view and in the Natural Navigator view. Whereas the Navigator view follows the Eclipse-specific rules, the Natural Navigator view provides enhanced, Natural-specific support for copying and pasting Natural objects and libraries.

Caution:
While the creation of new Natural sources via the wizards is under the control of NaturalONE, the creation of Natural sources via copy-and-paste is under the control of Eclipse. This does not cause problems with Natural projects since they use UTF-8 by default. However, it may cause problems with the copy when you are pasting into a non-Natural project - wrong characters may be shown because Eclipse uses a different code page. To solve the problem with the code page, you have to set the default encoding for text files to UTF-8 in the Eclipse preferences (under Preferences > General > Workspace > Text file encoding).

This section covers the following topics:

Navigator View

When you copy and paste objects in the Navigator view, there are no special restrictions as to the folder structure. However, you have to make sure that the pasted objects are always assigned to a library. You also have to make sure that valid Natural object names are used, especially when you copy an object and paste it in the same location as the original object. The name proposal that is offered by Eclipse does not meet the Natural naming conventions.

Natural Navigator View

How objects and libraries are copied and pasted in the Natural Navigator view depends on the settings of the toggle buttons in the local toolbar of that view and also on your project settings. For a description of the toggle buttons, see Using the Natural Navigator View.

Copying Objects from the File System

All Natural objects in the workspace follow specific format conventions. Each object is automatically converted into the appropriate code page during the download from the Natural server.

If the contents of your files follow the Natural format conventions and if the file names adhere to the naming conventions for Natural objects, you can drag (or copy and paste) your files from the file system (for example, from the Windows Explorer) to the Navigator view or to the Natural Navigator view, or you can drag them within the file system to the folder which is defined as your Eclipse workspace. NaturalONE will recognize these files as Natural objects.

In addition to the Natural objects which adhere to the Natural naming conventions, your workspace may also contain Natural objects for which alternative file names have been defined (with any combination of uppercase and lowercase in the file name, but with uppercase in the file extension). In this case, it is important that the Natural object name which adheres to the Natural naming conventions can be found in the source header of the file. Otherwise, the file will not be considered as a valid Natural object when you copy (or drag) it to your Eclipse workspace or to the Navigator view or Natural Navigator view.

If the new files are not immediately shown in the Navigator view or Natural Navigator view, you have to refresh the display.

Top of page

Moving Objects and Libraries

In the Navigator view, which follows the Eclipse-specific rules, you can use the Move command, or you can use drag-and-drop. When you use the Move command with a selected library or object, a dialog box appears in which you can choose the destination for the selected objects. Such a dialog box does not appear when using drag-and-drop.

The Natural Navigator view provides enhanced, Natural-specific support for cutting and pasting Natural objects and libraries. How objects and libraries are cut and pasted in the Natural Navigator view depends on the settings of the toggle buttons in the local toolbar of that view and also on your project settings. See also the information under Copying and Pasting Objects and Libraries.

When you cut an object in the Natural Navigator view and paste it on a node in the Natural Navigator view, the source object is deleted after it has been copied to the target node. The deletion, however, will only work if the paste operation is performed in the Natural Navigator view. If you cut an object in the Natural Navigator view and paste it in the standard Eclipse Navigator view, this will be handled as a copy operation.

Top of page

Renaming Objects and Libraries

You can use the Rename command in the Navigator view and in the Natural Navigator view. Whereas the Navigator view follows the Eclipse-specific rules, the Natural Navigator view provides enhanced, Natural-specific support for renaming Natural objects and libraries.

Important:
On the Natural server, only object names and library names are used. They must adhere to the Natural naming convention for this platform. When you update the Natural server, the handling for renamed objects on the Natural server is determined by the option Scratch server objects in the Natural preferences (see Natural > Builder in Setting the Preferences).

This section covers the following topics:

Navigator View

When you rename an object or library in the Navigator view, keep the following in mind: As long as the new name adheres to the Natural naming conventions, the name is considered as an object name or library name. When the new name no longer adheres to the Natural naming conventions (for example, when it is longer than 8 characters and/or contains lowercase characters), it is considered as a file name or library folder name. However, when a library folder name is renamed in such a way that it again adheres to the Natural naming conventions, the new name is then considered as a library name. With file names, this is slightly different: The new name is only considered as an object name when the original object name (which is shown in parentheses when a file name exists) and the new name are identical.

When a file name is defined, the object name can be changed in the object properties. When a library folder name is defined, a different library can be assigned in the library properties.

Start of instruction setTo rename an object or library

  1. In the Navigator view, select the node that is to be renamed.

  2. Invoke the context menu and choose Rename.

    The following dialog box appears.

    Rename

  3. Enter a new name.

    Warning:
    Do not change the file extension of an object. This will corrupt your application, and the object can no longer be edited with the appropriate editor.
  4. Optional. If you want to see which changes are performed and which objects are affected by this operation, choose the Preview button.

    Information such as the following can be shown. The object reference will automatically be changed in all objects (callees) for which the corresponding check box is selected.

    Rename

    Note:
    A list of callees is only shown when the Natural object name is changed, that is, the name which is referenced in the code of other Natural objects. When the name change results in a file name, a list of callees is not shown since such a change does not affect the code in other Natural objects.

  5. Choose the OK button to rename the node.

Natural Navigator View

When you rename an object in the Natural Navigator view, you can be sure that the names of the libraries and objects follow the Natural naming conventions and that they meet the requirements for Natural objects (for example, when you change the object type).

Start of instruction setTo rename an object or library

  1. In the Natural Navigator view, select the node that is to be renamed.

  2. Invoke the context menu and choose Rename.

    Or:
    Press F2.

    The following dialog box appears when you rename an object.

    Rename object

    The following dialog box appears when you rename a library.

    Rename library

  3. Enter a new object name or library name.

    Or:
    Enter a new file name for an object, or a new folder name for a library.

    Or:
    Enter both a new object name and a new file name for an object, or a new library name and a new folder name for a library.

  4. Optional. If you want to change the object type (for example, from program to subprogram), select the corresponding entry from the Object type drop-down list box.

    Only the allowed object types are available from this drop-down list box. A local data area, for example, can only be changed to a global data area or to a parameter data area.

    It is not possible to change the object type for a map. Therefore, this drop-down list box is dimmed when renaming maps.

  5. Optional. If you want to see which changes are performed and which objects are affected by this operation, choose the Preview button.

    The same information is shown as when renaming an object in the Navigator view. The object reference will automatically be changed in all objects (callees) for which the corresponding check box is selected.

    Note:
    A list of callees is only shown when the Natural object name is changed, that is, the name which is referenced in the code of other Natural objects. When the name change results in a file name, a list of callees is not shown since such a change does not affect the code in other Natural objects.

  6. Choose the OK button to complete the rename operation.

Top of page

Deleting Objects and Libraries

You can delete any Natural objects and libraries in the Navigator view or Natural Navigator view.

When you update the Natural server, the handling for deleted objects on the Natural server is determined by the option Scratch server objects in the Natural preferences (see Natural > Builder in Setting the Preferences).

Start of instruction setTo delete an object or library

  1. In the Navigator view or in the Natural Navigator view, select the node that is to be deleted.

  2. Invoke the context menu and choose Delete.

    A dialog box appears, asking whether you really want to delete the node from the file system.

    In the Natural Navigator view, it is possible to delete nodes which do not physically exist in the file system (for example, a Programs group node). If you are about to delete such a node, a special dialog box appears, asking, for example, if you want to delete all programs located in the current library or library folder from the file system.

  3. Choose the OK button (Navigator view) or the Yes button (Natural Navigator view) to delete the node.

Top of page