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

Code help regarding replace

Former Member
0 Likes
402

Hi ,

I need to delete the characters '####' from one of the fields of an gt_data.I have used the followin code to do it.

I also have a problem with append .there are two records created ...but I want only one without the '####'

please correct the code for me.

SPLIT get_data AT con_tab

INTO

gt_data-vbeln gt_data-bolnr

gt_data-status gt_data-service

gt_data-charge gt_data-box

gt_data-date.

APPEND gt_data.

IF NOT gt_data IS INITIAL.

REPLACE '####' WITH co_space INTO gt_data-bolnr.

CONDENSE gt_data-bolnr NO-GAPS.

ENDIF.

APPEND gt_data.

Message was edited by:

ramana peddu

null

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
377

SPLIT get_data AT con_tab

INTO

gt_data-vbeln gt_data-bolnr

gt_data-status gt_data-service

gt_data-charge gt_data-box

gt_data-date.

<b>*APPEND gt_data. "Remove this one</b>

IF NOT gt_data IS INITIAL.

do.

if gt_data-bolnr ca '#'.

REPLACE '#' WITH co_space INTO gt_data-bolnr.

else.

exit.

endif.

enddo.

CONDENSE gt_data-bolnr NO-GAPS.

ENDIF.

APPEND gt_data.

2 REPLIES 2
Read only

Former Member
0 Likes
378

SPLIT get_data AT con_tab

INTO

gt_data-vbeln gt_data-bolnr

gt_data-status gt_data-service

gt_data-charge gt_data-box

gt_data-date.

<b>*APPEND gt_data. "Remove this one</b>

IF NOT gt_data IS INITIAL.

do.

if gt_data-bolnr ca '#'.

REPLACE '#' WITH co_space INTO gt_data-bolnr.

else.

exit.

endif.

enddo.

CONDENSE gt_data-bolnr NO-GAPS.

ENDIF.

APPEND gt_data.

Read only

Former Member
0 Likes
377

The '#' you are seeing is not truely '#' character but some special character like a tab. Try the following code.

DATA: con_tab LIKE cl_abap_char_utilities=>horizontal_tab.

SPLIT get_data AT con_tab

INTO

gt_data-vbeln gt_data-bolnr

gt_data-status gt_data-service

gt_data-charge gt_data-box

gt_data-date.

REPLACE con_tab WITH space INTO gt_data-bolnr.

CONDENSE gt_data-bolnr NO-GAPS.

APPEND gt_data.