Dataport Set particular line to a variable

sabzamsabzam Member Posts: 1,149
Hi,

I have the following csv file
    40014065156 Date,Detail,Amount 04/11/2008,XXXXXXXXX,75.00 05/11/2008,XXXXXXXXX,65.00 06/11/2008,XXXXXXXXX,85.00 07/11/2008,XXXXXXXXX,95.00 08/11/2008,XXXXXXXXX,100.00 09/11/2008,XXXXXXXXX,200.00 10/11/2008,XXXXXXXXX,300.00

The dataport has already been created to enter the date, details and amount into their corresponding columns in the table and it works fine. The problem is with the account number i.e the first line (40014065156). i want to store it in a variable instead. How can I do so and in which trigger?

Regards,

Answers

  • matttraxmatttrax Member Posts: 2,309
    Global Variable: AccountNo

    OnAfterImportRecord:
    IF AccountNo = '' THEN BEGIN //Is not filled in
    AccountNo := ColumnFromFile;
    CurrDataport.SKIP; //So you don't continue processing that line
    END;

    That should get you started. Other changes may be necessary. Ideally they would be in the file as separate data items with a blank line in between (or whatever the DataItemSeparator property is set to).
  • sabzamsabzam Member Posts: 1,149
    Hi,

    Thanks for your reply but what is ColumnFromFile? Is it a variable or is it build-in in navision because it is giving me the error that i have specified an unknown variable

    Regards,
  • kinekine Member Posts: 12,562
    The problem is that the file is not "Dataport frendly". You need to read the whole line into variable and than parse it yourself, or use CurrFile.READ in OnPreDataItem to read the first and second line and let the rest go through standard reading...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.