icoxfog417 / SAPExtractorDotNET

The data extractor for SAP Query , Table
http://icoxfog417.github.io/SAPExtractorDotNET/Index.html
18 stars 6 forks source link

; changed to , in data #5

Closed HynekPetrak closed 10 years ago

HynekPetrak commented 10 years ago

Hi, the function below, makes ';' to be changed into ',', if the data contains ';' character. You split by either of those separators, but when assembling back, you put always ',' only.

Dim separated As String() = Line.Split((LineSeparator + ItemSeparator).ToCharArray) Dim els As New List(Of String)

            For i As Integer = 0 To UBound(separated)
                Dim str As String = separated(i)
                If String.IsNullOrEmpty(str) Then Continue For
                If isElement(str) Then
                    els.Add(str)
                ElseIf isElement(els.Last + str) Then 'for data include separator
                    Dim concated As String = els.Last + ItemSeparator + str
                    els.RemoveAt(els.Count - 1)
                    els.Add(concated)
                End If

            Next
icoxfog417 commented 10 years ago

I'll fix it as soon as possible. Thank you for efficient blog post.

HynekPetrak commented 10 years ago

Hi, I believe the fix is not correct. You cannot use even regexp to parse the LDATA structure. Consider a field returned contains a text like 'aaa, 000: aaaa, 022: bbbb', which in the LDATA table will be represented as: 025:aaa, 000: aaaa, 022: bbbb; , then the regexp will split into 3 substrings aaa, aaaa and bbbb, incorrectly. Note the LDATA format does not escape separators ....

icoxfog417 commented 10 years ago

@HynekPetrak , you are right. And I recognized there is no smart way to split LDATA...(format is terrible).