Dataport Problem- Help!!

Dave_SDave_S Member Posts: 17
Hi,

I am fairly new to MS Dynamics NAV, i am using 5.00
I am testing a dataport i have written to import invoices from a csv formated file. The dataport is used to populate Sales Header and Sales Line tables. Everything is ok in the header part (i think :roll: ) but when it gets to the line dataitem i get the following message:-

"You Must Specify No. in Sales Line Document Type='Invoice Document',Document No. = 'IMP10010', Line No.='1'"

When i check the Sales Line table it has the line entries but the only fields filled in are the ones i am populating through code! Its like it is not reading the data for the data lines.

My Dataport is:-
OBJECT Dataport 50050 Import Sales Invoice
{
  OBJECT-PROPERTIES
  {
    Date=10/17/08;
    Time=[ 9:17:30 AM];
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    TransactionType=UpdateNoLocks;
    OnInitDataport=BEGIN
                     // Setup array to use for document numbers, these are stored in an
                     // array then they are added to the lines in order.
                     FOR nCnt:=1 TO ARRAYLEN(aDocNos) DO BEGIN
                       aDocNos[nCnt]:= '';
                       aDocUsed[nCnt]:= FALSE;
                     END;

                     nHeadCnt := 0;                      //Used for storing header document numbers
                     nLineCnt := 0;                      //Used for setting the lines with the correct document no.
                   END;

  }
  DATAITEMS
  {
    { PROPERTIES
      {
        DataItemTable=Table36;
        DataItemTableView=SORTING(No.);
        OnBeforeImportRecord=BEGIN
                               INIT;
                             END;

        OnAfterImportRecord=BEGIN
                              nHeadCnt := nHeadCnt + 1 ;     // Header Count
                              WITH "Sales Header" DO BEGIN
                                VALIDATE("Document Type","Document Type"::Invoice);
                                VALIDATE("No.",NoSeriesMgt.GetNextNo('S-IMPINV',0D,FALSE));
                                aDocNos[nHeadCnt] := "No.";   // Take copy of the document number used on this header.
                                VALIDATE("Order Date");
                                VALIDATE("Posting Date",TODAY);
                                VALIDATE("Document Date","Order Date");
                                VALIDATE("Sell-to Customer No.");
                                VALIDATE("Bill-to Customer No.","Sell-to Customer No.");

                                Custmr.GET("Sell-to Customer No.");
                                VALIDATE("Sell-to Customer Name",Custmr.Name);
                                VALIDATE("Sell-to Address",Custmr.Address);
                                VALIDATE("Sell-to Address 2",Custmr."Address 2");
                                VALIDATE("Sell-to City",Custmr.City);
                                VALIDATE("Sell-to Post Code",Custmr."Post Code");
                                VALIDATE("Customer Posting Group",Custmr."Customer Posting Group");
                                VALIDATE("Gen. Bus. Posting Group",Custmr."Gen. Bus. Posting Group");
                                VALIDATE("VAT Bus. Posting Group",Custmr."VAT Bus. Posting Group");
                                VALIDATE("Bill-to Name",Custmr.Name);
                                VALIDATE("Bill-to Address",Custmr.Address);
                                VALIDATE("Bill-to Address 2",Custmr."Address 2");
                                VALIDATE("Bill-to City",Custmr.City);
                                VALIDATE("Bill-to Post Code",Custmr."Post Code");
                                VALIDATE("No. Series",'S-IMPINV');
                              END;

                              nLineCnt := 0;
                            END;

        OnPostDataItem=BEGIN
                         NoSeriesMgt.SaveNoSeries();       //Update the Number series.
                       END;

      }
      FIELDS
      {
        {      ;     ;"Sell-to Customer No." }
        {      ;     ;"Order Date"         }
        {      ;     ;"External Document No." }
      }
       }
    { PROPERTIES
      {
        DataItemTable=Table37;
        DataItemTableView=SORTING(Document No.,Line No.);
        OnBeforeImportRecord=BEGIN
                               INIT;
                             END;

        OnAfterImportRecord=BEGIN
                              WITH "Sales Line" DO BEGIN
                                IF STRLEN("Sell-to Customer No.")<>0 THEN BEGIN
                                  VALIDATE("Document Type","Document Type"::Invoice);
                                  // Set the document number.  If this is first line of the document.
                                  IF "Line No." = 1 THEN BEGIN
                                    nLineCnt := nLineCnt + 1;
                                   VALIDATE("Document No.",aDocNos[nLineCnt]);
                                  END ELSE
                                    VALIDATE("Document No.",aDocNos[nLineCnt]);

                                  VALIDATE("Sell-to Customer No.");
                                  VALIDATE(Type,Type::Item);                  //Line type
                                  VALIDATE("No.");
                                  VALIDATE("Location Code",'BLUE');          //Validate the warehouse code
                                END;
                              END;
                            END;

      }
      FIELDS
      {
        {      ;     ;"Sell-to Customer No." }
        {      ;     ;Quantity             }
        {      ;     ;"No."                }
        {      ;     ;"Variant Code"      ;Enabled=No }
        {      ;     ;Description          }
        {      ;     ;"Unit Price"         }
        {      ;     ;"Line No."           }
      }
       }
  }
  REQUESTFORM
  {
    PROPERTIES
    {
      Width=9020;
      Height=3410;
    }
    CONTROLS
    {
    }
  }
  CODE
  {
    VAR
      aDocNos@1000000000 : ARRAY [1000000] OF Code[10];
      aDocUsed@1000000001 : ARRAY [1000000] OF Boolean;
      nCnt@1000000002 : Integer;
      nHeadCnt@1000000003 : Integer;
      nLineCnt@1000000004 : Integer;
      NoSeriesMgt@1000000005 : Codeunit 396;
      Custmr@1000000006 : Record 18;

    BEGIN
    END.
  }
}


This is the sample csv file layout i am using:-
CRU109,1/24/2008,12345
CWG153,1/24/2008,12346
C00010,1/24/2008,12347
DIC107,1/24/2008,12348
DOB125,1/24/2008,12349


CRU109,10,1007,83,UK 8 (EU42) Green Original,55,1
CRU109,10,1007,90,UK 9 (EU43) Green Original,55,2
CRU109,10,1007,106,UK 10 (EU44) Green Original,55,3
CWG153,10,1007,83,UK 8 (EU42) Green Original,55,1
C00010,10,1007,83,UK 8 (EU42) Green Original,55,1
DIC107,10,1007,83,UK 8 (EU42) Green Original,55,1
DOB125,10,1007,83,UK 8 (EU42) Green Original,55,1

If anyone has any idea's i would appreciate the help :D

Cheers
Dave

Comments

Sign In or Register to comment.