Dataport - varying field lengths
Fisherman
Member Posts: 456
hey guys - me again.
I need to develop a dataport that can read a varying length file. It's an EDI document. As such, the length of the overall record, and the length of each field within the record, is dependent on the first character of the record.
I think I've determined that the stock usage of dataports (variable or fixed width) will not work for this. It appears that I'm going to need to parse the data myself. To do this, I would think that I would need to create a text field as long as my longest record (defined to be 64 characters), and read each row, parsing as I go.
Is this a correct assumption? If so, how do I read the data into a variable instead of a table record? Should I just create a table to hold the data and read it into that table, then parse from the table?
Any suggestions would be appreciated.
I need to develop a dataport that can read a varying length file. It's an EDI document. As such, the length of the overall record, and the length of each field within the record, is dependent on the first character of the record.
I think I've determined that the stock usage of dataports (variable or fixed width) will not work for this. It appears that I'm going to need to parse the data myself. To do this, I would think that I would need to create a text field as long as my longest record (defined to be 64 characters), and read each row, parsing as I go.
Is this a correct assumption? If so, how do I read the data into a variable instead of a table record? Should I just create a table to hold the data and read it into that table, then parse from the table?
Any suggestions would be appreciated.
0
Answers
-
how is the data seperated?
myitem,myitemdescription,mycost
"myitem","myitemdescription","mycost"
for example or something more complicated?
850 00000000000AB24836 PO HSS 000000126126 1260012 004010VICS 000004010004010X X4014010104010 P P
850 BEG0020000000SAAB24836 20060802
850 REF00400000IA 00848
850 DTM0120000001020060803
850 N1 02300000BY NEWARK 928048
850 PO103000000 0000000000000003EA200000000000000164 UP688047410022 VA19740
850 PO103000000 0000000000000003EA200000000000000438 UP741655100348 VA99059
850 PO103000000 0000000000000006EA200000000000000585 UP074469414586 VA12800
850 PO103000000 0000000000000006EA200000000000000363 UP011313020951 VA21600
850 PO103000000 0000000000000003EA200000000000000277 UP015228123462 VA38585
850 PO103000000 0000000000000003EA200000000000000234 UP018787767047 VA20190
850 PO103000000 0000000000000003EA200000000000000234 UP018787767061 VA20200
850 PO103000000 0000000000000003EA200000000000000473 UP018787765166 VA20240
850 PO103000000 0000000000000012EA200000000000000085 UP041670131229 VA19892
850 PO103000000 0000000000000003EA200000000000000185 UP041670132370 VA19902
850 PO103000000 0000000000000003EA100000000000000039 UP052336331655 VA24960
850 PO103000000 0000000000000003EA200000000000000759 UP074469414746 VA12855
850 PO103000000 0000000000000003EA100000000000000036 UP022796812032 VA40617
850 PO103000000 0000000000000003EA100000000000000036 UP022796174017 VA17001
850 PO103000000 0000000000000003EA100000000000000036 UP022796174024 VA17002
850 PO103000000 0000000000000003EA200000000000000473 UP018787761168 VA20150
850 PO103000000 0000000000000003EA200000000000000208 UP018787765043 VA20250
850 PO103000000 0000000000000003EA100000000000000036 UP022796800039 VA40685
850 PO103000000 0000000000000003EA100000000000000036 UP022796800022 VA40720
850 CTT0630000000000190 -
Lanham has an add-on for EDI. We have clients using it successfully.
Perhaps you could consider that. EDI documents are not simple.0 -
That's what we use too. A dataport for something like this would be pretty impressive.0
-
it's a variant of the ANSI 830 planning schedule...
H00012654 2006073120060731 P5701E573-60 00170992 EA1H D1741 DD20060807 D2199 DD20060809 D2301 DD20060814 D2767 DD20060816 D2806 DD20060821 D2555 DD20060823 D5872 DW20060828 D5592 DW20060904 D5870 DW20060911 D5641 DW20060918 D5856 DW20060925 D5772 DW20061002 D5481 DW20061009 D5832 DW20061016 D23325 DM20061023 D21216 DM20061120 D15175 DM20061218 D7267 DM20070115 S800 20060728135800 2006010120060728
I could write this in an hour in VB.Net, but I'm unsure in C/AL0 -
Hi
I'm assuming that the file your'e reading is a text file.
It seems that the 1st character is the definition of the line.
You could create a new codeunit to read the file.
REPEAT
CASE COPYSTR(Line,1,1) OF
'H' : BEGIN
some code here;
END;
'D' : BEGIN
some code here;
END;
END:
UNTIL File.POS = File.LEN;
where File is DatType File
Line DataType Text Len 64 (or maxlen of the data)
Hope this helps0 -
Thanks all -
Finally getting back to this. I ended up creating a "buffer" table of 6 columns :
an integer row id,
the header type from the file (1st character of each line),
the data of the row (the remainder of the row),
the user id who is running the dataport,
the date of the run, and
the Location code, specified through a filter on the request form.
I've cheated for now and put the parsing code in the "OnPostDataItem". I loop through each record in my buffer, and insert the appropriate data in the Production Forecast Entry table after I've verified all the information in the file.
it's ugly, and i'll probably port it to a two-dataport solution in the future, but it works.
Thanks.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K 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
- 323 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