funcntion that return array

how can i define a funtion that return 2 value??

i try to define the following function:

FN_F1(p_FromDate : Date;p_ToDate : Date) Value : ARRAY [2] OF Decimal

----some code -----
Value[1] := l_Value[1];
Value[2] := l_Value[2];

amoun1 := FN_F1[1]

amoun2 := FN_F1[2]

But its not working

Apparently you can declare an array as a return value in NAV. But I am not sure if you actually can use it.
I have never seen this being used anywhere.

I use reference parameters for this instead.

It may be an ugly logic,

Try this in worst case. Concatenate the two values which you want to return each separated by a comma like this “val1,val2” and return the concatenated string. Then split the text into 2 decimal values using selectstr function.

This is the right solution.

Unfortunately, it doesn’t look like return values can be an array

Here is a example codeunit that I use for web service calls where a page is not conducive to retrieving the right data. The function returns an array of production order component record ids for the given production order. The web service client can then read the components individually by record id.

PROCEDURE ProdOrderComponentKeys@1000000004(ProdOrder@1000000000 : Record 5405) returnIDs : ARRAY [50] OF Text[100];

VAR

ProdOrderComponents@1000000001 : Record 5407;

RecordRef@1000000002 : RecordRef;

RecordID@1000000003 : RecordID;

Index@1000000004 : Integer;

BEGIN

WITH ProdOrder DO BEGIN

ProdOrderComponents.RESET;

ProdOrderComponents.SETCURRENTKEY(Status, “Prod. Order No.”,“Prod. Order Line No.”,“Line No.”);

ProdOrderComponents.SETRANGE(Status,ProdOrder.Status);

ProdOrderComponents.SETRANGE(“Prod. Order No.”,ProdOrder.“No.”);

IF ProdOrderComponents.FINDSET THEN BEGIN

Index := 1;

REPEAT

RecordRef.GETTABLE(ProdOrderComponents);

RecordID := RecordRef.RECORDID;

returnIDs[Index] := FORMAT(RecordID);

Index := Index + 1;

UNTIL ((ProdOrderComponents.NEXT = 0) OR (Index > 50));

END ELSE BEGIN

returnIDs[1] :=’ ';

END;

END;

END;

What are “reference parameters” and how to declare them?[:P]

OK Got it Sorry![;)]

Tick the VAR field at the beginning of your parameter field specified in the local window and the specified parameter becomes a reference parameter.[8-|]