EDIdEv Framework EDI (FREDI) has three Cursor Types for processing EDI
files. They are:
1. Dynamic Cursor Type
'Dynamic (default)
oEdiDoc.CursorType = Cursor_Dynamic
2. ForwardOnly Cursor Type
'Forward Only (translating)
oEdiDoc.CursorType = Cursor_ForwardOnly
3. ForwardWrite Cursor Type
'Forward Wrte (generating)
oEdiDoc.CursorType = Cursor_ForwardWrite
Dynamic Cursor
Dynamic cursor type is FREDI's default setting. In this mode, data
segments and elements that are read or created into the component are stored in
a hierarchical tree in RAM memory allowing programmers to reference them
directly at anytime in the process. Dynamic cursor type can be used for
both reading (inbound) and writing (outbound) EDI files, which makes it possible
to create a solution that can read an EDI file, modify it and then save it to a
file.
A major disadvantage with the dynamic cursor type is its huge overhead. Storing an entire EDI file's information in RAM memory requires a large amount of memory, and time for managing the hierarchical tree and its index. With large EDI files, the performance of the component can come to a crawl as threshold settings are reached and memory management of data paging between RAM and virtual RAM takes effect. Although, changing the threshold settings can help a little, it is best to avoid the situation. We strongly do not recommend using dynamic cursor type for EDI files larger than 1MB.
ForwardOnly Cursor
The ForwardOnly cusor type can only be used for reading EDI files. In this
mode, only one data segment is kept in RAM
memory. Once the next data segment is read from the EDI file, the current
segment in memory is discarded and replaced by the newly read segment.
This process takes up little memory, and not much overhead
to slow the process. So unlike the dynamic cursor type, the forward cursor
type has no degradation in performance that's related to file size.
However, as its name states, ForwardOnly mode can only read EDI files in one
direction - forward only. So some methods and properties of the component that call previous segments are not
possible in ForwardOnly cursor type. For example, the "FirstDataSegment"
method will not be possible if you've already traversed thru the file - unless
you call the "LoadEdi" method again. However, calling the
LoadEdi method again does not cause much delay because in ForwardOnly cursor
type, LoadEdi method simply opens the file.
oEdiDoc.CursorType = Cursor_ForwardOnly ' <---- enable ForwardOnly cursor type
...
oEdiDoc.LoadEdi sEdiFile
Set oSegment = oEdiDoc.FirstDataSegment ' <----------- OK
...
While Not oSegment Is Nothing
Set oSegment = oSegment.Next '<--- reads next segment and discards previous segment in memory
WendSet oSegment = oEdiDoc.FirstDataSegment ' <----------- FAILS
Some other methods and properties not available in ForwardOnly cursor type are: GetDataSegmentByPos, GetElementByPos and GetHierarchyString.
ForwardWrite Cursor
The ForwardWrite cursor type can only be used for writing EDI files.
In this mode, data segments being created are committed to temp files after
every end of a loop, before being discarded from RAM memory. When the
"Save" method is finally called, an EDI file is created from the temp
files. This process use up much less memory, is more efficient and faster
than the default (Dynamic) cursor type. In Dynmic cursor type, all data
segments being created for the EDI file is kept in memory before they get
committed to a file. This runs into the same problem of reading large EDI
files; it will soon reach a threshold before paging kicks-in to degrade the
speed performance. So just like the ForwardOnly, the ForwardWrite doesn't
create a hierarchy tree in memory when it creates an EDI file. However,
because loops can happen a number
of times, and its creation can be faster than when they get committed to a file, the write to
disk could become a bottleneck and slow the process. Increasing the
document I/O buffer can resolve this issue. To increase the document I/O
buffer, do the following:
oEdiDoc.Property(Property_DocumentBufferIO) = 200
Since in ForwardWrite cursor type, the segments are committed to file after every loop, it is then unnecessary to include the loop instance in the hierarchical tree syntax. For example "N1(2)\N1" can simply be written out as "N1\N1". However, because segments are only committed into file after every loop, it is still important to include the instances of segments, otherwise the last instance of a segment will overwrite the previous instance.
Example of instances of data segments
Set oSegment = oTransactionset.CreateDataSegment("DTM")
oSegment.DataElementValue(1) = "405"
oSegment.DataElementValue(2) =
"20020617"
Set oSegment = oTransactionset.CreateDataSegment("DTM(2)")
' <---- keep instance of segment
oSegment.DataElementValue(1) = "150"
Example of loop instances
Set oSegment = oTransactionset.CreateDataSegment("N1\N1")
oSegment.DataElementValue(1) = "PR" 'Entity
Identifier Code
oSegment.DataElementValue(2) = "HMO Partners
INC."
Set oSegment = oTransactionset.CreateDataSegment("N1\N4")
oSegment.DataElementValue(1) = "Centerville"
Set oSegment = oTransactionset.CreateDataSegment("N1\N1")
' <--- loop instance N1(2)\N1 not required with ForwardWrite
oSegment.DataElementValue(1) = "PE" 'Entity
Identifier Code
oSegment.DataElementValue(2) = "ABC HEALTH MED CTR
"
Set oSegment = oTransactionset.CreateDataSegment("N1\N4")
' <--- loop instance N1(2)\N4 not required with ForwardWrite
oSegment.DataElementValue(1) = "Smallville"
Legal Information
This document is provided for informational purposes only and EDIDEV LLC makes
no warranties, either expressed or implied, in this document.
Information in this document is subject to change without notice.
The entire risk of the use or the result of the use of this document
remains with the user.
Complying with all applicable copyright laws is the responsibility of the user.
Without limiting the rights under copyright, no part of this document may
be reproduced, stored in or introduced into a retrieval system, or transmitted
in any form or by any means (electronic, mechanical, or otherwise), or for any
purpose, without the express written consent of EDIDEV LLC.
© 1999- 2003 EDIDEV LLC. All
rights reserved.