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

Problem In Excel

Former Member
0 Likes
629

Hi All,

I have a variable with text lv_longtext = ' Invoices must be against##Honeywell SA##Succursale du Luxembou ' and i am replacing the duble hashes with below code. after that we are trying to move this text to excel file but the output is coming as

Invoices must be against Honeywell SA Succursale du Luxembou. Please help us to remove the special character  FROM THE TEXT. if we check in debug mode we are able to see the space insted of special character  but after downloaded into the excle we are getting this special character.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN lv_longtext WITH

'  '. ALT 255 ASCII Character is used for space

Used below fm to display into output.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

Thanks,

Venkat

5 REPLIES 5
Read only

Former Member
0 Likes
579

Hi,

Try;

REPLACE ALL OCCURRENCES OF '##' IN lv_longtext WITH space.

instead of

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN lv_longtext WITH

' '.

Çağatay

Read only

0 Likes
579

Hi,,

HASHSES are Entered characters of the long text which is there at purchase order level.

In purchase order they have maintained text like

Invoices must be against

Honeywell SA

Succursale du Luxembou

IF we use read_text fm to get this text we will get DUBLE HASES and that we can't remove using some space..

Read only

0 Likes
579

Did you try to convert the text to a stream using FM CONVERT_ITF_TO_STREAM_TEXT ? Maybe that will work for you in this case.

Read only

0 Likes
579

Hi,

try to use below coding,



DATA:
           c_recdel(1)  type c  value '~',
           c_recdelx    TYPE x  VALUE '7E',   " ~ in hex
           c_segdel(1)  type c  value '^',
           c_segdelx    type x  value '5E',   " ^ in hex
           c_space(1)   type c  value ' ',
           c_spacex     TYPE x  VALUE '20'.   " Space in hex

  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      text           = l_string
*     MIMETYPE       = ' '
*     ENCODING       =
   IMPORTING
     buffer          = l_xstring.

* replace the special characters with a space.
  replace all occurrences of c_recdelx   in l_xstring
          with c_spacex in byte mode.

* replace the special characters with a space.
  replace all occurrences of c_segdelx   in l_xstring
          with c_spacex in byte mode. 

*replace for other special characters....

*   Convert row back to character string.
  CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
    EXPORTING
      im_xstring  = l_xstring
      im_encoding = 'UTF-8'
    IMPORTING
      ex_string   = l_string.

  i_final_line = l_string.

Thanks,

Chandra

Read only

Former Member
0 Likes
579
  1. is often used to represent an unprintable character...How do you know the problem is CRLF? It is very likely something else...in debug, find out what those characters actually are (debug shows the hex value!). Then, if you have something odd, turn off unicode in program attributes, declare data type x with the value of the hex for the bad character, and search for that and replace it with space or whatever is needed.

Your problem could be any hex values below 20 and any hex values above 7E