Was this helpful?
Callproc
Calls a database procedure, a procedure written in 4GL, or a procedure written in a supported 3GL such as ADA, C, COBOL, FORTRAN. Your system cannot support all of the programming languages listed.
Syntax
For database procedures or procedures written in 4GL:
[returnfield = [callproc] ] procname
 [([parameterlist])]
For procedures written in high-level 3GLs:
[returnfield = [callproc] ] procname 
  [([expression | byref (expression)
  {, expression | byref(expression)}])]
returnfield
Specifies the name of a field in the calling frame or procedure to receive the return value from the called procedure. The data type of the return field must agree with the return type of the called procedure.
procname
Specifies the name of the procedure you are calling. Enclose procedure names that are the same as 4GL keywords in quotes.
You cannot specify the name of a local 4GL procedure as the value of a variable.
parameterlist
Specifies a series of assignment statements separated by a semicolon (;) or comma (,).
Each assignment statement links a field or a variable in the keyword parameters of the initialize section in the called procedure with an expression, as shown below.
Simple assignments:
simpleobjectname :=  expression
simpleobjectname := byref(simpleobjectname)
On the left hand side of the assignment: simpleobjectname is the name of a field in the called procedure or a simple variable in the initialize section of the called frame.
On the right hand side of the assignment: simpleobjectname is the name of a field in the calling procedure or a simple variable in the calling frame.
For a simpleobject, byref() indicates that the object is passed by reference; this is discussed below. A complex object is always passed by reference; do not include the byref() statement.
Complex assignments:
arrayname := arrayname
recordname := recordname
callingformname.all
tablefieldname [[integerexpr]].all
On the left hand side of the assignment: arrayname and recordname are the names of objects in the initialize section of the called procedure.
On the right hand side of the assignment: arrayname and recordname are the names of objects in the calling procedure.
The .all syntax maps the simple fields in the calling form (or columns in the named table field) to the parameter list inside the procedure. Any field or column that does not correspond to a parameter is ignored.
expression
Specifies any legal 4GL expression that produces a simple-typed value
byref
Specifies a keyword indicating that a variable must be passed to the called procedure by reference
Description
The 4GL callproc statement calls a procedure from an ABF frame or procedure. A procedure is a routine written in 4GL, SQL, or a 3GL. A 4GL procedure can be global or local to its source file.
When using procedures, you can:
Include embedded query language statements in a procedure
Specify a procedure that returns a single value within an expression to the calling frame
Return multiple values to the calling frame by reference through the procedure's parameter list
Pass simple data types as parameters
You can use the reserved word all in the parameter list to a 4GL procedure, as shown below:
callproc procname (calling_formname.all |   
  calling_tablefield_name[[integer_expr]].all)
This syntax maps the simple fields in the calling form (or columns in the named table field) to the parameter list inside the procedure. Any field or column that does not correspond to a parameter is ignored.
Local variables and hidden columns are not mapped. When all is used with a table-field name, values are taken from the row on which the cursor is currently resting. To override this, specify an integer expression enclosed by brackets following the table-field name. In this case values are taken from the visible row with that number.
The keyword callproc is necessary except when the procedure returns a value that is used as a complete expression or as a constituent of an expression. In the latter case, you must omit the keyword callproc.
If you omit the keyword callproc, and you are not passing any parameters to the procedure, you must specify a pair of parentheses following the procedure name; for example:
x = proc1 ();
The name of the procedure must be the same as the one you give it within its source code. If your procedure name conflicts with a system-defined function, your procedure overrides the system‑defined function, except when you use the system-defined function within a query statement. You cannot call 4GL procedures within query statements. Use the Appplication-By-Forms -w flag to detect conflicts.
See your query language reference guide for a list of system‑defined functions and further information on the -w flag.
When a parameter is passed to a procedure, the parameter's value is transferred to a corresponding parameter inside the procedure. A parameter that is a simple field or a table‑field column can be passed either by value or by naming it in the statement.
The value for a field or table-field column passed by reference is not updated until the procedure returns to its calling frame.
When passing the value of a field or a column to a procedure by reference, be sure its data type, including nullability, is compatible with the corresponding parameter in the procedure. 4GL checks this at run time for 4GL procedures, but cannot check the data types for procedures written in other languages.
Because procname is a 4GL name, you can specify the name of the procedure at run time (unless the procedure is a local procedure). In this case, 4GL assumes that the return type is the same as the result value type. If the procedure attempts to return a value of an incompatible type, an error results at run time.
The following example calls the procedure specified in the procfield field of the current form and returns a value to the result field:
result = :procfield (x = 5, y = price);
Because the procedure name is a 4GL name, the colon is required when the value is to be supplied at run time. At run time, the application code supplies the correct procedure name for procfield on the current form, or it can be entered by you; then the named procedure is called. Note that the value of procfield cannot be a local procedure.
The following sections discuss 4GL procedures, 3GL procedures, and database procedures. The following 3GL procedures each have a separate section: ADA, C, COBOL, FORTRAN. Your system cannot support all of the programming languages listed. 4GL procedures are also discussed in Writing 4GL Statements.
Last modified date: 04/03/2024