Remove Invalid characters or Special Chars using by FM

Remove Invalid characters or Special Chars


We can remove special characters by using below standard functional module.


CALL FUNCTION 'SCP_REPLACE_STRANGE_CHARS'
      EXPORTING
        INTEXT      =
SOURCE_FIELDS-FIELDNAME
        REPLACEMENT = 46
      IMPORTING
        OUTTEXT     = RESULT.

                CONDENSE RESULT NO-GAPS.
   TRANSLATE RESULT TO UPPER CASE.
   IF RESULT CO '!'.
    RESULT = '.'.
   ENDIF.

Remove Invalid characters using by Program

How To Remove Invalid characters:-

*----------------------------------------------------------------------*
* Author      : Bloger                                                 *
* Description : This program helps for Remove Invalid characters       *
*----------------------------------------------------------------------*
    data: l_d_length like sy-index.
    data: l_d_offset like sy-index.
    data: charallowedupper(60) type c.
    data: charallowedlower(60) type c.
    data: charallowednumbr(60) type c.
    data: charallowedsondr(60) type c.
    data: charallowedall(240) type c.

*-- List of char. that are considered as allowed chars.

    charallowedupper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
    charallowedlower = 'abcdefghijklmnopqrstuvwxyzäüöß°ÖÄÜØɺ'.
    charallowednumbr = '0123456789'.
    charallowedsondr = '!"§$%&/()=?{[]}\u180?`*+~;:_,.-><|@'''.
    concatenate charallowedupper charallowedlower charallowednumbr
    charallowedsondr into charallowedall.

*-- Move the source field to the result
    RESULT = SOURCE_FIELDS-FIELD_NAME.

*-- Start removing invalid chars.
    l_d_length = strlen( RESULT ).
    if not RESULT co charallowedall.
      do l_d_length times.
        l_d_offset = sy-index - 1.
        if not result+l_d_offset(1) co charallowedall.
          result+l_d_offset(1) = ''.
        endif.
      enddo.
    endif.
    translate RESULT to upper case.



*$*$ end of routine - insert your code only before this line         *-*
  ENDMETHOD.                    "compute_0PROD_DESCR



Note:- RESULT SOURCE_FIELDS-FIELD_NAME (FIELD_NAME should be replace your requied infoobject)



Ads: