2007 Nov 13 12:16 PM
Dear Experts,
I'm stuck with a problem..... i am trying to REPLACE ALL OCCURRENCES OF 'AND' WITH 'AND datab LE' INTO s_where-low
and since im working with 4.6 this syntax gives me an syntax error as it wont recognize "ALL OCCURRENCES OF" as valid syntax,
Can someone plssss give me an alternative to achieve the above...
Regards,
Goldie.
2007 Nov 13 12:21 PM
Hi,
do like this
REPLACE 'AND' WITH 'AND datab LE' INTO s_where-low.
reward if it helps,
Satish
HI,
see this example.u have to write like this.
DATA: text1 TYPE string VALUE 'I know you know',
sub_string TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.
REPLACE ALL OCCURRENCES OF sub_string in text1 with new.
write:/ text1.
rgds,
bharat.
2007 Nov 13 12:21 PM
Hi,
do like this
REPLACE 'AND' WITH 'AND datab LE' INTO s_where-low.
reward if it helps,
Satish
2007 Nov 15 4:35 AM
thank u satish but this syntax only replaces the first occurrence i want to replace all the occurrence's of the word!
2007 Nov 13 12:22 PM
Hi,
try like this.
REPLACE ALL OCCURRENCES OF 'AND' IN s_where-low WITH ''AND datab LE'.
Regards,
prashant
2007 Nov 15 4:39 AM
Thank u Prashant Sriram and Bharat the syntax still gives me an error im workin on 4.6 and i think "ALL OCCURRENCES OF" addition to the REPLACE syntax results in an error .... im looking for an alternative solution.
2007 Nov 13 12:40 PM
Hi,
See the example below :
DATA: c4(4) TYPE C.
c4 = 'abab'.
REPLACE ALL OCCURRENCES OF 'ab' IN c4 WITH 'CCC'.
Thanks,
Sri.
2007 Nov 13 12:48 PM
HI,
see this example.u have to write like this.
DATA: text1 TYPE string VALUE 'I know you know',
sub_string TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.
REPLACE ALL OCCURRENCES OF sub_string in text1 with new.
write:/ text1.
rgds,
bharat.
2007 Nov 13 12:53 PM
Hi Goldie,
You can do it like below:
Do.
REPLACE f ...WITH g ...INTO h.
if sy-subrc = 0.
else.
exit.
endif.
Enddo.
This will keep on replacing the field with new one till it exists and when not it will exit out of loop.
Please reward points if reply is helpful.
Regards,
Ruchi
2007 Nov 15 4:40 AM
Hi
Check Possible Operations of REPLACE below "
replacing values
DATA: t4(10) TYPE c VALUE 'abcdefghij',
string4 LIKE t4,
str41(4) TYPE c VALUE 'cdef',
str42(4) TYPE c VALUE 'klmn',
str43(2) TYPE c VALUE 'kl',
str44(6) TYPE c VALUE 'klmnop',
len4 TYPE i VALUE 2.
string4 = t4.
WRITE string4.
REPLACE str41 WITH str42 INTO string4.
WRITE / string4.
string4 = t4.
REPLACE str41 WITH str42 INTO string4 LENGTH len4.
WRITE / string4.
string4 = t4.
REPLACE str41 WITH str43 INTO string4.
WRITE / string4.
string4 = t4.
REPLACE str41 WITH str44 INTO string4.
WRITE / string4.
Praveen
Hope it Helps .
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |