This article provides an example of the use of the FUNCTION-ID paragraph with the RDFPATH and REPOSITORY directives.
Problem:
The FUNCTION-ID paragraph can be used in the IDENTIFICATION DIVISION to name an external function. When a program that uses this function is compiled, the following error message appears:
1304-S Method not found in repository
Resolution:
The RDFPATH should be used to compile the function program (mydouble.cbl in the example below) if the repository is generated somewhere different to the source folder. It should be used with the program that uses it (mymain.cbl) if the repository has to be searched somewhere different from the source folder or any of the directories in the $COBCPY environment variable (if defined). If both are used, the function and the main program are compiled with the same value in the RDFPATH directive, the 1304-S error message should not occur. The following example runs fine:
cob mydouble.cbl -C RDFPATH=.
cob cmain.cbl -C RDFPATH=.
cobrun cmain.int
cmain.cbl:
$SET REPOSITORY(CHECKING OFF)
123456 IDENTIFICATION DIVISION.
PROGRAM-ID. PROG.
repository.
function abc as "mydouble".
WORKING-STORAGE SECTION.
01 NUM-1 PIC 99.
01 NUM-2 PIC 99.
PROCEDURE DIVISION.
move 4 to num-1.
compute num-2 = function abc ( num-1).
display num-1
display num-2
mydouble.cbl:
$set repository(update on)
123456 IDENTIFICATION DIVISION.
FUNCTION-ID. MYDO AS "mydouble".
ENVIRONMENT DIVISION.
DATA DIVISION.
LINKAGE SECTION.
01 A-NUMBER PIC 99.
01 b-NUMBER PIC 99 comp.
PROCEDURE DIVISION USING A-NUMBER
returning b-number.
COMPUTE b-NUMBER = A-NUMBER * 2 .
move a-number to return-code.
END FUNCTION MYDO.