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: 

How to remove symbol # (Output inbound file from SFTP with WRITE statement)

fkato
Discoverer
0 Kudos

Hi experts.

I tried to implement ABAP Program outputs inbound file from SFTP server with WRITE statement.

(not uploading file in SAP appl server, just want to output inbound file contents.)

However, symbol '#' was appeared the end of output result like below.

I tried to use REPLACE and CONDENSE statement to remove # , It did not work.

------------------------------------------------------------------------------

abcdefg

hijklmn

opqrstu#######################################

------------------------------------------------------------------------------

In case of uploading file in SAP appl server, this problem is not occurred.

I think this may be due to file format ( need BEGIN ~ END at the begining and end??)

I refer to the following note:2007916

https://launchpad.support.sap.com/#/notes/2007916

Thanks.

1 ACCEPTED SOLUTION

FredericGirod
Active Contributor

it looks like to be a problem of end-of-line character. What is strange, is you do not have issue with the other lines.

Before, every time you play with FTP (or SFTP) you should check what kind of system is your source & your destination. If it is different you have to transfert the file in ASCII mode, if it is the same you could transfert in BINARY mode. It will replace all the end-of-line character with the good one (Unix & Windows does not use the same).

Maybe you could try to check with a tool like Notepad++ what is the character is hexa at the end of your transfered file.

And you also have in SAP class to help you with this kind of char: CL_ABAP_CHAR_UTILITIES=>CR_LF

4 REPLIES 4

FredericGirod
Active Contributor

it looks like to be a problem of end-of-line character. What is strange, is you do not have issue with the other lines.

Before, every time you play with FTP (or SFTP) you should check what kind of system is your source & your destination. If it is different you have to transfert the file in ASCII mode, if it is the same you could transfert in BINARY mode. It will replace all the end-of-line character with the good one (Unix & Windows does not use the same).

Maybe you could try to check with a tool like Notepad++ what is the character is hexa at the end of your transfered file.

And you also have in SAP class to help you with this kind of char: CL_ABAP_CHAR_UTILITIES=>CR_LF

Sandra_Rossi
Active Contributor

# is the standard SAP character which is used to display a non-displayable character, for instance the "CR_LF" character would be displayed as # (cf Frederic answer).

It may also be due to a bad character encoding conversion (or no conversion at all).

I suggest that you ask the guys who are knowledgeable about the remote server what contains this file, i.e. its format (are they only characters?) and its character set (AKA code page). After that you may transfer in binary mode and interpret the bytes according to the character set (class cl_abap_conv_in_ce for instance).

PS: the note 2007916 - Sample Report for https File Transfer from Application Server to Remote Server is not relevant for your issue.

gdey_geminius
Contributor

you can try one of the below statement

replace all OCCURRENCES OF cl_abap_char_utilities=>cr_lf in lv_string with space.
replace all OCCURRENCES OF cl_abap_char_utilities=>newline in lv_string with space.

Thanks,

Gourab

Sandra_Rossi
Active Contributor
0 Kudos

As you say that uploading the file to the "SAP appl server" is okay, can you show how it should look like please? (but no private/confidential information please)