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

nathalie_michel
Participant
0 Likes
2,300

Dear All,

I have this coding

data : w_data(100),w_data1 TYPE string, w_data2 TYPE xstring.

data w_replace(1).

************************************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

w_data1 = 'A A A*R'.

w_replace = ' '.

REPLACE SECTION OFFSET 5 LENGTH 1 OF w_data1 WITH w_replace .

WRITE w_data1.

The idea is to replace the '*' in w_ data1 by a space. In w_replace I put 'ALT+32' and if I look the HEX code w_replace = 20. And it's exactly what I want.

But when I use REPLACE, the '*' is replace by nothing !

w_data1 before REPLACE = 41204120412A52

w_data1 after REPLACE = 412041204152

I want 41204120412052

I have already tried with w_replace = Space , = ' ', = 'ALT+32' For all, same problem

I also tried with 'ALT+255' , the HEX code is A0, and it's correctly replaced in w_data1, but for the rest of the program, I really need a blank corresponding at '20'.

- w_data1 is used to send by mail a PDF .

Idea ???

Thanks

Nathalie

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,294

data: lv_fdpos        type syst-fdpos,
        lv_part1         type c length 5,
        lv_part2         type c length 20,
        lv_final           type char30.

search w_data1 for '.*.'.
lv_fdpos = sy-fdpos - 1.
lv_part1 = w_data1(lv_fdpos).
lv_fdpos = sy-fdpos + 1.
lv_part2 = w_data1+lv_fdpos.
concatenate lv_part1 lv_part2 into lv_final. separated by space.
5 REPLIES 5
Read only

Former Member
0 Likes
1,294

Hi

Use Overlay operator as per below example

DATA: ONE(16), TWO(16).

ONE = '----****++++....'.

TWO = '-+.-.-*.-*+.'.

OVERLAY ONE WITH TWO ONLY '.'.

OVERLAY TWO WITH ONE ONLY '.+'.

OVERLAY ONE WITH TWO ONLY '+*'.

Field ONE now contains '---**-+-*.' and field TWO contains '-*-**-+-*.'.

Read only

Former Member
0 Likes
1,295

data: lv_fdpos        type syst-fdpos,
        lv_part1         type c length 5,
        lv_part2         type c length 20,
        lv_final           type char30.

search w_data1 for '.*.'.
lv_fdpos = sy-fdpos - 1.
lv_part1 = w_data1(lv_fdpos).
lv_fdpos = sy-fdpos + 1.
lv_part2 = w_data1+lv_fdpos.
concatenate lv_part1 lv_part2 into lv_final. separated by space.
Read only

0 Likes
1,294

Hi Florian,

Your suggestion was very helpfull and solved my problem .

Thanks a lot

Read only

MaryM
Participant
0 Likes
1,294

Hi Nathalie,

try:

TRANSLATE w_data1 USING '* '. (*space)

Regards,

MayM

Read only

former_member222860
Active Contributor
0 Likes
1,294

Check this:

data: wdata1 type string value 'A A A*R'.

TRANSLATE wdata1 USING '* '. " give space using Alt+255

write:/ wdata1.