Import CSV file that has different table structure then the table into CSV is being imported

Damjan
Member Posts: 94
Hi,
I need to import some data saved in CSV file into T81 - Gen. Journal Line
File structure of CSV file is not identical to table structure.
How to import such CSV using XMLPort? Should I import first in Temp Table and then from temporary table to T81?
Thank you
BR Damjan
I need to import some data saved in CSV file into T81 - Gen. Journal Line
File structure of CSV file is not identical to table structure.
How to import such CSV using XMLPort? Should I import first in Temp Table and then from temporary table to T81?
Thank you
BR Damjan
0
Best Answer
-
To skip the first line in the csv file just set a boolean flag True in the OnInitXMLport() then in the OnBeforeInsertRecord() for example set the boolean flag to false AND perform a currXMLport.SKIP else just process the csv lines.0
Answers
-
Take a look at xml-port 9171, 9172. Altough the fields are here in the order of the table structure, it is not necessary to do so. You can also define variables to fetch the data from the csv, and use the code to fill the table records, and insert (or update) them in code.IF User.Loves('Edo') THEN ok() ELSE currReport.genSkip;0
-
Hi
I managed to create XMLPort and at the moment there is also first record inserted into T81 - Gen. Journal Line, but this 1 record is header row in CSV, I need to skip that.
It inserts all columns from CSV file: "Column A" is inserted in first field element of the table "Gen. Journal Line", "Column B" is inserted in second field element on the table: "Gen. Journal Line", etc.
How can I skip fields that I do not need to insert -> CurrXML.SKIP -> this skip processing of XMLPort and closes the object, it does not skip the first row (header row).
And, there is one other thing, although I insert a new record with primary key on "Journal Template Name", "Journal Batch Name", "Line No." I get the error:
Microsoft Dynamics NAV
Break On Error Message:
The Gen. Journal Line already exists. Identification fields and values: Journal Template Name='TEST',Journal Batch Name='DZ',Line No.='10000'
OK
Thanks Damjan0 -
To skip the first line in the csv file just set a boolean flag True in the OnInitXMLport() then in the OnBeforeInsertRecord() for example set the boolean flag to false AND perform a currXMLport.SKIP else just process the csv lines.0
-
Hi,
After CurrXMLPort.SKIP code goes to the OnPostXMLPort() and exits the code, so that XMLPort is closed.
Code is attched in the printscreen
Thanks
0 -
Code seems okay. Did you try to follow the execution of the code with the debugger?0
-
Hi,
I created new object XMLPort with identical code and it works as expected.
Thank you
BR Damjan0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions