09-29-2008 3:47 PM
Hi there,
I am using the following code to read data from application server.
open dataset l_ap_file for input
in text mode
encoding default.
if sy-subrc eq 0.
do.
Reading a line from the input file.
read dataset l_ap_file into wa_data.
if sy-subrc ne 0.
exit.
endif.
split wa_data at cl_abap_char_utilities=>horizontal_tab
into gs_input-matnr
gs_input-s1qty
gs_input-s2qty
gs_input-s3qty
gs_input-s4qty
gs_input-s5qty
gs_input-s6qty
gs_input-s7qty
gs_input-s8qty
gs_input-s9qty
gs_input-datab
gs_input-datbi.
gs_input-datbi is a 10 character field. If the input data is 2/28/2010, after split statement, gs_input-datbi looks like 2/28/2010# which is not correct.
I want to eliminate the hash symbol which is the field separator...
I used REPLACE statement to remove # symbol. Still not able to solve the issue...
Could anyone please help me to solve this issue...
Your help is greatly appreciated...
Thanks,
Geetha
09-29-2008 3:56 PM
In this case I would also try to rectify the main issue why you are getting the # character at the end. This is possibly the end of line character which you are getting due to incorrect file transfer method.
Is this file comming from a Windows sytem to a Unix system? If yes than you should use the right transfer mode(ASCII) when transferring the file, so that the windows end of line character is converted to Unix end of line character.
09-29-2008 3:49 PM
hi,
there are more possibilities:
1.
TRANSLATE gs_input-datbi USING '# '.
this will replace the # with space
2.
SHIFT gs_input-datbi RIGHT DELETING TRAILING '#'.
this will move the date to the right end
hope this helps
ec
09-29-2008 3:50 PM
That is Newline symbol. so to remove that you can use
CL_ABAP_CHAR_UTILITIES=>NEWLINE
using REPLACE statement and NEWLINE you can eliminate that.
09-29-2008 4:51 PM
I updated the following statements
read dataset l_ap_file into wa_data.
if sy-subrc ne 0.
exit.
endif.
replace all occurrences of cl_abap_char_utilities=>newline
in wa_data with space.
split wa_data at cl_abap_char_utilities=>horizontal_tab
into gs_input-matnr
gs_input-s1qty
gs_input-s2qty
gs_input-s3qty
gs_input-s4qty
gs_input-s5qty
gs_input-s6qty
gs_input-s7qty
gs_input-s8qty
gs_input-s9qty
gs_input-datab
gs_input-datbi.
Still last field gs_input-datbi has '#' at the end which is a field separator / new line tab.
If I use REPLACE / TRANSLATE command, it's not working.
Any suggestion please...
Thanks & Regards,
Geetha
09-29-2008 3:51 PM
09-29-2008 3:52 PM
Following code is working.
data: w_var type char10.
w_var = '2/28/2010#'.
REPLACE '#' in w_var WITH ''.
09-29-2008 3:52 PM
You might want to split into char fields first.
Your Problem is the wrong data format of your date.
Internal data format for date fields is YYYYMMDD.
To achieve this you can use FM conversion_exit_budat_input.
09-29-2008 3:56 PM
In this case I would also try to rectify the main issue why you are getting the # character at the end. This is possibly the end of line character which you are getting due to incorrect file transfer method.
Is this file comming from a Windows sytem to a Unix system? If yes than you should use the right transfer mode(ASCII) when transferring the file, so that the windows end of line character is converted to Unix end of line character.
09-29-2008 4:30 PM
Yes...I transfered the file(Text tab delimited) from my PC to Unix server using CG3Z TCode.
Thanks,
Geetha
09-29-2008 4:38 PM
When you do the transfer, Use ASCII mode. You will not get the # character at the end.
P.S This will work provided your file doesnt have more than 255 characters in one line.
09-29-2008 4:56 PM
Wow...It works. I transferred the file using ASCII format. Now everything looks OK...
Thanks a lot...
Regards,
Geetha