Application Development and Automation 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: 
Read only

REPLACE/TRANSLATE not working

Former Member
0 Likes
5,987

Hi Frnds,

I am using read_text functional module to read PR line item text.

i am getting text like this : " Brass Flareless compression tube fittings### ".

i dont want '###'. so i used below code.

LOOP AT it_tline.

REPLACE ALL OCCURRENCES OF REGEX '#' IN it_tline-tdline WITH ' '.

CONCATENATE p_v_text it_tline-tdline INTO p_v_text SEPARATED BY space.

ENDLOOP.

no changes in text. It is not removing ###. I used below statement also... no result i got.

replace all occurrences of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

in it_tline-tdline with ' '.

Can any body tel me what may be the problem.

15 REPLIES 15
Read only

Former Member
0 Likes
3,791

Hi Kumar,

Just remove REGEX in your replace statement and try it

regards

padma

Edited by: Padmavathi Palli on Jul 11, 2008 6:55 AM

Read only

Former Member
0 Likes
3,791

Hello Kumar,

First try with Just remove REGEX in your replace statement and try it. It still not works then Instead of "CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB" try removing the Carrage feed constant variable in the same class.

Thanks,

Greetson

Read only

Former Member
0 Likes
3,791

REPLACE ALL OCCURRENCES OF '#' IN it_tline-tdline WITH ' '.

wats regex there in that replace statement???

regards,

madhu

Read only

Former Member
0 Likes
3,791

Try to use '#' directly in the replace statement like:

LOOP AT it_tline.

REPLACE ALL OCCURRENCES OF '#' IN it_tline-tdline WITH ' '

IN CHARACTER MODE.

CONCATENATE p_v_text it_tline-tdline INTO p_v_text SEPARATED BY space.

ENDLOOP.

Regards,

Joy.

Read only

0 Likes
3,791

Hi all,

I tried all u r suggestions, it is not working.

if i used in sample report (where we do small practice ) it is working.

like

data : p_v_text type string.

p_v_text = 'Brass Flareless compression tube fittings### '.

REPLACE ALL OCCURRENCES OF '#' IN p_v_text WITH ''.

write : p_v_text.

but in my main report it is not working, I think the text coming from READ_TEXT functional module.

@ greetson can u tell me how can i use: " try removing the Carrage feed constant variable in the same class."

Thanks,

Kumar

Read only

0 Likes
3,791

Hello Kumar,

There is a attribute in the class "CL_ABAP_CHAR_UTILITIES=>" for carriage feed. Check that variabe and use that attribute in your logic.

Thanks,

Greetson

Read only

Former Member
0 Likes
3,791

HI,

As per my knowledge Replace and Transalate will work based on the text Environment. So before using this statement please apply the below code. So that it will set the text environemt.

SET LOCALE LANGUAGE lang [COUNTRY cntry].

i hope this will solves your probelm.

Many Thanks,
Raghu.

Read only

0 Likes
3,791

Hi Grretson,

There is no that type of attribute. i tried with other one FORM_FEED no use.

Can any body give sol. here is my code:

FORM item_text USING p_v_objname

p_c_a07

p_c_ekpo

CHANGING p_v_text.

  • intarnal table declaration

DATA : it_tline TYPE TABLE OF tline WITH HEADER LINE.

CLEAR : p_v_text,

it_tline.

REFRESH it_tline.

  • Reading RFQ texts according to text id.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = p_c_a07

language = sy-langu

name = p_v_objname

object = p_c_ekpo

TABLES

lines = it_tline

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc = 0 AND it_tline[] IS NOT INITIAL.

LOOP AT it_tline.

replace all occurrences of CL_ABAP_CHAR_UTILITIES=>FORM_FEED

in it_tline-tdline with ' '.

REPLACE ALL OCCURRENCES OF '#' IN it_tline-tdline WITH '' IN CHARACTER MODE.

CONCATENATE p_v_text it_tline-tdline INTO p_v_text SEPARATED BY space.

REPLACE ALL OCCURRENCES OF REGEX '#' IN p_v_text WITH ''.

ENDLOOP.

ENDIF.

ENDFORM.

Read only

0 Likes
3,791

Hello Kumar,

Try the attribute "CR_LF" ... My mistake in my previous replies.

Thanks,

Greetson

Read only

0 Likes
3,791

Thanks for reply,

I tried that also...

regards,

Kumar

Read only

0 Likes
3,791

If u r getting '#' for every line in table it_tline then u can try this

FORM item_text USING p_v_objname

p_c_a07

p_c_ekpo

CHANGING p_v_text.

  • intarnal table declaration

DATA : it_tline TYPE TABLE OF tline WITH HEADER LINE.

data: len type i.

CLEAR : p_v_text,

it_tline.

REFRESH it_tline.

  • Reading RFQ texts according to text id.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = p_c_a07

language = sy-langu

name = p_v_objname

object = p_c_ekpo

TABLES

lines = it_tline

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4

object = 5

reference_check = 6

wrong_access_to_archive = 7

OTHERS = 8.

IF sy-subrc = 0 AND it_tline[] IS NOT INITIAL.

LOOP AT it_tline.

len = strlen( it_tline-tdline ).

  • Say for last 3 char u r getting '#'

len = len - 3.

if len > 0.

CONCATENATE p_v_text it_tline-tdline+0(len) INTO p_v_text SEPARATED BY space.

endif.

clear len.

ENDLOOP.

ENDIF.

ENDFORM.

Also u can split the char string into an internal table based on '#' and then only consider string that have char other than '#'.

Regards,

Joy.

Read only

0 Likes
3,791

Hi Joyjit,

I tried split. but text is not splitting. It seems not working.

Any way this text will not come every time like this.

This is the first time happend in this year.

Any way how can i read that text have the '#' charecter so that if that particular char is there i will execute your code.

Regards,

Kumar

Read only

0 Likes
3,791

Hay thanks to allll.

Actually problem in Uploading programe.

There is three spaces in the text file which is Uploaded as PR. That is the reason READ_TEXT giving '###'. that means there is 3 tab spaces in the text.

Any way still i have question why i am not able remove that symbols (###) from text line wich is given READ_TEXT functional module.

If i fnd the sol.. i will post here.... If any body have the answer plz tel me, it will help further..

Thanks,

Kumar

Read only

Ashish_23
Product and Topic Expert
Product and Topic Expert
0 Likes
3,044

Hi Team,
Did anyone found any solution to this issue. This issue is happening with me as well till now.

Read only

Former Member
0 Likes
3,791

Hi try this code..

DATA : t_hex(2) TYPE c.

DATA :y TYPE x VALUE '0D'.

CONCATENATE y ':' INTO t_hex.

TRANSLATE pv_text USING t_hex .

TRANSLATE pv_text USING ': '.