perez_a
New User
Joined: 02 Feb 2006 Posts: 25 Location: Italy
|
|
|
|
HELLO FRIENDS,
I'M CREATING AN EXTERNAL UDF WITH HOST LANGUAGE COBOL.
I NEED TO RETURN ONLY 1 PARAMETER TO THE UDF, HOW CAN I DO?
I'VE FOUND THIS EXAMPLE:
WORKING-STORAGE SECTION.
77 EXCHANGE_RATE PIC S9(5)V9(5) PACKED-DECIMAL.
LINKAGE SECTION.
* PARAMETERS *
77 ORIGINAL_CURRENCY PIC XXX.
77 TARGET_CURRENCY PIC XXX.
77 EXCHANGE_DATE FORMAT DATE.
PROCEDURE DIVISION USING
BY REFERENCE ORIGINAL_CURRENCY
BY REFERENCE TARGET_CURRENCY
BY REFERENCE EXCHANGE_DATE
RETURNING EXCHANGE_RATE.
BUT THE STATEMENT "RETURNING" IS NOT ALLOWED.
PLEASE HELP ME!!!
BIE BIE ALEX |
|
anamikak
New User
Joined: 10 May 2006 Posts: 64 Location: Singapore
|
|
|
|
Specifying "RETURN" for UDF , that too in Procedure division is not allowed in COBOL. Always, you have only PROCEDURE DIVISION using parm1,parm2(ie, list of parameters).
Also before you start of writing external UDF, you have to define the UDF to DB2. This is done by using
CREATE FUNCTION function name(parmetr declaration with data type)
Returns (data type1, data type2...)
Parameter style SQL
Language COBOL;
so you see , The return statement is coded while defining the UDF and not in the external function that is written in host language, in this case it is COBOL.
after this, when you actually write the UDF in Cobol, you can declare the input and out partmeters in the Linkage section at 01 levels and in the the procedure division you can say "USING " pameters defined in linkage section.
hope this helps you. |
|