cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Remove special characters in BW transformations

0 Kudos
12,642

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

Accepted Solutions (1)

Accepted Solutions (1)

former_member182516
Active Contributor
0 Kudos

Hi Silva,

',<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890'.

These are the Valid chars and numbers which will be accepted by BW system, System will throw an error only when load receives a char which is not there in the above. And that char will be treated as a Invalid Char.

In you case the special char is different that the reason why its not taken care by RSKC.

To rectify the error delete the request from DSO and edit the Bad entries in PSA and reload the data to DSO and activate the data.

If you are facing this issue very often then try to implement a logic which handles the special/invalid characters issue.

Check the below link which explains you in details how to implement the routine logic at info object level.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0afbb81-f219-2c10-4181-b20f6b10e...

http://scn.sap.com/people/jyothi.velpula/blog/2010/12/23/removing-invalid-characters-using-field-rou...

Please post the DSO activation error log...

Regards

Prashanth K

Answers (4)

Answers (4)

Former Member
0 Kudos

I just stumbled upon this thread and don't quite agree with the proposed solution.

I thought I'd add this in case anyone comes across the same problem.

The original post mentioned that RSKC contained ALL_CAPITAL, in most cases which should handle all of the characters listed (and in fact pretty much any valid unicode character if you have unicode enabled).


There are a couple of situations which are still considered invalid though:

1. If the first character is a !

2. If the characteristic contains only a #

3. ASCII control characters (< 0x38)

In the specific example mentioned in the original post, the text causing the failure started with a ! and this is what caused the problem.  The proposed solution above will allow the data to be activated, but at the cost of losing a lot of other characters, which if you are dealing with non-english text can be a problem.

When using ALL_CAPITAL in RSKC you should only need to check for the above 3 cases.

Former Member
0 Kudos

This message was moderated.

0 Kudos

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

Former Member
0 Kudos

Hey "cousin"

Thanks for posting back the solution.

Some improvement suggestions:

  1. get the list of invalid characters from the existing configuration, with FM RSKC_ALLOWED_CHAR_GET
  2. Use as escape a character that is more unlikely to be valid, such as: Ø
  3. Pre-define constants at the beginning of the code (makes the code a little more flexible and readable)
  4. using l_sgtxt instead of "a" for the name of the (makes the code more readable).

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:

  1. move the call to RSKC_ALLOWED_CHAR_GET' to the Start routine and store its value in a global variable (improves performance).
  2. turn this code into a function module

Cheers

Renato Silva

0 Kudos

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.

Former Member
0 Kudos

Hi Catia,

Are you completely sure about the character causing the error in BW system.

Can you provide us with the error message log obtained while DSO Activation.

Br,

Arpit

Former Member
0 Kudos

Catia,

It may be possible that character is different that what we see.

You need  to check it in Source in that case.

Regards,

Ganesh