10-07-2008 4:57 PM
Hi,
Consider one string1 = 'ABCDAE' OR string2 = 'SHEETAL'.
I want to replace the second occurance of A in above string1.and second occurance of E in above string2 with any differnt character.
I tried with offset calculation , length , replace , split stmts.
but always first occurance is getting replace.
Please provide your ideas.
Regards,
Shital
10-07-2008 5:05 PM
10-07-2008 5:15 PM
Hi,
Try this.
data: string1 type char10 value 'ABCDAE',
len type i.
write: / string1.
search string1 for 'A'.
if sy-subrc = 0.
add 1 to sy-fdpos.
len = strlen( string1 ) - sy-fdpos.
replace 'A' in string1+sy-fdpos(len) with '!'.
write: / string1.
endif.
Darren