To pass a TABLE-HANDLE by reference, use this syntax for the RUN statement in the calling routine:
( { [INPUT] | OUTPUT | INPUT-OUTPUT } TABLE-HANDLE tt-handle
 BY-REFERENCE).
The called routine defines the parameter using ordinary TABLE-HANDLE parameter syntax, with no BY-REFERENCE keyword:
DEFINE { [INPUT] | OUTPUT | INPUT-OUTPUT } PARAMETER TABLE-HANDLE tt-handle.
BY-REFERENCE appears only on the calling RUN statement, not on the parameter definition. (The BIND keyword, in contrast, must appear on both sides. See TABLE-HANDLE form with BIND.)
Note: If the called routine’s temp-table is a static temp-table, you can save the overhead of instantiating it by defining it as REFERENCE-ONLY:
DEFINE TEMP-TABLE temp-table-name REFERENCE-ONLY.

Example

In the following sample code, ProcA.p builds a dynamic temp-table at run time, runs ProcB.p persistently, then passes the temp-table handle to ProcB's addRecords internal procedure using the BY-REFERENCE keyword. Because the table is passed by reference, the AVM shares the caller's instance instead of copying its definition and data. ProcB.p adds records directly to the caller's temp-table through the handle. ProcA.p then reads those records back through the same instance using a dynamic query.

Note: BY-REFERENCE must be specified on every RUN statement that passes the parameter. If you omit it, the AVM makes an implicit copy of the temp-table instead of sharing the instance. If you need the sharing to persist for the life of a persistent procedure without repeating the keyword on each call, use BIND instead. See TABLE-HANDLE form with BIND.
ProcA.p (caller)
/* ProcA.p */
DEFINE VARIABLE hTT    AS HANDLE NO-UNDO.
DEFINE VARIABLE hTTBuf AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc  AS HANDLE NO-UNDO.

/* Build a dynamic temp-table with a single field. */
CREATE TEMP-TABLE hTT.
hTT:ADD-NEW-FIELD("Field1", "CHARACTER").
hTT:TEMP-TABLE-PREPARE("ttShared").
hTTBuf = hTT:DEFAULT-BUFFER-HANDLE.

/* Run ProcB.p persistently, then share the temp-table by reference. */
RUN ProcB.p PERSISTENT SET hProc.
RUN addRecords IN hProc (INPUT-OUTPUT TABLE-HANDLE hTT BY-REFERENCE).

/* Display the records that ProcB.p added to the shared instance. */
CREATE QUERY hQuery.
hQuery:SET-BUFFERS(hTTBuf).
hQuery:QUERY-PREPARE("FOR EACH ttShared").
hQuery:QUERY-OPEN().
hQuery:GET-FIRST().

REPEAT WHILE NOT hQuery:QUERY-OFF-END:
  DISPLAY hTTBuf:BUFFER-FIELD("Field1"):BUFFER-VALUE FORMAT "X(20)".
  hQuery:GET-NEXT().
END.

DELETE OBJECT hQuery.
DELETE OBJECT hProc. /* unload ProcB.p */
DELETE OBJECT hTT.
ProcB.p (callee)
/* ProcB.p */
PROCEDURE addRecords:
  DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE hTT.
  DEFINE VARIABLE hBuf AS HANDLE NO-UNDO.

  hBuf = hTT:DEFAULT-BUFFER-HANDLE.

  hBuf:BUFFER-CREATE().
  hBuf:BUFFER-FIELD("Field1"):BUFFER-VALUE = "Record1".

  hBuf:BUFFER-CREATE().
  hBuf:BUFFER-FIELD("Field1"):BUFFER-VALUE = "Record2".

  hBuf:BUFFER-CREATE().
  hBuf:BUFFER-FIELD("Field1"):BUFFER-VALUE = "Record3".
END PROCEDURE.