cancel
Showing results for 
Search instead for 
Did you mean: 

Removing the '#' from the Text Field output....

Former Member
0 Kudos

Hi,

I have a very annoying issue here...

There's this free text field of type CHAR length 255.

I am populating this field with the free text information that the user populates in a free text box on a BSP page.

Now what I see in this table field is that for every 'Enter' pressed by the user it contains a '#' value.

I want to get rid of that hash value such that it becomes a long string value without '#' (s).

Here's the text that comes from the BSP page into this field;

"Per Ryan#, #,#,I spoke with Sanjiv Tyagi late in the afternoon on Friday."

and here's what I want it to look like;

"Per Ryan, I spoke with Sanjiv Tyagi late in the afternoon on Friday."

I have tried all possible methods (at least the ones that I knew) to make it happen, but the text is not changing to my desired output.

Here's what I have tried;

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN current_note WITH space in character mode.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>vertical_tab IN current_note WITH space in character mode.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN current_note WITH space in character mode.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN current_note WITH space in character mode.

REPLACE all OCCURRENCEs OF '#' IN current_note WITH ',' in character mode.

Unfortunately, nothing happened and the text remained the same.

Please let me know what else should I try to get this done....

Thanks,

Sanjiv

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

I found it !!!

Thanks to Thomas Jung for all the help that he extended to me in solving this issue. I am updating this post for the benefit of the people who may have had or may run into this issue...

Here's what I did;



  DATA: hex_r1(2)  TYPE x VALUE '0D0A'.
  DATA: hex_rb(1)  TYPE x VALUE '20'.

  DATA: uhex_r1(2) TYPE x VALUE '0D0A'.
  DATA: uhex_rb(2) TYPE x VALUE '0020'.

  DATA: char1(1) TYPE c.

  DATA: out_xstring TYPE xstring.

* Remove the non-unicode characters from the note field
****Convert the Character String to Binary String
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text   = current_note
        IMPORTING
          buffer = out_xstring.

      IF cl_abap_char_utilities=>charsize = 1.
        REPLACE ALL OCCURRENCES OF hex_r1 IN out_xstring WITH hex_rb IN BYTE MODE.
      ELSE.
        REPLACE ALL OCCURRENCES OF uhex_r1 IN out_xstring WITH uhex_rb IN BYTE MODE.
      ENDIF.

      CLEAR : current_note.

      DATA:
        convin  TYPE REF TO cl_abap_conv_in_ce.
      CALL METHOD cl_abap_conv_in_ce=>create
        EXPORTING
          input = out_xstring
        RECEIVING
          conv  = convin.

      CALL METHOD convin->read
        IMPORTING
          data = current_note.

      REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN current_note WITH space IN CHARACTER MODE.
      REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>vertical_tab IN current_note WITH space  IN CHARACTER MODE.
      REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN current_note WITH space IN CHARACTER MODE.
      REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN current_note WITH space IN CHARACTER MODE.

      i_zer_reqcansum-act_note = current_note. "current_note.

And after all this, what I had in the activity note field is a string without any non-unicode characters (i.e # ).

This # had been a real problem for me. Hope you'll have the answer to your query here.

By the way, if you'd like to know a little more about the unicode stuff, here's where you should go;

http://www.fileformat.info/info/unicode/char0032/index.htm

Thanks once again to Thomas and to all those who took time to respond to my querries..

Cheers!

Sanjiv Tyagi

Former Member
0 Kudos

Hi,

Could you try to use function CONVERT_STREAM_TO_ITF_TEXT? This function will try to convert the text and remove the special characters. At least the result can give us a hint.

BR

Kami

Former Member
0 Kudos

I appreciate everyone's response on this, but I haven't found the answer to it yet.

Sorry to get back late on this. I could not write back as I was on leave for about a month....

Please let me know if you had any headways in it...

Thanks,

Sanjiv

Former Member
0 Kudos

Unfortunately, I haven't been able to find any solution to this problem yet...

I'd highly appreciate any help from you guys...!

Thanks,

Sanjiv

alejandro_bindi
Active Contributor
0 Kudos

Just in case, did you try entering the same text in another computer? With another keyboard? Logged in with another user? Maybe the problem is between the monitor and the chair...I saw that happen.

On another topic, you mention the user is entering the text on a BSP page...so you shouldn't be posting this issue in the WDA forum...

Regards

alejandro_bindi
Active Contributor
0 Kudos

If the user is indeed pressing Enter, the newline constant should do it...

Try something like this instead of the REPLACE:


  DATA:
    strtab     TYPE string_table,
    str        TYPE string,
    clean_note        TYPE string.

   SPLIT current_note AT cl_abap_char_utilities=>newline
                  INTO TABLE strtab.
   LOOP AT strtab INTO str WHERE str IS NOT INITIAL.
      CONCATENATE clean_note str INTO clean_note
         SEPARATED BY space.
   ENDLOOP.

uday_gubbala2
Active Contributor
0 Kudos

Hi Sanjiv,

I understand that the #'s are being appended coz of the carriage return. But why do you have the 3 commas in between i.e, "#, #,#,". Would the user have entered it as:

Per Ryan

,

,

,I spoke with Sanjiv Tyagi late in the afternoon on Friday.

I was wondering if anything else might be wrong coz if the user had typed as "Per Ryan," and then pressed enter the sequence would have been different like: "Per Ryan,#" but as how you had said its coming as, "Per Ryan#,".

Regards,

Uday

Former Member
0 Kudos

Well, thanks for the response, Uday....

The answer to your question is 'Yes'....

Though this is just an example, but I would imagine even if the user did not put the ( , ) , the situation would still be the same... and I've tested that....

Thanks,

Sanjiv

uday_gubbala2
Active Contributor
0 Kudos

Hi Sanjiv,

I defined a string S1 with the value that you had mentioned:

Per Ryan#, #,#,I spoke with Sanjiv Tyagi late in the afternoon on Friday.

I tried in 2 different ways as shown below:

replace all occurrences of '#' in s1 with ''.

AND

CALL FUNCTION 'SWA_STRING_REMOVE_SUBSTRING'
EXPORTING
input_string = s1
DELETE_PATTERN = '#'
IMPORTING
OUTPUT_STRING = s1 .

In Both The Cases I Got The Output As Below:

Per Ryan, ,,I spoke with Sanjiv Tyagi late in the afternoon on Friday.

Isn't this the kind of output that you were looking for? The system has removed the # character as how you wanted. It has just left behind the comma's that you had purposefully entered.

Regards,

Uday

Am sorry Sanjiv realized that this is a mistake from my side. Sorry for the mixup the code that I was suggesting doesn't work. I will try research & come up with a proper solution.

Edited by: Uday Gubbala on Oct 17, 2008 12:43 PM