2008 Sep 15 4:01 AM
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....
2008 Sep 15 4:09 AM
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.
2008 Sep 15 4:56 AM
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...
2008 Sep 15 5:01 AM
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.
2008 Sep 15 4:44 AM
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.
2008 Sep 15 5:14 AM
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
2008 Sep 15 5:35 AM
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?
2008 Sep 15 5:45 AM
hi
cross platform data trnsfer is appending the # .
try using CG3Z to do drop the file to app server using ASCII mode
regards
vivek
2008 Sep 15 7:16 AM
>
> 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?
2008 Sep 15 7:30 AM
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
2008 Sep 15 7:46 AM
>
> 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...
2008 Sep 15 9:52 AM
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...
2008 Sep 15 10:00 AM
>
> 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...
2008 Sep 15 10:08 AM
hi
as i said it will be diff to change the symbol in code.
try file transfer with ASCII.
regards
vivek
2008 Sep 15 10:19 AM
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.
2008 Sep 16 7:08 AM
>
> 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?
2008 Sep 15 7:23 AM
Use the following code.
OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.
2008 Sep 17 7:35 AM
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
2010 Oct 25 9:24 PM
same problem... looks like OPEN DATASET WITH SMART LINEFEED removes the '#'.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |