Problem with dataport and general journals

poppinspoppins Member Posts: 647
Hello Everybody !

This is my first post in this forum. I'm a beginner in using Microsoft Dynamics Nav and unfortunately I'm facing now problem. I used a Dataport which load lines from an Excel file to the general journals table.
My problem is that, when examining the inserted values on the table, I found that there is noi value in the field "Document Type" and that the value of the field "Amount" is 0.

What can I do to fix it???

Here is the code of the Dataport, if needed:

Documentation()

G/L Entry - OnPreDataItem()

G/L Entry - OnBeforeExportRecord()

G/L Entry - OnAfterExportRecord()

G/L Entry - OnBeforeImportRecord()

G/L Entry - OnAfterImportRecord()
  
  "Gen. Journal Line".INIT;
  "Gen. Journal Line".VALIDATE("Journal Template Name","Gen. Journal Line"."Journal Template Name");
  "Gen. Journal Line".VALIDATE("Journal Batch Name","Gen. Journal Line"."Journal Batch Name");
  "Gen. Journal Line".VALIDATE("Line No." ,"Gen. Journal Line"."Line No." + 10000);

  IF "Gen. Journal Line".INSERT(TRUE) THEN
   "Gen. Journal Line".SetUpNewLine("Gen. Journal Line",Balance,FALSE);

  "Gen. Journal Line".VALIDATE("Posting Date",DateCompt);

  "Gen. Journal Line".VALIDATE("Document Type","Type Document");
  "Gen. Journal Line".VALIDATE("Document No.",FORMAT(DocNum));
  "Gen. Journal Line".VALIDATE("Account Type","Gen. Journal Line"."Account Type"::Customer);
  "Gen. Journal Line".VALIDATE("Account No.","N°Client");
  "Gen. Journal Line".VALIDATE("Gen. Journal Line".Description,Désignation);
  //"Gen. Journal Line".VALIDATE(Amount,Montant);
  "Gen. Journal Line".VALIDATE("Amount (LCY)",Montant);
  "Gen. Journal Line".VALIDATE("Document Date","Date Document");
  "Gen. Journal Line".VALIDATE("External Document No.","N° Documentf");
  "Gen. Journal Line"."Bal. Account Type":="Gen. Journal Line"."Bal. Account Type"::"G/L Account";
  Customer.GET("N°Client");
  "Groupe Compta":=Customer."Customer Posting Group";
  "Customer Posting Group".GET("Groupe Compta");
  "Gen. Journal Line".VALIDATE("Bal. Account No.","Customer Posting Group"."Receivables Account");
    
  "Gen. Journal Line".MODIFY(TRUE);

DocNum += 1;

G/L Entry - OnPostDataItem()

ImportDataPar(NomF : Text[250];NomModFeuille : Code[10];NomFeuille : Code[10];DateComptabilisation : Date;"N°Doc" : Code[20])
FileName:=NomF;
"Gen. Journal Line"."Journal Template Name":=NomModFeuille;
"Gen. Journal Line"."Journal Batch Name":=NomFeuille;
DateCompt:=DateComptabilisation;
"N° Document":="N°Doc";

Comments

  • poppinspoppins Member Posts: 647
    In fact, the DataItem of the Dataport refers to the G/L Entry table...but in the Dataport's code, the General journals table is used.
    I don't understand why...can't that be the source of the errors??????
  • faizguy84faizguy84 Member Posts: 52
    You will have to use Gen. Journal Line as dataitems and then write the code for validation.

    Regards,
    Faisal Bukhari
  • poppinspoppins Member Posts: 647
    thank you for your reply....but what validation code???
    Isn't the validation taking place in the Dataport code???
  • SavatageSavatage Member Posts: 7,142
    Yes,

    Change your dataitem to the correct one & re-try your code.

    Note: The best way to see if a dataport is working correctly is to manually enter a line into the journal, filling in the info you normally do. Then you can look at the table and see all the fields that get filled.
    When you run your dataport all the same fields should be filled else your dataport is missing something.
  • poppinspoppins Member Posts: 647
    I tried to change the DataItem but got an error...in fact, the property DataItemTableView is set to SORTING(No. Series)...and the field No.Series doesn't exist for the Gen. Journal Line table...so what field should I use instead????
  • SavatageSavatage Member Posts: 7,142
    edited 2012-06-21
    Why do you need any view in a dataport? leave it blank
  • poppinspoppins Member Posts: 647
    I don't really know....In fact I got the code and I was asked to correct it as an exercise....I started dealing with Nav 2009 only two weeks ago....
  • SavatageSavatage Member Posts: 7,142
    more dataport info:
    http://msdn.microsoft.com/en-us/library/dd301300

    Read more about dataports in the application designers guide. (w1w1adg.pdf)
    http://www.microsoft.com/en-us/download ... x?id=24432

    If it's just an exercise for 2009 - the best answer would be to delete the dataport & start learning XML ports. :mrgreen:
  • poppinspoppins Member Posts: 647
    I wish it was possible....My manager is insisting on the use of DATAPORTS... ](*,) ](*,) ](*,)
  • SavatageSavatage Member Posts: 7,142
    poppins wrote:
    I wish it was possible....My manager is insisting on the use of DATAPORTS... ](*,) ](*,) ](*,)
    Fine then go step by step and work your way through it.

    For a dataport you need to just select the table you want to import into.
    Map the fields to match your incoming data.
    Manipulate the data if needed during import.
    No Dataitemviews or stuff like that needed. That's more for a form.
  • SavatageSavatage Member Posts: 7,142
    Here's a GJL dataport sample - using a datafile of just 4 fields to import.
    It's for importing credits so if you build this one & run the data - then view the results it might give you an idea on how the dataport works. Good luck

    https://docs.google.com/document/d/1ESb ... PeQwM/edit
Sign In or Register to comment.