Installation guide
Zetadocs for NAV Installation Guide
This edition 5
th
December 2012 © Copyright Equisys plc 2012 All trademarks acknowledged All rights
reserved
Page 82
file.WRITEMODE(FALSE);
// If we can't open the file, just return false as we cannot match a value
IF NOT file.OPEN(FilePath) THEN
BEGIN
EXIT(FALSE);
END;
// Cycle through all lines in the file until we find te value we were
// looking for or
// we reach the end of the file
REPEAT
// Read each line at a time
IF file.READ(line) <> 0 THEN
BEGIN
// Check if value appears anywhere in the line
// NOTE: If values wrap over more than one line they will not be matched
pos := STRPOS(line, Value);
IF (pos <> 0) THEN
BEGIN
// We've found the value we were looking for, close the file and
// return true
file.CLOSE;
EXIT(TRUE);
END;
END;
UNTIL file.POS = file.LEN; // Check if we have reached the end of the file
// We've reached the end of the file without finding the value we were
//looking for
// Close the file and return false
file.CLOSE;
EXIT(FALSE);
}
Creating the GetMatchingPurchaseOrder function
Next return to the functions tab, ViewC/AL Globals.
Add the function GetMatchingPurchaseOrder, details below.
Name
GetMatchingPurchaseOrder (Orders, ZdControlFile)
Description
Searches through the ZdControlFile to find a matching Purchase Order
Arguments
Orders record List of opened purchase orders
ZdControlFile text[1024] The control file of the document queue item
Returned value
True if the Order matches the DQF file
False if not
Adding Code into the GetMatchingPurchaseOrder function
Now that we have added the function into the codeunit we need to add the following code, open the C/AL
editor (F9) and paste in the code below into the GetMatchingPurchaseOrder section. We have included
comments throughout to explain the various sections.
CODE:
GetMatchingPurchaseOrder (Record Orders, Text[1024] ZdControlFile)
{
// Clear any filters on the Orders record
Orders.RESET;
// Set range so we are only looking at orders
Orders.SETRANGE(Orders."Document Type",Orders."Document Type"::Order);