NaturalONE Version 8.3.7
 —  Code Generation  —

Defining User Exits

This section explains what a user exit is and how to select and define one in NaturalONE. The following topics are covered:


Introduction

By default, the generated source code is protected from editing and changes can only be made within user exits, positions within the generated code where you can insert customized or specialized processing. Changes to the user exit code are always preserved upon subsequent regeneration of the module. We recommend that you only add custom code within user exits.

Warning:
Although it is not recommended, you can edit the protected lines in the generated source code outside of the user exits. However, your changes will not be preserved upon regeneration. For information about the protected lines in the generated source code, see Using the Source Editor/Protected Lines in Sources Generated by Construct or Code Generation in Using NaturalONE.

The code generation wizards provide a wide variety of user exits, which vary based on the type of module you are generating. Some exits contain sample code or subprograms, while others generate the **SAG DEFINE EXIT and **SAG END-EXIT tags only — you provide the actual code. You can modify any user exit code generated into the edit buffer.

Notes:

  1. For information on the supplied user exits, refer to User Exits for the Generation Models, Natural Construct Generation.
  2. For information about the User Exit editor, refer to User Exit Editor, Natural Construct Generation.
  3. If you require code to be inserted in the generated module where no user exit currently exists, have your Natural Construct administrator recommend a suitable exit or add a new exit to the wizard.

Top of page

Define a User Exit

When a generated module is open in the Eclipse editor, all available user exits for the module are displayed in the Outline view. This section covers the following topics:

Tip:
If the user exits are not displayed in the Outline view, select graphics/user-exit-icon.png on the toolbar.

Access a User Exit

Start of instruction setTo access a user exit

  1. Select the user exit in the Outline view.

  2. Open the context menu for the user exit.

    For example:

    graphics/context-menu-for-user-exit.png

  3. Select one of the options listed.

    The user exit is displayed in the editor view. For example:

    graphics/user-exit-in-editor.png

    The **SAG EXIT POINT tag indicates that the exit does not exist and you must use the Outline view to add code or generate sample code.

Add Code to a User Exit

Start of instruction setTo add code to a user exit

  1. Open the context menu for the user exit.

  2. Select Add Code.

    The exit is displayed in the editor view. For example:

    graphics/user-exit-add-code.png

    The **SAG DEFINE EXIT and **SAG END-EXIT tags indicate that the user exit exists, even when there is currently no code in it, and you can define or modify the exit directly in the editor.

  3. Move the cursor to the end of the **SAG DEFINE EXIT user-exit-name line.

  4. Select Enter.

  5. Add the code on the lines provided.

Generate Sample

Start of instruction setTo add code to a user exit

  1. Open the context menu for the user exit.

  2. Select Generate Sample.

    The **SAG DEFINE EXIT and **SAG END-EXIT lines are displayed with sample code. For example:

    graphics/user-exit-generate-sample.png

  3. Move the cursor to the end of the **SAG DEFINE EXIT user-exit-name line.

  4. Modify the sample code as required.

Clear Exit

Start of instruction setTo clear code from an existing user exit

  1. Open the context menu for the user exit in the Outline view.

  2. Select Clear Exit.

    All lines of code within the selected exit are deleted and the comment line that identifies the insertion point for the exit within the editor is restored.

Modify Code in a User Exit

Start of instruction setTo modify code in a user exit

  1. Select the user exit in the Outline view.

    The user exit is displayed in the editor.

  2. Modify and save the user exit.

Note:
You can make changes to user exits equivalent to the Add Code and Clear Exit options by modifying these lines in the editor view — without using the context menu for the Outline view. If you do this, ensure you do not change the ** SAG comment lines.

Top of page