Try OpenEdge Now
skip to main content
Programming Interfaces
External Program Interfaces : Host Language Call Interface : Using HLC library functions : Using a library function that writes to a shared buffer
 
Using a library function that writes to a shared buffer
When you use a CALL statement to invoke a routine that writes to a shared buffer, you must make sure that a transaction is active at the time of the call. For example, place the CALL statement in a DO TRANSACTION block, as shown in the following code fragment:
DEFINE NEW SHARED VARIABLE errcode AS INTEGER NO-UNDO.

DEFINE NEW SHARED BUFFER newcust   FOR CUSTOMER.

FIND FIRST newcust.

/* 1 */
DO TRANSACTION:
  . . .
/* 2 */
  CALL HLCROUTINE1.
  IF errcode = 2 THEN DO:
    MESSAGE "Unable to read newcust".
    UNDO, RETRY.
  END.
  . . .
/* 3 */
END.
These notes explain the transaction block:
1. The transaction begins.
2. The CALL statement is defined.
3. The transaction ends.
The explicit DO TRANSACTION statement is not the only way to create a transaction in ABL. For example, you create an implicit transaction when you use the UPDATE statement within a FOR EACH block.
If your C function calls an HLC library function that writes to a shared buffer, (for example, prowtbc()), and no transaction is active, the library function returns a non-zero return code value that indicates an error has occurred and an ABL error condition results. Use an ON ERROR phrase within your ABL code to handle ABL error conditions.