2006 Aug 14 7:31 AM
Hi All,
I have a requirement, where i have to Remove double quotes after uploading a file.
I am uploading the file using GUI_UPLOAD.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
FILETYPE = 'ASC'
has_field_separator = '"'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_tab INTO wa_tab.
TRANSLATE wa_tab-line USING '" '.
SHIFT wa_tab-line LEFT DELETING LEADING space.
MODIFY it_tab FROM wa_tab.
CLEAR wa_tab.
ENDLOOP.
The above logic is replacing '"' with a blank space. I dont want this blank space which is generated. The double quote should be removed and the next character should shift to left in place of Double quote.
Note : I am on 4.6C and it doesnt have replace all occurrences of.
How to achieve this ?
Thanks in advance,
Best regards,
Prashant
2006 Aug 16 6:26 AM
Well as Vijay already suggested to use CONDENSE statememnt, i will only add that to preserve actual space, you can first translate these to any other character and than use the same logic. for example
LOOP AT it_tab INTO wa_tab.
first translate the space with a ^
TRANSLATE wa_tab-line USING ' ^'.
TRANSLATE wa_tab-line USING '" '.
condense wa_tab-line no-gaps.
now translate back ^ to get space
TRANSLATE wa_tab-line USING '^ '.
MODIFY it_tab FROM wa_tab.
CLEAR wa_tab.
ENDLOOP.
Hope this helps...
Hi All,
I have a requirement, where i have to Remove double quotes after uploading a file.
I am uploading the file using GUI_UPLOAD.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_file
FILETYPE = 'ASC'
has_field_separator = '"'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = it_tab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT it_tab INTO wa_tab.
TRANSLATE wa_tab-line USING '" '.
SHIFT wa_tab-line LEFT DELETING LEADING space.
MODIFY it_tab FROM wa_tab.
CLEAR wa_tab.
ENDLOOP.
The above logic is replacing '"' with a blank space. I dont want this blank space which is generated. The double quote should be removed and the next character should shift to left in place of Double quote.
Note : I am on 4.6C and it doesnt have replace all occurrences of.
How to achieve this ?
Thanks in advance,
Best regards,
Prashant
2006 Aug 14 7:43 AM
Hi Prashant ,
There is one simple method for it . When you find <b>"</b> in you table , you shift the previous data into other tab (table2) . Continue searching and when you get next <b>"</b> again shift the data to table2 .
Hope this helps .
Edit : If you dont want to use another table , you can use function TRIM . To know more about it click
<a href="http://help.sap.com/saphelp_erp2005/helpdata/en/a8/2afd3f2d14e869e10000000a155106/content.htm">TRIM</a>
Message was edited by: Shounak M
Regards ,
Shounak M.
Message was edited by: Shounak M
2006 Aug 14 7:49 AM
2006 Aug 14 7:49 AM
Well, One marco for this ...
* Macro for Avoid special characters
DEFINE check_special_char.
w_len = strlen( &1 ).
w_inc = 0.
do w_len times.
if text-0100 cs &1+w_inc(1).
&1+w_inc(1) = space.
endif.
w_inc = w_inc + 1.
enddo.
END-OF-DEFINITION.
LOOP AT it_tab INTO wa_tab.
check_special_char wa_tab-line.
endloop.where <b>text-0100</b> possess value ' " '.
Hope this helps you !
~thomas.
2006 Aug 14 12:36 PM
Hi,
The TRIM command is not available in 4.6C.
Please let me know any other way to solve the problem.
Best regards,
Prashant
2006 Aug 14 12:41 PM
Hi,
please do the following correction in your code.
LOOP AT it_tab INTO wa_tab.
TRANSLATE wa_tab-line USING '" '.
SHIFT wa_tab-line LEFT DELETING LEADING space.
<b>CONDENSE WA_TAB-LINE no-gaps.</b>
MODIFY it_tab FROM wa_tab.
CLEAR wa_tab.
ENDLOOP.
that will take care.
regards
vijay
2006 Aug 14 1:06 PM
Hi Vijay,
I had tried using Condense No-gaps, but the problem is the file to be uploaded also has a REMARKS field which has statements including spaces. So this spaces should be retained.
Is there any other work around.
Thanks,
Best regards,
Prashant
2006 Aug 14 1:30 PM
Prashant
Try the below logic.
loop at itab into wtab.
split wtab on " into ltab.
do n times. "n number of fields
describe component of ltab.
condense field.
concatenate fields into string.
enddo.
endloop.
Regards
Anurag
2006 Aug 14 1:49 PM
2006 Aug 14 1:58 PM
2006 Aug 16 2:53 AM
Hi Rich,
Does it mean, that this is the limitation in SAP 4.6C.
Best regards,
Prashant
2006 Aug 16 3:02 AM
2006 Aug 16 6:26 AM
Well as Vijay already suggested to use CONDENSE statememnt, i will only add that to preserve actual space, you can first translate these to any other character and than use the same logic. for example
LOOP AT it_tab INTO wa_tab.
first translate the space with a ^
TRANSLATE wa_tab-line USING ' ^'.
TRANSLATE wa_tab-line USING '" '.
condense wa_tab-line no-gaps.
now translate back ^ to get space
TRANSLATE wa_tab-line USING '^ '.
MODIFY it_tab FROM wa_tab.
CLEAR wa_tab.
ENDLOOP.
Hope this helps...