Running a Dataport from a Codeunit

I have the following simple code: a report that references a codeunit which in turn runs a dataport. The codeunit is defined as a global in the report. My problem is that this won’t even compile and I don’t understand why. The comliation error I get is: A field from a record/variable is expected. Any help would be greatly appreciated. Thanks. Report 50062 Documentation() Report - OnInitReport() Report - OnPreReport() Yesterday := TODAY - 1; WebFile := ‘w:\webpo’+FORMAT(Yesterday,8,’<Month,2><Day,2>’)+’.txt’; OK := EXISTS(WebFile); IF OK THEN BEGIN ReqFile.OPEN(WebFile); IF ReqFile.LEN > 0 THEN BEGIN ReqFile.CLOSE; //DATAPORT.RUN(50005,FALSE); cuRunDataPort.Begin(50005); //cuRunDataPort is the global for code unit 50014 END; END; CodeUnit 50014 Documentation() OnRun() Begin(“DataPort Number” : Integer) DATAPORT.RUN(“DataPort Number”, FALSE);

Try losing the space in your parameter. So call the paratemer DataportNumber.

Just don’t call your function in the codeunit “Begin”. This is a quite special word in C/AL and may not be used as function name. Name your function “dspace” and you will be able to compile :slight_smile:

Changed the function name from “begin” to “drun” and everyone is happy. Thanks very much for your help.