Wednesday, November 11, 2015

Unwanted Characters

Method 1
*** Removing unwanted characters.
DATA: var_str(100) VALUE
‘QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890-_’  ,
var_custpo TYPE /BIC/OIZCCUSTPO,
var_temp TYPE /BIC/OIZCCUSTPO,
var_len(3) TYPE c.
CLEAR: var_custpo,
var_len,
var_temp.
var_custpo = source_fields-/bic/zccustpo.
var_len = strlen( var_custpo ).
DO var_len TIMES.
SUBTRACT 1 FROM var_len.
IF var_str CS var_custpo+var_len(1).
CONCATENATE var_custpo+var_len(1) var_temp INTO var_temp.
ENDIF.
ENDDO.
RESULT = var_temp.

Method 2

CONSTANTS: c_allowed(100) TYPE C value
‘ #{}[]!”%&”()*+,-./:;<=>?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcd’ &
‘efghi’ &
‘jklmnopqrstuvwxyz ‘.
DATA : var_EANUPC TYPE /BI0/OIEANUPC,
var_len TYPE i,
var_error TYPE sy-subrc,
var_offset TYPE sy-index.
CLEAR: var_EANUPC.
var_EANUPC = SOURCE_FIELDS-EANUPC.
TRANSLATE var_EANUPC TO UPPER CASE.
CLEAR: var_error.
CALL FUNCTION ‘RSKC_CHAVL_CHECK’
EXPORTING
I_CHAVL                     = var_EANUPC
IMPORTING
E_ERR_SUBRC                 = var_error.
IF var_error NE 0.
CLEAR: var_len.
var_len = strlen( var_EANUPC ).
DO var_len TIMES.
CLEAR:var_offset.
var_offset = sy-index – 1.
IF var_EANUPC+var_offset(1) CO c_allowed.
ELSE.
var_EANUPC+var_offset(1) = ”.
ENDIF.
ENDDO.
ENDIF.
* result value of the routine
RESULT = var_EANUPC.

No comments:

Post a Comment