Navision crashes when running dataport

All,

I built the dataport below to import data in the general journal . Basically it works. However, sometimes when it’s run, Dynamics NAV crashes. Don’t really know why. Does anybody see any reason for the problems in the code below. I am not really familiar with C/AL… Any help is appreciated.

Gen. Journal Line - OnPreDataItem()
“Journal Template Name” := ‘PAYROLLIMP’;
“Line No.” := 0;
NewNumber:= NoSeriesManagement.GetNextNo(‘PRL-IMP’, WORKDATE, TRUE);

Gen. Journal Line - OnBeforeExportRecord()

Gen. Journal Line - OnAfterExportRecord()

Gen. Journal Line - OnBeforeImportRecord()

INIT;

Gen. Journal Line - OnAfterImportRecord()

BEGIN
“Journal Batch Name” := VarBatchNm;
“Line No.” := “Line No.” + 10000;
“Document No.”:= NewNumber;
“Posting Date”:= VarPostDt;
“Account Type”:= VarAccTy;
“Account No.” := VarAccNo;
VALIDATE (“Account No.”);
Description:= VarDesc;
Amount:= VarAmnt;
VALIDATE(Amount);
“Shortcut Dimension 1 Code”:= VarDim1;
VALIDATE(“Shortcut Dimension 1 Code”);
“Shortcut Dimension 2 Code”:= VarDim2;
VALIDATE(“Shortcut Dimension 2 Code”);
END