Application Development and Automation 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: 
Read only

OPEN DATASET returning '#' character

Former Member
0 Likes
7,774

Hi Experts, I have a question regarding the OPEN DATASET. I know that there are so many threads regarding OPEN DATASET, however, i haven't found any issues like mine. So, here is the issue

I am trying to uploading a text file in a format (MT940) to t-code FF.5 in a background mode. In my program, i am using the OPEN DATASET to read the file and implement some validation in my program. The problem is like this: in the end of each line of the text file, it seems an extra character is appear. For example, if the actual line in the file is '1234567' then, when use OPEN DATASET, the ABAP will read that line as '1234567#' . Any one know why? And anyone know if that '#' characters will always be in the end of the line ? Anyway, my OPEN DATASET code is like this:

OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING UTF-8 TYPE 'UNIX' .

Anyone could tell me what i am doing wrong or anyone have any suggestions, please feel free to reply to my threads..All useful suggestion will be rewarded...Thank you in advance guys....

Hi Experts, I have a question regarding the OPEN DATASET. I know that there are so many threads regarding OPEN DATASET, however, i haven't found any issues like mine. So, here is the issue

I am trying to uploading a text file in a format (MT940) to t-code FF.5 in a background mode. In my program, i am using the OPEN DATASET to read the file and implement some validation in my program. The problem is like this: in the end of each line of the text file, it seems an extra character is appear. For example, if the actual line in the file is '1234567' then, when use OPEN DATASET, the ABAP will read that line as '1234567#' . Any one know why? And anyone know if that '#' characters will always be in the end of the line ? Anyway, my OPEN DATASET code is like this:

OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING UTF-8 TYPE 'UNIX' .

Anyone could tell me what i am doing wrong or anyone have any suggestions, please feel free to reply to my threads..All useful suggestion will be rewarded...Thank you in advance guys....

18 REPLIES 18
Read only

Former Member
0 Likes
4,927

if you are getting the '#' at the end of each line , then that means it is NEWLINE symbol.

so you can replace the '#' NEWLINE using the CL_ABAP_CAHR_UTILITIES=>NEWLINE

try this

REPLACE CL_ABAP_CAHR_UTILITIES=>NEWLINE in w_record with space.

Read only

0 Likes
4,927

I have just tried using the REPLACE cl_abap_char_utilities=>cr_lf IN my_wa WITH space , REPLACE cl_abap_char_utilities=>newline IN my_wa WITH space and REPLACE cl_abap_char_utilities=>horizontal_tab IN my_wa WITH space and it does not seems to have any effect at all. I know this because i am inserting the text file line to a table and i still can see the '#' character in it. Anymore suggestion? Thank you so much anyway...

Read only

0 Likes
4,927

use this REPLACE cl_abap_char_utilities=>horizontal_tab IN wa_tab with SPACE and check in debugging mode.

IF SPACE is not working, use ` `.

To get `, press the button before 1 button in the keyboard.

Read only

Former Member
0 Likes
4,927

Hi ,

I also faced the similar sitation.

Us e the following codeing to remove that # symbol.

YOu can search for that # using the method, cl_abap_char_utilities=>horizontal_tab.

So your coding should look like this. REPLACE cl_abap_char_utilities=>horizontal_tab IN wa_tab with space.

Additional Information:

The concept behind that is, every character including space can be represented in Hexadecimal Format. The Hexadecimal value for TAB is 9.

Read only

Former Member
0 Likes
4,927

Are you doing cross platform transfers?

I mean is the file comming from a UNIX sytem to a Windows system or vice versa. read dataset normally doesnt read the end of line character unless the file was transfered incorrectly. IF you are doing cross platfor transfers you have to select the appropriate transfer mode so that the unix end of line character is replaced by windows end of line character or vice versa.

If the above statement is true for you then the hash you see is not actually a hash, instead it is the end of line character.

Just use the right transfer mode.

regards

vivek

Read only

0 Likes
4,927

Yes, my actual file is actually in Windows environment then i copied the file to my AIX system (where my SAP is installed) then the my program is execute the FF.5 by using the file that is already in the AIX system...Is that make anything different?

Read only

0 Likes
4,927

hi

cross platform data trnsfer is appending the # .

try using CG3Z to do drop the file to app server using ASCII mode

regards

vivek

Read only

0 Likes
4,927

>

> hi

>

> cross platform data trnsfer is appending the # .

>

> try using CG3Z to do drop the file to app server using ASCII mode

>

> regards

> vivek

Hi, is the '#' character will always be there in every end of line? If that is the case, than probably i can just delete the last character of each line of my text file in my program. What do you think?

Read only

0 Likes
4,927

hi...

you can do that but that wil be computing effort...

if u can find a way to upload file in ASCII mode there shouldn't be any problem

but i think deleteing symbol in code wont be that easy..

i have used dat...its diif to do...let me know if it works

regards

vivek

Read only

0 Likes
4,927

>

> Use the following code.

> OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

I did...This is the first thing i did when using OPEN DATASET....Thank you very much anyway...

Read only

0 Likes
4,927

if the character is in end of line then that is NEWLINE, so try to use this

after open the dataset, Read the records then replace the NEWLINE.

REPLACE CL_ABAP_CAHR_UTILITIES=>NEWLINE in w_record with space.

Did you Try that...

Read only

0 Likes
4,927

>

> if the character is in end of line then that is NEWLINE, so try to use this

>

> after open the dataset, Read the records then replace the NEWLINE.

>

>

REPLACE CL_ABAP_CAHR_UTILITIES=>NEWLINE in w_record with space.

>

> Did you Try that...

Yes, i tried that...and the '#' is still there...I also tried:

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN rec WITH space

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN rec WITH space.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN rec WITH space.

But it's not working...

Read only

0 Likes
4,927

hi

as i said it will be diff to change the symbol in code.

try file transfer with ASCII.

regards

vivek

Read only

0 Likes
4,927

Then it is From CR .

Just try with this example...

REPORT  ZTEST_REMOVE_CR.

data: cr(1) type c.
data: text(10).

cr = cl_abap_char_utilities=>cr_lf.

text = cr.


replace cr in text with space.

write text.

in you case it will be

REPLACE ALL OCCURRENCES OF cr IN rec WITH space.

Read only

0 Likes
4,927

>

> hi

> as i said it will be diff to change the symbol in code.

>

> try file transfer with ASCII.

>

> regards

> vivek

Is there a way to upload a file to SAP apps server in background mode? Because when i am using the CG3Z, it only works when i execute my function module in front end (via GUI). However, when i execute my function module from my middleware (webmethods), it doesn't work. It seems CG3Z is only for front end upload...

Any idea guys?

Read only

Former Member
0 Likes
4,927

Use the following code.

OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

Read only

dev_parbutteea
Active Contributor
0 Likes
4,927

Hi,

Unfortunately, the GUI FM's can only be used in foreground...

In background you need to use open dataset.

If there is the '#', it might be because the data type you are using is not char, please try using a data type of CHAR.

Regards,

Sooness

Read only

Former Member
4,927

same problem... looks like OPEN DATASET WITH SMART LINEFEED removes the '#'.