Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters)

Hi Abap-gurus,

I am using a simple piece of codes for ABAP-Routine in BW Transformation to eliminate invalid Characters.

The Source is XBLNR and the Target field is 0REF_DOC_NO (Reference Document Number).

My piece of codes as following:-

DATA : v_char(27) TYPE c VALUE 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

DATA: l_user_allowed_char TYPE rsallowedchar,

             input(200) TYPE c,

             l_all_allowed_char(140) TYPE c,

             l_result_str_len TYPE i,

             l_str_increment TYPE i.

     CONSTANTS c_sap_allowed_char(84) TYPE c VALUE

     ' !"%&''()*+,-./:;<=>?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

     IF l_all_allowed_char IS INITIAL.

       SELECT SINGLE * FROM rsallowedchar

       INTO l_user_allowed_char

       WHERE allowkey = 'S'.

       CONCATENATE c_sap_allowed_char

       l_user_allowed_char-allowchar

       INTO l_all_allowed_char.

     ENDIF.

     IF source_fields-xblnr CA v_char.

       input = source_fields-xblnr.

       TRANSLATE input TO UPPER CASE.

       l_result_str_len = STRLEN( input ).

       l_str_increment = 0.

       WHILE l_str_increment LE l_result_str_len.

         IF NOT input+l_str_increment(1) CO l_all_allowed_char.

           input+l_str_increment(1) = ' '.

         ENDIF.

         ADD 1 TO l_str_increment.

       ENDWHILE.

       result = input.

     ENDIF.

However, I still receive error message saying:-

Value '#' (hex. '2300') of characteristic 0REF_DOC_NO contains invalid characters.

Any advice would be greatly Appreicated.

Thanks in advance,

Vince

Tag

SAP NetWeaver Business Warehouse

Tags:
Former Member replied

Hi Vincent,

When I said comment the concatenate statement I meant that complete statement.

You had to comment all three lines.

Now just comment all the IF condition, like below:

"    IF l_all_allowed_char IS INITIAL.

"      SELECT SINGLE * FROM rsallowedchar

"      INTO l_user_allowed_char

"      WHERE allowkey = 'S'.

"      CONCATENATE c_sap_allowed_char

"      l_user_allowed_char-allowchar

"      INTO l_all_allowed_char.

"    ENDIF.

I have tried your code in my local program and it works.
Following is your complete code with some tweaks:

-----------------------------------------------------------------------------------------

DATA : v_char TYPE c LENGTH 27.
DATA: l_user_allowed_char TYPE rsallowedchar,
             input(200) TYPE c,
             l_all_allowed_char(140) TYPE c,
             l_result_str_len TYPE i,
             l_str_increment TYPE i.
CONSTANTS c_sap_allowed_char(84) TYPE c VALUE
' !"%&''()*+,-./:;<=>?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

*     IF l_all_allowed_char IS INITIAL.
*       SELECT SINGLE * FROM rsallowedchar
*       INTO l_user_allowed_char
*       WHERE allowkey = 'S'.
*       CONCATENATE c_sap_allowed_char
*       l_user_allowed_char-allowchar
*       INTO l_all_allowed_char.
*     ENDIF.

v_char = sy-abcde.
IF xblnr CN v_char.
  input = xblnr.
  TRANSLATE input TO UPPER CASE.
  l_result_str_len = strlen( input ).
  l_str_increment = 0.
  WHILE l_str_increment LE l_result_str_len.
    IF NOT input+l_str_increment(1) CO c_sap_allowed_char.
      input+l_str_increment(1) = ' '.
    ENDIF.
    ADD 1 TO l_str_increment.
  ENDWHILE.
  result = input.
ENDIF.

-----------------------------------------------------------------------------------------

Bolds are the values I changed.

Please let me know if this works for you.

Thanks

Amit

1 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question