confirm dataport ran successfully on import

Hello,

I was wondering if anyone knows of an easy way to confirm that a dataport has ran successfully from the calling code. I want to do something like this:

IF DATAPORT.RUN THEN BEGIN

CODE

CODE…

END;

The problem is that DATAPORT.RUN returns VOID. You can do this with an XML Port and it works fine but this functionality is not available with a DATAPORT. I’m sure I could come up with something complicated to solve my problem but I just want to keep it simple. [:)] If you have any ideas I would greatly appreciate any input.

Thanks!

This is fairly simple:

You need to create a Codeunit which calls the dataport in the OnRun trigger.

Then you call the codeunit with the IF:

IF CODEUNIT.RUN THEN BEGIN
CODE
CODE...
END;

Hi Thomas,

Would you not hit the same problem in the codeunit i.e. how do you how the dataport was sucessful?

One suggestion it create function in the dataport which returns a boolean. If the dataport set a global variable based on your condition and then test afterwards

e.g.

MyDataport.RUN;

IF MyDataport.CheckComplete THEN BEGIN
CODE
CODE…
END;

This does not help.
When the Dataport fails (with an Error condition) the system would not get the chance to test the “CheckComplete” option.

To cater for this option you need to make use of the “IF CONDUNIT.RUN” behavior.

So if you want the dataport to “fail” at a certain point based on a decision to be taken in the dataport itself, you just need to raise an ERROR in this case.