Dataport - How to Create Multiple Records

I have a dataport to create Purchase Header records. In the dataport I am using code to get the next invoice number via the NoSeriesManagement code unit. I can create a Purchase Header record correctly if there is only 1 record in the import file. If there are 2 or more records in the import file then only the 1st record gets created as a Purchase Header. Stepping through the code I can see that new Invoice numbers are correctly generated for subsequent invoices (the Number Series gets incremented properly), but the next records do not get created. Is there a command to make sure that a record is created after each OnAfterImportRecord trigger? Thanks, Harold

Use Commit

Hi Harold, DO NOT USE COMMIT. Commit should be used only in special cases (a search on commit on this forum should helop you understand better what that is for). As for why you cannot create the other records, can you post the code that you have in the dataport. I am sure you are just missing something in there … Cristi Nicola

You may need in OnBeforeImportRecord a call to INIT;

Tried the INIT in the OnBeforeImportRecord and it didn’t help. The dataport reads the file into variables with prefix ‘x’. Here’s the code in the OnAfterImportRecord trigger IF IsInPOArray(xPONo) = FALSE THEN BEGIN AddPOToArray(xPONo); //add to array so we don’t process more lines for this header //Set the Purchase Header Variables “Document Type” := 2; //val 2 = Invoice “Posting Date” := WORKDATE; //Get no series codes PurchSetup.FIND(’-’); “No. Series” := PurchSetup.“Invoice Nos.”; “Posting No. Series” := PurchSetup.“Posted Invoice Nos.”; //Get Next Invoice No. “No.” := ’ ‘; NoSeriesMgt.InitSeries(“No. Series”,“No. Series”,“Posting Date”,“No.”,“No. Series”); “Buy-from Vendor No.” := xVendorCode; VALIDATE(“Buy-from Vendor No.”); “Pay-to Vendor No.” := xVendorCode; VALIDATE(“Pay-to Vendor No.”); “Order Date” := WORKDATE; “Posting Description” := ‘Invoice ’ + FORMAT(“No.”); “Document Date” := TODAY; “Doc. No. Occurrence” := 1; “Reason Code” := GetReasonCode(xCampaignCode); “Payment Terms Code” := ‘90EOM’; //calculate due date based on payment terms “Due Date” := CALCDATE(‘CM’, “Order Date”); “Due Date” := CALCDATE(’+90D’, “Due Date”); “Currency Code” := ‘THB’; “Currency Factor” := 1; “Prices Including VAT” := FALSE; “Vendor Order No.” := xPONo; “Vendor Authorization No.” := xClientCode; //Add to the Dimension array for Media - Code 2 AddtoDimensionArray(COPYSTR(xVendorCode, 5, STRLEN(xVendorCode)) , “No.”, 0, 2); //Add to the Dimension array for Program - Code 4 AddtoDimensionArray(‘100000’ , “No.”, 0, 4); //always set line no = 0 for header dimension END;

Found my problem. I added an ELSE section with a SKIP