Skip to Content

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 07, 2014 at 03:09 PM

    Hi Vincent,

    As I can see from your reply that in RSKC you have following values:

    SPACE@.`|#!"%&'()*+,-–/\:;<=>?_^[]$Ö�0123456789ALL_CAPITAL_PLUS_HEX {}ÜÄ

    And in your code you are concatenating these values in l_all_allowed_char.

    So after this if you are trying to validate and eleminate # from the XBLNR values it is basically considering # as a valid character because it is present in 'rsallowedchar' table.

    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.

    And the control will not go to in the IF condtion at all.

    I suggest try to comment the concatenate statement once and then try to run the DTP, it shuld work.

    Then you make changes accordingly to consider Concatenate statement or not.

    Please let us know how it goes.

    Thanks

    Amit


    test1.JPG (24.7 kB)
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 07, 2014 at 08:21 AM

    Hi,

    please check the RSKC transaction maintain the special char

    then check the BW side in RSKC - ALL_CAPITAL_PLUS_HEX

    check the table - RSALLOWEDCHAR - those special char to maintain or not.

    Thanks,

    Phani.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Kodanda,

      Thanks for the prompt reply, I have checked RSKC on BW and also Table RSALLOWEDCHAR, it shows as below:-

      SPACE@.`|#!"%&'()*+,-–/\:;<=>?_^[]$Ö�0123456789ALL_CAPITAL_PLUS_HEX {}ÜÄ

      The piece of code that I used basically should only take the characters I mentioned in the code right?

      Did I miss something in the ABAP codes?

      Many thanks,

      Vince

  • Posted on May 07, 2014 at 08:59 AM

    Hi,

    In one of my Previous BW Project, we faced same issue and I used the code in the attached file.

    Try it, it might be helpful to you.

    Regards

    Sajid Shaik


    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 09, 2014 at 05:36 AM

    Not directly related to your query, but there are two enhancements to make.

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

    should be a constant, and you should use a different TYPE C LENGTH 27. (This is because the v_char(27) isn't permitted in some contexts, so you'll should get used to it). But in fact, you don't need it. The system field sy-abcde contains what you need.


    This next bit is just wrong:

    IF l_all_allowed_char IS INITIAL.


    l_allowed is ALWAYS initial at this point.


    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Matthew,

      Thanks for the advice,

      I have made changes according to what you have advised, my code as below:-


      Did the changes I do correctly?

      DATA : v_char TYPE c LENGTH 27.

      v_char = Sy-abcde.

      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 CN 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.

      By the way, Someone above (Amit) advised me on commenting off the CONCATENATE statement, do I still need to do that?

      Many thanks for your time,
      Vince

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.