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 # with space

Former Member
0 Likes
12,245

Hi,

I need to replace the appearance of # character with space in a character field.

the normal Replace property of ABAP does not work.

Please advise.

Sheetal

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,355

Try this.

replace all occurrences of cl_abap_char_utilities=>HORIZONTAL_TAB

in str with space.

Regards,

Rich Heilman

10 REPLIES 10
Read only

Former Member
0 Likes
5,355

try this ..

split v_str at <b>cl_abap_char_utilities=>HORIZONTAL_TAB</b>

Read only

Former Member
5,355

The # you see is not a # in reality thats why it is not workinf.

It must be TAB character or a page break character.

Use the atrributes of the class CL_ABAP_CHAR_UTILITIES like HORIZONTAL_TAB or NEWLINE etc.

replace CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB with space in string.

Regards,

Ravi

Read only

Former Member
0 Likes
5,355

translate w_char using '# ' .

After # space is mandatory in single quotes.

regards,

sai ramesh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
5,356

Try this.

replace all occurrences of cl_abap_char_utilities=>HORIZONTAL_TAB

in str with space.

Regards,

Rich Heilman

Read only

0 Likes
5,355

I have tried this , but the solution is not working for me.

Could you help me with some sample code?

To give you more indepth knowhow--->

I have converted OTF data to PDF into internal table having structure TLINE.

I am trying to replace the ## occurrences from the field TDLINE of this internal table.

Read only

0 Likes
5,355

Well then maybe they are not horiontal tabs, maybe they are carriage returns. Try this next.

replace all occurrences of 
  cl_abap_char_utilities=>CR_LF in str with space.

Regards,

RIch Heilman

Read only

0 Likes
5,355

thanks ...this has solved my initial level problem...

Read only

0 Likes
5,355

Maybe you want to award points for helpful answers, and mark "Solved my problem" next to the answer that really solved your issue.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
5,355

report oo_deneme1.

TYPES: BEGIN OF TY_OUTPUT,

TEXT1(10),

TEXT2(10),

TEXT3(30),

END OF TY_OUTPUT.

DATA: OUTPUT_TAB TYPE TY_OUTPUT OCCURS 0 WITH HEADER LINE.

TYPES: BEGIN OF TY_DATA,

TEXT(80) ,

END OF TY_DATA.

DATA: DATA_TAB TYPE TY_DATA OCCURS 0 .

DATA: DATA_WA TYPE TY_DATA.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>CLIPBOARD_IMPORT

IMPORTING

DATA = DATA_TAB

  • LENGTH =

EXCEPTIONS

CNTL_ERROR = 1

ERROR_NO_GUI = 2

NOT_SUPPORTED_BY_GUI = 3

OTHERS = 4.

IF SY-SUBRC = 0.

LOOP AT DATA_TAB INTO DATA_WA.

replace all occurrences of CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB

in DATA_WA-TEXT with '*'.

SPLIT DATA_WA-TEXT AT '*' INTO

OUTPUT_TAB-TEXT1

OUTPUT_TAB-TEXT2

OUTPUT_TAB-TEXT3.

IF SY-SUBRC = 0 .

APPEND OUTPUT_TAB.

WRITE: / OUTPUT_TAB.

ELSEIF SY-SUBRC = 4.

WRITE: / 'Split error:', DATA_WA-TEXT.

ENDIF.

ENDLOOP.

ELSE.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

Former Member
5,355

hi Sheetal,

Please try the following logic:


data itab type table of tdline.
data wa_itab type tdline.

loop at itab into wa_itab.
   replace all occurrences of 
    cl_abap_char_utilities=>CR_LF in wa_itab-line with space. 
modify itab from wa_itab index sy-tabix.
endloop.

"instead of CR_LF try with HORIZONTAL_TAB also.

Hope this helps,

Sajan Joseph.