Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problems uploading a text file with line feed characters from Windows

Former Member
0 Kudos

Hi,

I am using the FM GUI_UPLOAD to load a text file in which at the end of each line there is a line feed character. When I upload the file, the FM interprets the entire file as ONE record; it does not recognize the line feed character at the end of each file line. I am using the parameter in the FM "HAS_FIELD_SEPARATOR" and it does not do anything to remidiate this issue.

The funny thing is that WS_upload works like a charm and it separates every line in the text file according to the line feed character at the end of each file line.

Why a FM that is obsolete would work better and with less effort than the new one? We are on 4.6c and will go to ECC6.0 May 2009.

Can anybody recommenced a way to process this type of file using GUI_upload?

The file to process is downloaded from a bank Website into a Windows PC. Sending the file to Unix first is not an option.

Thanks,

Pierre Martinez

Edited by: Pierre Martinez on Aug 15, 2008 1:09 AM

7 REPLIES 7

former_member188685
Active Contributor
0 Kudos

are you making

READ_BY_LINE = ' ' by any chance.

I just want to know what is the Character you are passing to SAP, which specified a linefeed. can you just let me know...

0 Kudos

Thanks for helping.

File type is ASC

I have tried READ_BY_LINE = ' X' and it gives me the entire file on one record returned in the table.

I have tried READ_BY_LINE = ' ' and it gives me the file in more records in the returned table but not the correct amount of records.

I am not passing any character to the SAP FM GUI_Upload. I do not think there is a way to tell it what character is the separator, there is a flag to tell the FM that the fields are separated by delimiters. This is parameter HAS_FIELD_SEPARATOR. I have used both way with X and blank and it does not make a difference.

I am afraid the file I am reading in is has not been converted to a Windows format and that is shy GUI_upload does not work but WS_upload works without converting to a Windows format.

I have also tried the file type of BIN and it brings the file in the incorrect number of records.

Thanks again.

0 Kudos

Hi Pierre,

Can you try openning the file in Windows Notepad, as it only interprets CR/LF as the end of record.

If the records in the file are not displayed correctly, then your assumption that the file has not been converted to Windows format is probably true.

Best Regards

David Cooper

0 Kudos

Hi,

I have done that and Notepad does NOT interpret the line feed character. The file looks all messed up. Notepad does NOT split the data into records. The Hex character at the end of each file line is 0A.

The user will download the file into a Windows desktop from the bank's website and from there an ABAP program needs to read it and parse it. But the ABAP program can not even catch the entire file with gui_upload. WS_upload can catch it with no issues.

I tried catching the file into an internal table of data type string using GUI_upload, but it only catches two bytes of the file and nothing else.

I will try catching the file in some other type of data type for the internal table in gui_upload.

Once I catch it, I can split the file by the line feed character. I need to catch it first, but "my glove" is not big enough. Defining the internal table for the gui_upload as character is a guessing game since I really do not know how big the text file is since GUI_upload will put it in a one record.

Thanks.

0 Kudos

Hi Pierre,

Just restating the problem:

1) End-Of-Record = HEX(0A) = ASCII(10) = LF

2) File must be read from the users PC via SAPgui

3) Recommended Upload routine GUI_UPLOAD does not recognise LF as the End-Of-Record

Possible Solutions:

1) Have the user calling a pre-processing program on the PC to convert to Dos/Windows format. I know not ideal

Freeware utilities are available for this from many sites on the internet.

2) Have the user transfer the file to the unix file system via FTP or SAMBA file share.

Sorry i can't be much more help here.

Hope you find a solution.

Former Member
0 Kudos

Hi Pierre,

Can you please supply the FM call you are specifying. I suspect that the file type is incorrect, as I have not encountered this problem myself in windows, except where a Unix file has not been converted to Windows format.

The FM assumes ASC file_type and READ_BY_LINE = 'X' so these do not need to be specified for text files.

Cheers

David Cooper

sebgut
Explorer
0 Kudos

Hi,

in your program, you should upload the file as binary file to your server (have a look at transactions CG3Y and CG3Z for code example) once on the server you will be able to manipulate your file to change the LF to CRLF or if your server is under Unix you will only need to use the "OPEN DATASET ..." 

BR,

Sébastien