on 2012 Nov 26 11:50 PM
Hi BW Gurus,
I have a problem with special characters like the following example: “!210247 NUALJOTA”.
I have ALL_CAPITAL in RSKC, and “Lower case” enable option in the infoobject, and I try to use the FM: SCP_REPLACE_STRANGE_CHARS, but there is ativation issues of the DSO regarding invalid characters for this dimension.
Does anybody knows how to solve this problem?
Thanks in advance.
Best regards,
Cátia Coelho
Request clarification before answering.
Hi everyone,
Thank you for the answers! Problem solved with this abap code:
DATA: a TYPE c LENGTH 000050.
DATA: l_len TYPE i,
l_time TYPE i.
MOVE source_fields-sgtxt TO a.
TRANSLATE a TO UPPER CASE.
l_len = strlen( a ).
DO l_len TIMES.
IF a+l_time(1) CN ',<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890' .
a+l_time(1) = '!'.
ENDIF.
l_time = l_time + 1.
ENDDO.
REPLACE ALL OCCURRENCES OF '!' IN a WITH space.
CONDENSE a.
result = a.
Thanks.
Best regards,
Cátia Coelho
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey "cousin"
Thanks for posting back the solution.
Some improvement suggestions:
So, the final code looks like:
CONSTANTS:
c_allowed_char TYPE c LENGTH 200 VALUE
'!,<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890',
c_escape TYPE c VALUE 'Ø'. " because '!' is a valid character too
DATA: l_allowed_char TYPE c LENGTH 200,
l_sgtxt TYPE c LENGTH 000050,
l_len TYPE i,
l_time TYPE i.
" get list of allowed characters - from system config
CALL FUNCTION 'RSKC_ALLOWED_CHAR_GET'
IMPORTING
e_allowed_char = l_allowed_char.
IF sy-subrc <> 0.
" if it fails, get use standard list, from constant
l_allowed_char = c_allowed_char.
ENDIF.
MOVE source_fields-sgtxt TO l_sgtxt.
TRANSLATE l_sgtxt TO UPPER CASE.
l_len = STRLEN( l_sgtxt ).
DO l_len TIMES.
IF l_sgtxt+l_time(1) CN l_allowed_char .
l_sgtxt+l_time(1) = c_escape.
ENDIF.
l_time = l_time + 1.
ENDDO.
REPLACE ALL OCCURRENCES OF c_escape IN l_sgtxt WITH space.
CONDENSE l_sgtxt.
result = l_sgtxt.
Something else that could be done:
Cheers
Renato Silva
I just want to add, if you don't want the blanks got removed, please don't use the Method Concatenate. Because trailing blanks will be ignored .
You can refer the code below.
CONSTANTS:
l_c_chars1(41) TYPE c
VALUE '`"$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJK',
l_c_chars2(47) TYPE c
VALUE 'LMNOPQRSTUVWXYZ[]^_{}abcdefghijklmnopqrstuvwxyz',
c_escape TYPE c VALUE 'Ø'.
DATA:
* l_offset TYPE i,
l_length TYPE i,
l_strlen TYPE i,
l_allowed_chars TYPE string,
l_times TYPE i,
l_index TYPE i,
l_char TYPE c,
l_output TYPE char80.
RESULT = SOURCE_FIELDS-/BIC/PNRPTNTXT.
CONCATENATE l_c_chars1 l_c_chars2 INTO l_allowed_chars.
CONDENSE l_allowed_chars NO-GAPS.
DESCRIBE FIELD RESULT LENGTH l_times IN CHARACTER MODE.
DO l_times TIMES.
l_index = sy-index - 1.
l_char = result+l_index(1).
IF l_char CN l_allowed_chars.
result+l_index(1) = space.
endif.
enddo.
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.