Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

REPLACE OFFSET with space

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

Former Member replied
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.
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question