Você está na página 1de 9

ABAP Coding for BW Transformation...

Vincent Ong 308 posts since Aug 29, 2011


ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 7, 2014 9:50 AM
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.

Generated by Jive on 2015-08-13+02:00


1

ABAP Coding for BW Transformation...

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 Business Warehouse
Tags: abap, routine, invalid_characters

kodanda pani KV
Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 7, 2014 10: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.

Vincent Ong 308 posts since Aug 29, 2011


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 7, 2014 10:52 AM
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?

Generated by Jive on 2015-08-13+02:00


2

ABAP Coding for BW Transformation...

Many thanks,
Vince

Sajid Shaik 748 posts since May 15, 2006


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 7, 2014 10: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
(996 bytes)

Amit Dahiya 577 posts since Jan 8, 2014


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 7, 2014 5: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.

Generated by Jive on 2015-08-13+02:00


3

ABAP Coding for BW Transformation...

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

Vincent Ong 308 posts since Aug 29, 2011


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 3:21 AM
Hi Amit,
Thanks for the explanation, I have followed what you said and commented the Concatenate statement.
However, it display error:E:Statement "L_USER_ALLOWED_CHAR-ALLOWCHAR" is not defined. Check your
spelling. spelling.

What is did was this: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.

Did I do it wrongly?

Generated by Jive on 2015-08-13+02:00


4

ABAP Coding for BW Transformation...

Thanks,
Vince

Amit Dahiya 577 posts since Jan 8, 2014


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 6:07 PM
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

Generated by Jive on 2015-08-13+02:00


5

ABAP Coding for BW Transformation...

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

Vincent Ong 308 posts since Aug 29, 2011


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 12, 2014 3:40 AM
It worked! Thanks a lot Amit
Appreciated the help.

Amit Dahiya 577 posts since Jan 8, 2014


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 12, 2014 2:53 PM
Good to know that it helped.
Happy working

Generated by Jive on 2015-08-13+02:00


6

ABAP Coding for BW Transformation...

Regards
Amit

Matthew Billingham 10,087 posts since Aug 2, 2004


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 7: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.

Vincent Ong 308 posts since Aug 29, 2011


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 7:52 AM
Hi Matthew,
Thanks for the advice.
Sorry but my abap skills is really limited >.<
I understand you are saying I should use sy_abcde, but may I know how should I put it into this routine?
And I_allowed is always initial that that point, which means I shouldn't use that If-else statement in my code?
Kindly advise please.

Thanks in advance,
Vince

Matthew Billingham 10,087 posts since Aug 2, 2004


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 8:01 AM
Define l_allowed_char using STATIC rather than DATA. Or if it is used in an end-routine or other 7.0 type
routine, define it as a class attribute.

Generated by Jive on 2015-08-13+02:00


7

ABAP Coding for BW Transformation...

For sy-abcde, I'd use:


DATA : v_char TYPE c LENGTH 27.
v_char = sy-abcde. " Since sy-abcde has length 26, the 27th position will have space
Now I notice that you have: IF source_fields-xblnr CA v_char. This means "If XBLNR contains any allowed
characters..."
I think you want "If XBLNR contains any character that isn't allowed". For that you need CN. You can read the
different operations here. ABAP Keyword Documentation

Vincent Ong 308 posts since Aug 29, 2011


Re: ABAP Coding for BW Transformation Routine (Eliminate Invalid Characters) May 9, 2014 10:32 AM
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 ).

Generated by Jive on 2015-08-13+02:00


8

ABAP Coding for BW Transformation...

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

Generated by Jive on 2015-08-13+02:00


9

Você também pode gostar