RE: Putting code into function
Hi you can create function. You can create function with return value, or just a function .
But you need to provide where are you going to create this function. This is they way How to create function with return value,
Go to View -> C/AL Globals
Then go to Functions tab
Type the name of the function, Example CalcRcdNotInvoiced , Then click on Locals, then go to Returns Value tab, In the Name field type AmtRcdNotInv , Return type should be Decimal.
Now you have created new function, I guess you do not have any parameters to send, so click F9 and go down then you can see your new function.
Paste your code inside the function now
IF PurchaseLine.FINDSET THEN
REPEAT
ReceivedNotInvoiced := ReceivedNotInvoiced + PurchaseLine."A. Rcd. Not Inv. Ex. VAT (LCY)";
UNTIL PurchaseLine.NEXT = 0;
AmtRcdNotInv := ReceivedNotInvoiced;
If the answer is solved your problem. Please make it as Verified.