Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Replacing special characters

Former Member
0 Kudos

Hi Experts

I have reqwirement, Purchasing data, using data source 2LIS_02_SCL (Purchasing Data (Schedule Line Level)) fails frequently because it brings unassigned "#" values for the object ZQUOTNUM (Quotation number).

To eliminate the unassigned "#" values automatically write a routine at transfer rules leval.

I found out one function module SCP_REPLACE_STRANGE_CHARS but how to use this function module

Regards

Venkat Marneni

3 REPLIES 3

Former Member
0 Kudos

Hi,

you can use the "replace' statement

constants: c_char type char1 value '#',

w_text is the input text( purchasing data)

REPLACE ALL OCCURRENCES OF c_char IN w_text WITH c_colon.

c_colon is the replacement value.

Regards,

Sriram

Former Member
0 Kudos

Hi,

Just create a function with this code .... and assign the result parameter.

Remember you need to do only Result parameter..

Code follows...

FUNCTION Z_TO_CHANGE_SPECIAL_CHARS.

*"----


""Local Interface:

*"----


DATA: L_USER_ALLOWED_CHAR TYPE RSALLOWEDCHAR,

L_ALL_ALLOWED_CHAR(140) TYPE C,

L_RESULT_STR_LEN TYPE I,

L_STR_INCREMENT TYPE I.

CONSTANTS C_SAP_ALLOWED_CHAR(58) 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.

RESULT = TRAN_STRUCTURE-ZZZ.

TRANSLATE RESULT TO UPPER CASE.

L_RESULT_STR_LEN = STRLEN( RESULT ).

L_STR_INCREMENT = 0.

WHILE L_STR_INCREMENT L_RESULT_STR_LEN.

IF NOT RESULT+L_STR_INCREMENT(1) CO L_ALL_ALLOWED_CHAR.

RESULT+L_STR_INCREMENT(1) = ' '.

ENDIF.

ADD 1 TO L_STR_INCREMENT.

ENDWHILE.

ENDFUNCTION.

Just add your table or structure to the RESULT parameter.

If you are writing a routine... You just copy the whole code and paste it between form ... end form... statments.

I hope that this works..

Regards

Former Member
0 Kudos

data:char(25) value '5#4#2#&1#&' .

replace all occurrences of '#' in char with space.

replace all occurrences of '&' in char with space .

write: char.

regards,

venkat