Application Development 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: 

Finding Special Characters

Former Member
0 Kudos

During an import into the MARM table, some material number (MATNR) have been imported with special characters. The character we have found was A0(Hex), which is a non-breaking space. The way I found this was through debugging. The special characters are causing some issues with other functions. I'm now trying to write a program to search through the current MATNRs and check if they have these special characters and then print them and the hex versions.

Does anyone have any advice? I've tried looking in different spots but I'm either overlooking it or can't seem to find any info.

Thanks in advance,

CD

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Try this code to remove special characters.

DATA: C_MATNR TYPE CHAR.
DATA: l_d_offset LIKE sy-index.
CONSTANTS: c_allowed(100) TYPE c value u2018ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_u2019.
C_MATNR = MATNR. 
TRANSLATE C_MATNR TO UPPER CASE.  
DO 60 TIMES.
  l_d_offset = sy-index u2013 1.
  IF +l_d_offset(1) CO c_allowed.   " Character allowed, donu2019t do anything
  ELSE.                             " Character not allowed, replace with blank space character
    C_MATNR+l_d_offset(1) = u2018 u2018.
  ENDIF.
  CONDENSE C_MATNR.
  MATNR = C_MATNR.
ENDDO.

This will definitely help you.

Regards,

Lalit Mohan Gupta.

4 REPLIES 4

Former Member
0 Kudos

Hi,

On each iterartion on your table ask if they have special chars...something like this



CONCATENATE SY-ABCDE '0123456789' INTO STRING
LOOP AT IT_MATNR.

IF IT_MATNR-MATNR CO STRING,
" ONLY CONTAINS NORMAL CHARACTERS
ELSE.
" PRINT WHAT YOU NEED.
ENDIF.

I hope this is helpful

bye

gabriel P.-

Former Member
0 Kudos

Hi,

SEARCH dobj FOR pattern (IN BYTE or CHARACTER MODE) could do it but the statement is obsolete.

This can help you to a new equivalent one.

Issa

Edited by: Issa SY on Apr 14, 2009 6:14 PM

Former Member
0 Kudos

field-symbols <x> type x.
assign gv_matnr to <x> casting.

loop at it_matnr into gv_matnr.
  if gv_matnr cn gv_wanted_chars.
    write:
     / 'Char', gv_matnr,
     / 'Hex', <x>.
  endif.
endloop.

See also [this thread.|]

best wishes

Ed

Former Member
0 Kudos

Try this code to remove special characters.

DATA: C_MATNR TYPE CHAR.
DATA: l_d_offset LIKE sy-index.
CONSTANTS: c_allowed(100) TYPE c value u2018ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_u2019.
C_MATNR = MATNR. 
TRANSLATE C_MATNR TO UPPER CASE.  
DO 60 TIMES.
  l_d_offset = sy-index u2013 1.
  IF +l_d_offset(1) CO c_allowed.   " Character allowed, donu2019t do anything
  ELSE.                             " Character not allowed, replace with blank space character
    C_MATNR+l_d_offset(1) = u2018 u2018.
  ENDIF.
  CONDENSE C_MATNR.
  MATNR = C_MATNR.
ENDDO.

This will definitely help you.

Regards,

Lalit Mohan Gupta.