Built-In Functions - 2

678 Views


Quit

The *QUIT built-in function specifies an exit from an action diagram sequence construct or user point; when you specify the *QUIT function, all subsequent steps in the construct (or subroutine) are bypassed.

When you specify the *QUIT function within a sequential construct, Synon defines a branch to the end of the subroutine.

If you use the *QUIT function outside of a sequential construct, Synon defines a branch to the closest, most recently nested, subroutine which, in many instances, is the user point.

To limit the action of *QUIT, you can enclose actions within a sequential construct.

There are no parameters for this built-in function. Synon implements the *QUIT built-in function as a GOTO statement for both RPG and COBOL.

In the following example, the step Update database is not executed if errors occur:

:"
: ..Validate fields
: ..Validate relations
: -CASE
: | -If errors
: | <"QUIT
: -ENDCASE
: ..Update database
’"

Retrieve Condition

The *RTVCND built-in function specifies that the name of a given condition is to be retrieved into a function field.

This can be of particular use if you want to show the full description of a condition next to the condition on a panel or report.

The convert condition values command (YCVTCNDVAL) creates a file which stores the condition data. This file will be in the generation library whenever you execute it.

There are two parameters for this function type:

· One input parameter which is the status field name.

· One output parameter which is the work field into which the condition is retrieved. Both parameter fields are of usage type vary (VRY).

Example To specify that the description of the current value of the Gender field is to be shown in the Gender Name field of an EDTRCD function, you could add a Gender Name field to the function’s device design, and insert the following action in the function’s action diagram:

> USER:
:-
: DTL. Gender name = Condition name of DTL. Gender <<<
’"

You can provide Retrieve Condition functionality with F4 prompting by setting the CUA Prompt (YCUAPMT) model value to *CALC and inserting the *RTVCND built-in function at a CALC: user point in the action diagram.

Rollback

The *ROLLBACK built-in function allows you to add your own rollback points to a program that is executing under OS/400 commitment control.

Commitment control is a method of grouping database file operations that allows the processing of a database change to be either fully processed (COMMIT) or fully removed (ROLLBACK).

There are no parameters for this function type.

Synon implements the *ROLLBACK built-in function as an RPG ROLBK statement and as a COBOL ROLLBACK statement.

Set Cursor

The *SET CURSOR built-in function allows you to explicitly position the cursor on any field on the device design by specifying the field name and the context to which it belongs.

In addition, the *SET CURSOR built-in function allows you to control cursor positioning based on the occurrence of errors.

There are two input parameters for this function type:

· Field name on which the cursor is positioned.

· *Override error field that is conditional and can take a value of *YES or *NO. It determines whether cursor positioning takes place based on the occurrence of an error.

You cannot use *SET CURSOR to override cursor positioning due to errors generated by display files such as values list errors on status fields.

These errors are implemented below the level of the application program in the display device or file.

The following is an example of the Set Cursor function. In this example, if the Customer Status field is Active, move the cursor to the Customer Name field.

Substring

The *SUBSTRING built-in function allows you to extract a portion of a character string from one field and insert it into another.

There are five parameters for this function type:

· Three input parameters which are a character string, *String 1, denoting the character substring that is to be extracted, the *From position field denoting the position from which the extraction of the character string will occur, and the *For length field denoting the length of the character substring to be extracted.

· Two output parameters which are the *Resulting string into which the extracted substring will be inserted and a *Return code to determine the result of the attempted insertion.

Return code is an implied parameter and is set to condition *NORMAL when insertion completes successfully.

The *For Length field has two special conditions: *FLDLEN which indicates that the entire length of the field or constant is to be used and *END which means that the extraction will occur from theposition of the *From position field to the end of the field or constant.

Synon implements the *SUBSTRING built-in function in RPG via the SUBSTR statement in COBOL via the STRING statement. For COBOL 85, it is via reference modification and for COBOL, 74 it is via string manipulation.

The following is an example of a substring function. This example extracts the first six characters from the Full Name field.

Subtract

The *SUB built-in function specifies an arithmetic subtraction on two operands, *FACTOR1 and *FACTOR2.

There are three parameters for this function type:

· Two input parameters which are the two operands, *FACTOR1 and *FACTOR2.

· One output parameter which is the *Result field containing the result of the subtraction.

All three parameters must be numeric field types. Synon implements the *SUB built-in function as an RPG SUB statement and as a COBOL SUBTRACT statement.

> USER: Process detail record
:"
: RCD. Difference = RCD. Entered val - WRK .Calc val <<<
’"

 

Post Comments