Breaking News
Loading...
Sunday 17 July 2016

How to use function in Microsoft Dynamics Navision

Function is nothing but the group of statement which is call multiple times as per requirement by writing its name only. For making the functions in NAV follow below steps. We have to make function witch will calculate the sum, division, multiplication, subtraction of give two number 

Step: 1 Create new code unit and save it with proper number and name. Then go to “View” =>>”C/AL Global” as show in figure.


Step: 2 in Open windows got to the “Function” tab. And write function name here I take “MyFunction”. After we have to define input parameter and output (return) data type and variables so now click on “Locals” button as show in right side.


Step:3 Now you can give parameters ,return parameter ,variables etc. here  we use 3 input parameter  Number1, Number2,Operation with its data type.




Step: 4 Now we specify the return variable he we use Result as show in below image.



Step: 5 now save your work and close the window by pressing “Esc” key. And go to the code unit designer page. Its shows the one more line with name “MyFunction”.



Step: 6 now write the code of you function as given below.


IF Operation='+' THEN
BEGIN
  Result:=Number1+Number2;
END
ELSE IF Operation='-' THEN
BEGIN
   Result:=Number1-Number2;
END
ELSE IF Operation='*' THEN
BEGIN
   Result:=Number1*Number2;
END
ELSE IF Operation='/' THEN
BEGIN
   Result:=Number1/Number2;
END;

(Note: I think you understand the function very well so I have no need to explain it in details)




Step: 6 Now call this function from the “OnRun()“ trigger of the code unit as show in bellow image 



Step: 7 now run the code unit and show the out put.



0 comments:

Post a Comment

Thanks for comment

 
Toggle Footer