Skip to Content
0

BW replace invalid char

Aug 01, 2017 at 06:04 PM

160

avatar image
Former Member

Hi!

I'm traying to validate a field string, it needs to accept valid characters in BW and the transacction RSKC so if those characters aren't allowed then replace them for "-"(hyphen).

The procedure I'm developing is an implementation of ABAP function (SCP_REPLACE_STRANGE_CHAR) within transformation routine... It returns the strange chars replaced, but it doesn't respect all characters in RSKC added (ÁÉÍÓÚÜÑ)...

What can I do to all the characters in BW and RSKC to be accepted?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Raymond Giuseppi
Aug 02, 2017 at 09:16 AM
1

Try to use FM RSKC_CHAVL_OF_IOBJ_CHECK as in this old sample (I used to call it in an old custom service class executed in some of my Transfer Routine for InfoObject (Mainly when Info Objects came from user input fields without check/rule in ECC)

  " translate result to upper case. " removed 
  length = strlen( result ).
  do length times.
    index = sy-index - 1.
    current_char = result+index(1).
    call function 'RSKC_CHAVL_OF_IOBJ_CHECK'
      exporting
        i_chavl           = current_char
        i_iobjnm          = infoobject
      exceptions
        chavl_not_allowed = 1
        others            = 2.
    if sy-subrc <> 0.
      move ' ' to result+index(1).
    endif.
  enddo.
Share
10 |10000 characters needed characters left characters exceeded
Mohit Agrawal Aug 02, 2017 at 12:17 PM
0

Hi Chris,

Please use below code. It should work.

We take a text string with all the valid characters accepted by BW and check the input string character by character. If anything is invalid, it is replaced by hyphen (-).

DATA: txtstring TYPE c LENGTH 000050.
DATA: l_len TYPE i,
l_time TYPE i.

MOVE source_fields-sgtxt TO txtstring.

TRANSLATE txtstring TO UPPER CASE.


l_len = strlen( txtstring ).


DO l_len TIMES.
IF txtstring+l_time(1) CN ',<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890' .

txtstring+l_time(1) = '-'.
ENDIF.

l_time = l_time + 1.
ENDDO.

result = txtstring.

Now you may like to replace '-' with blank or space.

REPLACE ALL OCCURRENCES OF '!' IN txtstring WITH space.

condense txtstring. "remove all spaces

result = txtstring.

Thanks

Mohit Agrawal

Share
10 |10000 characters needed characters left characters exceeded
Erdem Pekcan Aug 03, 2017 at 10:04 AM
0

Hi,

RSKC setting should be ALL_CAPITAL_PLUS_HEX only. Do not add any other characters, othwerwise the parameter is ignored.

If the problem still occurs, this article will help : https://blogs.sap.com/2017/06/28/removing-invalid-characters-from-bw-load/

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Aug 08, 2017 at 09:04 PM
0

Thanks for help me guys!

I resolved my problem, I used the FM 'RSKC_ALLOWED_CHAR_GET' and I used the next code:

DATA: g_allowed_char(200) TYPE C.

IF g_allowed_char is INITIAL.

CALL FUNCTION 'RSKC_ALLOWED_CHAR_GET' IMPORTING

e_allowed_char = g_allowed_char.

ENDIF.

RESULT = SOURCE_FIELDS-TXZ01.

CHECK g_allowed_char NE 'ALL_CAPITAL'.

DO.

IF not RESULT CO g_allowed_char.

result+sy-fdpos(1) = '-'.

ELSE.

exit.

ENDIF.

ENDDO.

Regards!!

Share
10 |10000 characters needed characters left characters exceeded