‎2007 Jun 26 9:19 AM
Hey ABAP, i have following Problem:
REPLACE ALL OCCURRENCES OF '.' IN SECTION OFFSET lv_offset of lv_kstbm.
when trying to compile this, it tells me that between "OFFSET" and "of" LENGTH is expected.
REPLACE ALL OCCURRENCES OF '.' IN SECTION OFFSET lv_offset LENGTH lv_length of lv_kstbm.
when compiling this one, it tells me "length lv_length" isnt expected to be there.
lv_length and LV-offset are both local variables of type i.
any ideas?
‎2007 Jun 26 9:24 AM
i think you are combining two things in one...
by pattern replacing.
DATA: c4(4) TYPE C.
c4 = 'abab'.
REPLACE ALL OCCURRENCES OF 'ab' IN c4 WITH 'CCC'.
by position replacing...
DATA: text TYPE STRING.
text = 'abcdefgh'.
REPLACE SECTION OFFSET 4 OF text WITH 'XXXX'.
one of them can be used at a time..
regards
shiba dutta
‎2007 Jun 26 9:24 AM
hi
i think you have to complete the statement with the WITH text addition
REPLACE ALL OCCURRENCES OF '.' IN SECTION OFFSET lv_offset LENGTH lv_length of lv_kstbm WITH 'something'.
if helpful, reward
Sathish. R
‎2007 Jun 26 9:24 AM
i think you are combining two things in one...
by pattern replacing.
DATA: c4(4) TYPE C.
c4 = 'abab'.
REPLACE ALL OCCURRENCES OF 'ab' IN c4 WITH 'CCC'.
by position replacing...
DATA: text TYPE STRING.
text = 'abcdefgh'.
REPLACE SECTION OFFSET 4 OF text WITH 'XXXX'.
one of them can be used at a time..
regards
shiba dutta
‎2007 Jun 26 9:27 AM
chk this example
Pattern-based replacement of all found location of the word "know" in the data objects text1 and text2 by "should know that". After the first REPLACE statement, text1 contains the complete content "I should know that You should know that ", and sy-subrc contains the value 0. The data objects cnt, off, and len contain the values 2, 23, and 16 respectively. After the second REPLACE statement, text2 contains the truncated content "I should know that" and sy-subrc contains the value 2. The data objects cnt, off, and len contain the values 1, 2, and 16.
DATA: text1 TYPE string,
text2(18) TYPE c,
cnt TYPE i,
off TYPE i,
len TYPE i.
text1 = text2 = 'I know you know'.
REPLACE ALL OCCURRENCES OF 'know' IN:
text1 WITH 'should know that'
REPLACEMENT COUNT cnt
REPLACEMENT OFFSET off
REPLACEMENT LENGTH len,
text2 WITH 'should know that'
REPLACEMENT COUNT cnt
REPLACEMENT OFFSET off
REPLACEMENT LENGTH len.