cancel
Showing results for 
Search instead for 
Did you mean: 

handle invalid char at end of text

former_member657893
Participant
0 Kudos

We have written below abap code to handle invalid char ..

Still I am facing below error while activating DSO. present abap cod is  not handling if invalid char are at end of text.

Sample text data from ECC:

KEYBACK DESC: KEYBACK 0S48803 S48K S48 48""
LINER, TOP COVER, PLATE,G20-32-BPC RUBBER##
casques IRIS 2, de couleur VERTE. réf 010110###

Value " CASQUES IRIS 2, DE COULEUR VERTE RF 05010110 " (HEX 20004300410053005100550045005300200049005200490053) of characteristic 0POSTXT contains an error at position 46

DATA : INT_VAR TYPE /BI0/OIPOSTXT.
DATA : str_var1(60) TYPE c.
DATA : var2 TYPE i.
DATA : var3 TYPE i.
DATA : var4 TYPE i.
DATA : str_var6(60) TYPE c.
DATA : length TYPE i.

MOVE SOURCE_FIELDS-SGTXT TO INT_VAR.

TRANSLATE int_var TO UPPER CASE .

length
= STRLEN( int_var ).
DO length TIMES.
  
IF int_var CN
  
',<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890' .
    
IF sy-fdpos IS INITIAL.
      
CLEAR str_var1.
    
ELSE.
       str_var1
= int_var+0(sy-fdpos).
    
ENDIF.
     var2
= STRLEN( int_var ).
     var3
= sy-fdpos + 1.
     var4
= var2 - var3.
    
IF var4 EQ 0.
       str_var6
= int_var+sy-fdpos.
    
ELSE.
       str_var6
= int_var+var3(var4).
    
ENDIF.
    
CONCATENATE str_var1 str_var6 INTO RESULT.
  
ELSE.
     RESULT
= int_var.
  
ENDIF.
   int_var
= RESULT.
ENDDO.
RESULT
= int_var.

please let me know any additional settings required in BW system or modifications of abap code?

Accepted Solutions (1)

Accepted Solutions (1)

sander_vanwilligen
Active Contributor
0 Kudos

HI,

Recently I developed a Character String Cleansing Add-on. There is no need anymore to develop your own logic and maintain it in many Transformations, just use my Add-on with a comprehensive interface and it will solve any problems with invalid characters.

Please have a look at my blog .

Best regards,

Sander

former_member657893
Participant
0 Kudos

below code is working fine

*DATA : INT_VAR TYPE /BI0/OIPOSTXT.

    DATA : INT_VAR(50) TYPE c.

    DATA : str_var1(60) TYPE c.

    DATA : var2 TYPE i.

    DATA : var3 TYPE i.

    DATA : var4 TYPE i.

    DATA : str_var6(60) TYPE c.

    DATA : length TYPE i.



    MOVE SOURCE_FIELDS-SGTXT TO INT_VAR.



    TRANSLATE int_var TO UPPER CASE .



    length = STRLEN( int_var ).

*DO length TIMES.

*  IF int_var CN

    WHILE int_var CN

    ',<>?/\:;"''ABCDEFGHI JKLMNOPQRSTUVWXYZ!%^&*()__+=1234567890' .

      IF sy-fdpos IS INITIAL.

        CLEAR str_var1.

      ELSE.

        str_var1 = int_var+0(sy-fdpos).

      ENDIF.

      var2 = STRLEN( int_var ).

      var3 = sy-fdpos + 1.

      var4 = var2 - var3.

      IF var4 EQ 0.

*        str_var6 = int_var+sy-fdpos.

        CLEAR str_var6.

      ELSE.

        str_var6 = int_var+var3(var4).

      ENDIF.

      CONCATENATE str_var1 str_var6 INTO RESULT.

*  ELSE.

*    RESULT = int_var.

*  ENDIF.

      int_var = RESULT.

    ENDWHILE.

*ENDDO.

    RESULT = int_var.

Answers (3)

Answers (3)

KodandaPani_KV
Active Contributor
0 Kudos

Hi,

add the below statement in the code.

CONDENSE RESULT NO-GAPS.

Thanks,

Phani.

former_member657893
Participant
0 Kudos

exactly where can I add in my code?

former_member657893
Participant
0 Kudos

I added

RESULT = int_var

CONDENSE RESULT NO-GAPS.

is it correct, still I am facing error.

Value "CASQUES IRIS 2 DE COULEUR VERTE RÉF 05010110   " (HEX
43004100530051005500450053002000490052004900530020) of characteristic 0POSTXT
contains an error at position 45

Message no. BRAIN290

Diagnosis

Characters that have a hexadecimal display between HEX00 and HEX1F are not
permitted in characteristic values. The character at position 45 is one of these
characters. The value is therefore not permitted.

Note that these characters cannot be displayed and are therefore displayed as
'#'. The actual character '#' has the hexadecimal display HEX23.

Procedure

Check the origin of the characteristic value. If possible, change the
characteristic value in the source.

Incorrect source text in update routines and transfer routines can also cause
this problem.

former_member657893
Participant
0 Kudos

even I used  below code also at end of my present code, still same error.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN resultWITH ' '.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN result WITH ' '.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>vertical_tab IN result WITH ' '.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN result WITH ' '.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>form_feed INresult WITH ' '.

REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>backspace IN result WITH ' '.

Loed
Active Contributor
0 Kudos

Hi Suneel,

Try this:

DATA : INT_VAR TYPE /BI0/OIPOSTXT.
DATA : length TYPE i.

DATA : num type i.

MOVE SOURCE_FIELDS-SGTXT TO INT_VAR.

TRANSLATE int_var TO UPPER CASE .


num = 0.


length
= STRLEN( int_var ).


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

   ENDIF.

 

   num = num + 1.


ENDDO.


condense int_var NO-GAPS.


RESULT
= int_var.




Just post here for any queries..

Regards,

Loed

yasemin_kilinc
Active Contributor
0 Kudos

Hi,

A modification on Loed's code could be using the standart RSKC_CHAVL_OF_IBOJ_CHECK function. In the do statement of Loed's code, you can code:

data: infoobject type RSD_IOBJNM,

l_d_index type sy_index,

l_d_char type c.

do length times.

l_d_index = sy_index.

l_d_char = INT_VAR+l_d_index.

call function 'RSKC_CHAVL_OF_IBOJ_CHECK'

Exporting

i_chavl = i_d_char

i_iobjname = infoobject

exceptions

chavl_not_allowed = 1.

if sy_subrc NE 0.

INT_VAR+l_d_index(1) = space.

endif.

This will always behave acording to the setting on accepted characters. When there is a character not accepted (with tcode RSKC), thiss code will change that character as space. If you require anything else you can change the "space" part of the code.

Hope it gives an idea

Regards

Yasemin...

KodandaPani_KV
Active Contributor
0 Kudos

Hi,

Below issue cause of HEXA decimal places at position 46. system does not undersatand the hexa decimal places.

we are also not find the HEXA decimal palces - some times it will give the sapce issue.

-Phani.

RafkeMagic
Active Contributor
0 Kudos

I assume your last character is a space... I don't see anything in your logic to remove it

former_member657893
Participant
0 Kudos

Hi Raf,

Please let me know where to include the logic and please give me piece of code