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: 

ACSII character recognition

Karan_Chopra_
Active Participant
0 Kudos
120

i have an internal table with a 150 character long field(char 150) which has some value i want to replace character in that field with ASCII value less than 32 with space (ASCII 32).

how can i find that in internal table and replace it

8 REPLIES 8

Karan_Chopra_
Active Participant
0 Kudos
78

plz help

Former Member
0 Kudos
78

Hi karan,

You can try that using field symbols.

Former Member
0 Kudos
78

Loop at itab.

i = 0.

j = 1.

Do 150 times.

char = itab+i(j).

If char = ascii32.

char = space.

Endif.

itab+i(j) = char.

i = i + 1.

j = j + 1.

clear char.

Enddo.

Endloop.

Former Member
0 Kudos
78

Hi karan,

you can use this command also

REPLACE ALL OCCURRENCES OF '<character>' IN text WITH ' '.

Reward if useful.

Karan_Chopra_
Active Participant
0 Kudos
78

help guysssssssssss

Former Member
0 Kudos
78

Hi Karan,

DATA: T(15) VALUE 'AbCdEfGhIjfxx'.

TRANSLATE T USING 'fZ'.( here 'f' is the character to be replaced and Z is character replaced).

Hope it helps u..

Reward points if helpful..

Regards,

Goutham.

Karan_Chopra_
Active Participant
0 Kudos
78

i have to check if ASCII is less than 32 how can i do that .

i cannot chk 4 each char less than 32 individually.

0 Kudos
78

Hi Karan.

you can try this code. But please recognize that this coding might have problems in an unicode system.

-


...

DATA : lv_char150 TYPE c LENGTH 150,

lv_len TYPE i,

lv_index TYPE sy-tabix.

FIELD-SYMBOLS <fs> TYPE x.

fill lv_char150 only to demonstrate...

CONCATENATE cl_abap_char_utilities=>horizontal_tab 'Hallo Test' INTO lv_char150.

lv_len = STRLEN( lv_char150 ).

DO lv_len TIMES.

lv_index = sy-index - 1.

ASSIGN lv_char150+lv_index(1) TO <fs> CASTING.

IF <fs> < ''20'.

<fs> = '20'.

ENDIF.

ENDDO.

...

-


Kindly regards,

Stefan