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

To remove Double quotes while uploading a file

Former Member
0 Likes
4,403

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

1 ACCEPTED SOLUTION
Read only

Rashid_Javed
Contributor
0 Likes
2,572

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...

RJv

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

12 REPLIES 12
Read only

former_member628175
Active Participant
0 Likes
2,572

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

Read only

abdul_hakim
Active Contributor
0 Likes
2,572

hi

try using CONDENSE WA_TAB-LINE.

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
2,572

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.

Read only

Former Member
0 Likes
2,572

Hi,

The TRIM command is not available in 4.6C.

Please let me know any other way to solve the problem.

Best regards,

Prashant

Read only

Former Member
0 Likes
2,572

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

Read only

Former Member
0 Likes
2,572

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

Read only

0 Likes
2,572

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

Read only

0 Likes
2,572

I think that if you use the REPLACE statement instead, that it may shift it for you.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
2,572

This is not working either.



report zrich_0001.

data: str type string.

str = 'This is the string that the "Quotes" must be removed from'.

while sy-subrc = 0.
  replace '"' with ' ' into str.
endwhile.

write:/ str.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
2,572

Hi Rich,

Does it mean, that this is the limitation in SAP 4.6C.

Best regards,

Prashant

Read only

0 Likes
2,572

Not a limitation, we just need to go about it a different way.

Regards,

Rich Heilman

Read only

Rashid_Javed
Contributor
0 Likes
2,573

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...

RJv