DATAPORT : how to return to the first line or read again the file ?

navision2009R2
Member Posts: 8
I would need to read the whole CSV file (to check each line) then go back to the first line to process the data.
Is it possible ? How can I do so ?
Is it possible ? How can I do so ?
0
Answers
-
Hello @navision2009R2,
You can create a report that call your dataport twice, passing a parameter with the value of 1 the first time and 2 the second, so you can do whatever you need depending on this value.
Be sure to set the UseReqForm property to No in the dataport.
The report could be as simple as this one
Where the function CallID is the function in your dataport to get the call value.
Like this:
Where globalID is a global integer variable.
Regards
0 -
Hi @navision2009R2,
Great name by the way!
Sure want to read twice?
A trick I use to read the header lines on a dataport but you could use to read all the dataport lines...
OnPreDataItem=VAR
DosInFile@100000006 : File;
StreamIn@100000005 : InStream;
OffSetLength@100000004 : Integer;
NextStep@100000003 : Integer;
ReadStep@100000002 : Integer;
LineFeed@100000001 : Integer;
ReadLine@100000000 : Text[1024];
BEGIN
IF CurrDataport.IMPORT THEN BEGIN
DosInFile.OPEN (FileName);
DosInFile.CREATEINSTREAM (StreamIn);
LineFeed := 0;
REPEAT
OffSetLength := StreamIn.READTEXT (ReadLine, 1024);
LineFeed += 1;
UNTIL OffSetLength <> 0;
IF LineFeed > 1 THEN
OffSetLength := OffSetLength + 2;
REPEAT
NextStep := StreamIn.READTEXT (ReadLine, 1024);
OffSetLength := OffSetLength + NextStep + 4;
UNTIL NextStep <> 0;
DosInFile.CLOSE;
CurrFile.SEEK (OffSetLength);
END;
But I would say a better solution is to read all the records and place in a temporary record and on
Dataport - OnPostDataport()
Read back the temporary records and process the data from there.
Hope this helps!
Big D signing off!0
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