05-17-2006 10:33 AM
REPLACE all occurances of '-' WITH space INTO lv_temp.
Please advise
regards
Kumar
05-17-2006 12:04 PM
hii Praneeth
use
<b>SPLIT STRING AT - INTO P1 P2 P3 P4 .
CONCATENATE P1 P2 P3 P4 INTO P SEPARATED BY SPACE .</b>
I tried it ..it worked .
Regards
Naresh
05-17-2006 10:36 AM
replace all occu<b>rr</b>ences of '-' in lv_temp with space.
give 2 R's in occurrences
Message was edited by: Chandrasekhar Jagarlamudi
05-17-2006 12:22 PM
EXCELLENT CHANDRASEKHAR ITS WORKING.
AWARDED MAXIMUM POINTS
THANKS AGAIN
REGARDS
PRANEETH
05-17-2006 10:36 AM
hii
<b>REPLACE ALL OCCURRENCES OF - WITH SPACE into lv_string .</b>
REPLACE<strl>WITH<str2>INTO<c>[LENGTH<1>].
ABAP/4 searches the field <c> for the first occurrence of the first, <1> positions of the pattern <str1>. If no length is specified, it searches for the pattern <str1> in its full length.
Regards
Naresh
05-17-2006 10:37 AM
05-17-2006 10:38 AM
REPORT ZNEGIDEMO .
DATA: A(4) TYPE C,A1(20) VALUE 'Welcome - to-- ABA-P'.
REPLACE ALL OCCURRENCES OF '-' IN a1 with space.
write a1.
it is workin(tested).
05-17-2006 10:39 AM
REPORT abc.
DATA : cha(10) VALUE 'cha-sek'.
REPLACE ALL OCCURRENCES OF '-' IN cha WITH space.
WRITE : cha.
Reward points if helpful and close thread if solved
05-17-2006 10:46 AM
Hi praneeth,
check the below code,it is working.
data: lv_data(30) type c value 'kee-rt-hi'.
REPLACE all occurrences of '-' IN lv_data WITH ' '.
write:/ lv_data.
Award points if helpful.
regards,
keerthi.
Message was edited by: keerthi kiran varanasi
05-17-2006 10:46 AM
Hi,
check this..
REPLACE ALL <b>OCCURRENCES</b> OF '-' WITH SPACE into lv_temp.
regards
vijay
05-17-2006 10:49 AM
To replace a string in a field with a different string, use the REPLACE statement.
REPLACE <str1> WITH <str2> INTO <c> [LENGTH <l>].
The statement searches the field <c> for the first occurrence of the first <l> positions of the pattern <str1>. If no length is specified, it searches for the pattern <str1> in its full length.
Then, the statement replaces the first occurrence of the pattern <str1> in field <c> with the string <str2>. If a length <l> was specified, only the relevant part of the pattern is replaced.
If the return code value of the system field SY-SUBRC is set to 0, this indicates that <str1> was found in <c> and replaced by <str2>. A return code value other than 0 means that nothing was replaced. <str1>, <str2>, and <len> can be variables.
DATA: T(10) VALUE 'abcdefghij',
STRING LIKE T,
STR1(4) VALUE 'cdef',
STR2(4) VALUE 'klmn',
STR3(2) VALUE 'kl',
STR4(6) VALUE 'klmnop',
LEN TYPE I VALUE 2.
STRING = T.
WRITE STRING.
REPLACE STR1 WITH STR2 INTO STRING.
WRITE / STRING.
STRING = T.
REPLACE STR1 WITH STR2 INTO STRING LENGTH LEN.
WRITE / STRING.
STRING = T.
REPLACE STR1 WITH STR3 INTO STRING.
WRITE / STRING.
STRING = T.
REPLACE STR1 WITH STR4 INTO STRING.
WRITE / STRING.
The output appears as follows:
abcdefghij
abklmnghij
abklmnefgh
abklghij
abklmnopgh
regards
vinod
05-17-2006 11:17 AM
Hi Praneeth,
The correct Syntax is,
replace all occurrences of '-' in lv_temp with space.
regards,
Kiran
05-17-2006 11:31 AM
Hai Praneeth
Basic form
REPLACE f WITH g INTO h.
Addition
... LENGTH len (length specification for field f )
Effect
Replaces the first occurrence of the contents of field f in field h with the contents of field g . All fields are handled in their defined length; this means that closing blanks are not ignored.
The return code value indicates whether the string f was found in h and replaced by g :
SY-SUBRC = 0 String replaced.
SY_SUBRC = 4 String not replaced.
Example
DATA FIELD(10).
MOVE 'ABCB' TO FIELD.
REPLACE 'B' WITH 'string' INTO FIELD.
returns:
FIELD = 'AstringCB', SY-SUBRC = 0
Note
The fields f and g in the REPLACE statement should not overlap. Otherwise, the result is undefined.
Addition
... LENGTH len ... (length specification for field f )
Effect
Searches for the string f in the field h not in its (full) field length, but in the length len .
Example
DATA: PATTERN(5) VALUE 'ABC',
LEN TYPE I,
REPL_STRING(5) VALUE '12345',
FIELD(12) VALUE 'abcdeABCDE'.
REPLACE PATTERN WITH REPL_STRING
INTO FIELD.
does not change FIELD , since 'ABC ' does not occur in abcdeABCDE ' .
LEN = STRLEN( PATTERN ).
REPLACE PATTERN LENGTH LEN
WITH REPL_STRING
INTO FIELD.
changes FIELD to 'abcde12345DE' .
Related SEARCH , TRANSLATE , OVERLAY
Thanks & Regards
Sreenivasulu P
05-17-2006 11:56 AM
Thanks for all your replies.
But i am not getting space in between,the two strings are concatenated without space in between.
Thanks
praneet
05-17-2006 12:03 PM
hi then u need to use split command and then use concatenatation
data : a(10),b(10),d(40).
D = Apple/Orange.
Split d at / into a b.
Concatenate a b into d separated by .
Write:/ d.
05-17-2006 12:04 PM
hii Praneeth
use
<b>SPLIT STRING AT - INTO P1 P2 P3 P4 .
CONCATENATE P1 P2 P3 P4 INTO P SEPARATED BY SPACE .</b>
I tried it ..it worked .
Regards
Naresh
05-17-2006 12:09 PM
Hi Naresh,
The problem is I am not sure how many occurences of - will be there in my string.In that case i think this will fail.
Regards
Praneeth
05-17-2006 12:11 PM
[code]In that case declare one itab and concatenate those
check the modified one
REPORT abc.
DATA : BEGIN OF itab OCCURS 0,
str(50),
END OF itab.
DATA : cha(50) VALUE 'cha-sek-jskjfsjf',
str(2000).
SPLIT cha AT '-' INTO TABLE itab.
loop at itab.
concatenate str itab-str into str separated by space.
endloop.
write : str.
Message was edited by: Chandrasekhar Jagarlamudi