ユーザー定義関数は、組み込み関数を呼び出すことができるほとんどの場所で呼び出すことができます。
FUNCTION キーワードを使用せずにユーザー定義関数を呼び出す場合は、その名前を REPOSITORY 段落で指定する必要があります。
次の例は、usedef というユーザー定義関数定義を含む翻訳群とその関数呼び出しを含むプログラムを示しています。
Identification division. Function-id. usedef. Program-id. jparse1.Linkage section. 01 Bal pic 999v999. 01 Spend pic 999v999. 01 res pic 999v999. Procedure division using Bal Spend returning res. compute res = Bal - Spend goback. End function usedef. Identification division. Program-id. 'caller'. Environment division. Configuration section.Program-id. jparse1.Working-storage section. 01 result pic 999v999 usage display. 01 dis-res pic 999v999. Procedure division. compute result = function usedef(10 9.99). move result to dis-res. display "Current balance = " dis-res. goback. End program 'caller'.
コンパイル後に「caller」プログラムを実行すると、出力は次のようになります。
Current balance = 000.010