Error Import command error

Good morning everyone.
I need an urgent help, because I'm with the project stopped due to this error.
I have the following situation:
- I'm importing an EDI file.
The problem that the file comes across (data) in a single line separated by TAG's.
And importing the final part of the file (last columns) is not being imported.
I tested it with 2 files: 1 with 14,090 columns (characters) and another with 4,930 columns (characters) and the problem is the same.
I tried, using a stream, with the command import unformatted and nothing solved.
QTY + 1: 2000'DTM + 2: 20180607: 102'QTY + 1: 2000'DTM + 2: 20180621: 102'QTY + 1: 2000'DTM + 2: 20180705: 102'QTY + 1: 4000'DTM + 2: 20180719: 102'UNT + 89 + 1'UNZ + 1 + 1'IT * 000210038 * 0000 * 00001

When executing and with the message it imports up to: QTY + 1: 2000'DTM + 2: 20180607: 102'QTY + 1
The final part comes with the blank message.
I tried with the copy-lob command for a variable of type longchar, the same problem.
Here is my code below.
Code:
DEFINE VARIABLE v-line AS CHARACTER NO-UNDO.

DEFINE TEMP-TABLE ttLine
     FIELD c-line AS CHARACTER.

DEFINE VARIABLE c-dir AS CHARACTER NO-UNDO.
DEFINE VARIABLE c-file AS CHARACTER NO-UNDO.
assign c-dir = 'c: \ temp \ Input'
        c-file = c-dir + "~ \ my_file.TXT".

IF SEARCH (c-file) <>? THEN DO:
    INPUT FROM VALUE (c-file).
    REPEAT ON ERROR UNDO, NEXT:
        v-line = ''.
        CREATE ttLinha.
        IMPORT v-line.
MESSAGE v-line
         VIEW-AS ALERT-BOX INFO BUTTONS OK.
       
        ASSIGN ttLine.c-line = v-line.
    END.
    INPUT CLOSE.
END.
FOR EACH ttLinha:
    MESSAGE ttLinha.c-linha
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
 
Last edited by a moderator:

Cringer

ProgressTalk.com Moderator
Staff member
Is there a carriage return before the end of file? There should be.
 
1) Progress Version, Service Pack and Product
Progress 10.2b
2) SO and version
windows 10 64 bit
3) What you tried
Import a TXT file as content into a single line
4) What mistakes are you getting
No errors occur, only, no matter the last characters of the line, as described in the post's initial message
 
As I have described, I have a TXT file with a single line.
When using import, the last characters of the line are not imported.
This occurs when the row has more than 3000 columns.
 
For example the final part of the attached file:
203'PAC +++ DAP08 :: 10'QTY + 52: 24: PCE'UNS + S'UNT + 71 + 39000001'UNZ + 1 + 390 '

Does not matter
 

Attachments

  • TESTE_000004.TXT
    1.2 KB · Views: 7
Not exactly 3000, always the last positions are not imported.
I just tested with another file with 14090 characters, and it imported up to 13937.
After this position goes blank
 

TomBascom

Curmudgeon
Your attached teste_00004.txt file does not terminate with a newline. The last character is '

IMPORT *requires* that input files be terminated with newline. From the documentation:

The UNFORMATTED option forces IMPORT to read one physical line at a time. A physical line ends with a newline or linefeed character.

End of file <> end of line.

COPY-LOB should be fine but you do not show any code using COPY-LOB.
 

TomBascom

Curmudgeon
Code:
define variable lineIn as character no-undo.
define variable cData  as longchar no-undo.

copy-lob from file "test.txt" to cData.
message length( cData ).
pause.

input through value( 'cat ./test.txt ; echo ""' ).  /* add a newline... remove the '; echo ""' bit to see what happens without a newline */
repeat:
  import unformatted lineIn.
  message length( lineIn ).
  pause.
end.
input close.
 

TomBascom

Curmudgeon
If a text file might not be properly terminated run something like this:
Code:
define stream datafile.
define variable lastchar as integer no-undo.
define variable filename as character no-undo initial "test.txt".

input stream datafile from value( filename ) no-echo.
seek stream datafile to end.
seek stream datafile to ( seek( datafile ) - 1 ).
readkey stream datafile.
input stream datafile close.
lastchar = lastkey.
message lastchar.
pause.

if lastchar <> 10 and lastchar <> 13 then
  do:
    message "fixing!".
    pause.
    output to value( filename ) append.
    put unformatted skip(1).
    output close.
  end.
 
Good Morning.
I was able to solve the problem.
Thus:
define variable line1 as longchar no-undo.

copy-lob from file tt-arq.nom-arq-complete to line1.
assign line = string (line1).
Counter = 1 to num-entries (line, " ' "):
ASSIGN C-LINE = entry (counter, line, " ' ").
RUN pi-import ( input C-LINE).
end.

Thank you very much.
 
Top