RefCall rule

Official Content
This documentation is valid for:

Used to call a program whenever referential integrity check fails.

This rule is used to call a program when referential integrity check fails. All attribute parameters are used, maintaining the order given by the parameter list, to form the foreign key; this foreign key is used to reference the desired table.

Syntax

RefCall('PgmName', par1 , ... , parN);

Where:
PgmName is the name of the program to be called when referential integrity check fails.

parN.... is the list of attributes or variables. Attributes determines the table to be referenced. Variables are used to give additional information to the program.

Description

The parameters par1,...,parN, can be attributes or variables. The attributes form the foreign key and the variables are used for additional information.

RefCall is basically used for two purposes:

  • To pass control to a Transaction object where the user will be able to enter the missing information.           
  • To pass control to a Procedure object that creates the missing information.

Notes

  • The called program must receive the same parameter list specified by RefCall().
  • In web transactions, the RefCall can not call an object with form (Web Panel or Web Transaction).
  • This rule implicitly reads the referenced table twice: the first time to verify that the reference was incorrect, and the second time to control that the values returned by the called program are a valid reference.

Examples

Given the following transactions:

Invoices              Customer                   CustomerProduct
{                     {                          {
   InvoiceNumber*        CustomerNumber*            CustomerNumber*
   InvoiceDate           CustomerName               ProductNumber*
   CustomerNumber        CustomerAdd                CustomerProductCause
   CustomerName          {                       }
{                           ProductNumber*
                            ProductName
                            InvoiceLineQtty
                            InvoiceLinePrice
                            InvoiceLineAmount
                         }
	              }

Case 1: Passing control to a Transaction which permits the insertion of missing data

The following rule is defined in the Invoice Transaction which calls the CustomerProduct Transaction whenever the referential integrity check fails, which latter permits the insertion of attribute values rectifying this failure.

Rules for Invoice Transaction:

RefCall('CustomerProduct',CustomerNumber,ProductNumber);

Rules for CustomerProduct Transaction:

Parm(&Customer, &Product);
&Customer = CustomerNumber On AfterComplete;
&Product  = ProductNumber  On AfterComplete;

Case 2: To create missing data

The following rule is defined in the Invoice Transaction which calls the Addition Procedure object whenever referential integrity check fails, which latter permits the insertion of attribute values rectifying this failure.

Rules for Invoice Transaction:

RefCall('Addition', CustomerNumber, ProductNumber, &CustomerProductCause);
&CustomerProductCause = 'Invoice-Insertion';

Procedure Addition (it is better to implement this using Business Components):

New
   CustomerNumber       = &Customer
   ProductNumber        = &Product
   CustomerProductCause = &CustomerProductCause
EndNew

Rules for Addition Procedure: 

Parm(&Customer, &Product, &CustomerProductCause);

Scope

Objects   Transaction object

See also

RefMsg Rule
Prompt rule






Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.