2013 Jan 21 5:07 AM
Hello Experts,
I have internal table like shown below.
APPEND 'SO_SEL' TO itab.
APPEND 'SO_TEST' TO itab.
In the above internal can we replace ‘SO’ with only ‘S’.I tried using statement
REPLACE ALL OCCURRENCES OF REGEX '\b(SO)\b'
IN TABLE itab WITH 'S'
RESPECTING CASE .
But its not working.Please advise.
Thanks
prabahran
2013 Jan 21 5:21 AM
Hi,
REPLACE ALL OCCURRENCES OF 'SO' IN itab WITH ' S'.
Regards,
Vijay
Hello Experts,
I have internal table like shown below.
APPEND 'SO_SEL' TO itab.
APPEND 'SO_TEST' TO itab.
In the above internal can we replace ‘SO’ with only ‘S’.I tried using statement
REPLACE ALL OCCURRENCES OF REGEX '\b(SO)\b'
IN TABLE itab WITH 'S'
RESPECTING CASE .
But its not working.Please advise.
Thanks
prabahran
2013 Jan 21 5:21 AM
Hi,
REPLACE ALL OCCURRENCES OF 'SO' IN itab WITH ' S'.
Regards,
Vijay
2013 Jan 21 8:43 AM
Hi Vijay,
I tried as per your suggestion but its not working.Please see the below screenshots(Before & After Replace statement). 'SO' gets replaced by 'S' in column SELANAME but 'S' present in the column 'KIND' gets shifted into column 'SELNAME'.Please advise if i am wrong.
Thanks
prabahran
2013 Jan 21 9:08 AM
Have you already tried with the CHARACTER/BYTE MODE additions?
2013 Jan 21 9:43 AM
hi Prabaharan ,
could you tell me how you are using the replace statement ?
i tried myself , not getting such prblm :
types : begin of ty_sel,
selname(8),
kind(1),
end of ty_sel.
data : pt_selection type standard table of ty_sel,
wa_sel type ty_sel.
wa_sel-selname = 'p_fmarea'.
wa_sel-kind = 'P'.
append wa_sel to pt_selection.
wa_sel-selname = 'p_layout'.
wa_sel-kind = 'P'.
append wa_sel to pt_selection.
wa_sel-selname = 'SO_ABCAX'.
wa_sel-kind = 'S'.
append wa_sel to pt_selection.
wa_sel-selname = 'SO_XYZ'.
wa_sel-kind = 'S'.
append wa_sel to pt_selection.
wa_sel-selname = 'SO_PQR'.
wa_sel-kind = 'S'.
append wa_sel to pt_selection.
LOOP AT pt_selection into wa_sel.
replace all occurrences of 'SO' in wa_sel-selname with 'S'.
modify pt_selection from wa_sel.
ENDLOOP.
2013 Jan 21 10:06 AM
Hi Yogesh,
could you tell me how you are using the replace statement ?
REPLACE ALL OCCURRENCES OF REGEX 'SO_' IN TABLE itab WITH 'S_'
RESPECTING CASE.
i didnt loop the table instead i used the above statement.
Thanks
prabaharan
2013 Jan 21 11:01 AM
hi prabaharan ,
I consider it you do it by looping the table & replacing in the field.
OR
define the field ( in which you need replacement ) as the last field in internal table.
when you are using
REPLACE ALL OCCURRENCES OF REGEX 'SO_' IN TABLE itab WITH 'S_'
RESPECTING CASE.
TABLE itab is being considered as string here , when you are replacing 'SO_' with 'S_' , actually you are replacing 3 characters by 2 characters , hence all the characters on right are being shifted one place to left .
2013 Jan 21 6:55 AM
Hi ,
Modify your code as below:
APPEND 'SO_SEL' TO itab.
APPEND 'SO_TEST' TO itab.
REPLACE ALL OCCURRENCES OF REGEX 'SO'
IN TABLE itab WITH 'S'
RESPECTING CASE.
This worked for me
Thanks.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |