Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Working with String-REPLACE

Former Member
0 Likes
567

Hi,

I need to replace string contents in the internal table.

FM TEXT_SPLIT & SWA_STRING_SPLIT are not meeting my requirement.

<BSP_PROTCL>://<BSP_SERVER>/SAP/BW/BEX?BOOKMARK_ID=42QDVUFIFCOQ9O50UDSBMJUDO&VA

I need to replace code in between '=" and '&' each time

Any ideas?

Rgds

Praveen

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
515

You could of course use regex, but I am not really a fan of it. So here is a solution.

data: lv_source type string.
data: lv_first_part type string.
data: lv_second_part type string.
data: lv_third_part type string.
data: lv_target type string.
data: Lv_some_other_value type string.

lv_source = `<BSP_PROTCL>://<BSP_SERVER>/SAP/BW/BEX?BOOKMARK_ID=42QDVUFIFCOQ9O50UDSBMJUDO&VA`.

split lv_source at `=` into lv_first_part lv_second_part.
split lv_second_part at `&` into lv_second_part lv_third_part.

Lv_some_other_value = `BlahBlahBlah`.
CONCATENATE lv_first_part `=` lv_some_other_value `&` lv_third_part into lv_target.

write:/ lv_source.
write:/ lv_target.

Regards,

Rich Heilman

2 REPLIES 2
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
516

You could of course use regex, but I am not really a fan of it. So here is a solution.

data: lv_source type string.
data: lv_first_part type string.
data: lv_second_part type string.
data: lv_third_part type string.
data: lv_target type string.
data: Lv_some_other_value type string.

lv_source = `<BSP_PROTCL>://<BSP_SERVER>/SAP/BW/BEX?BOOKMARK_ID=42QDVUFIFCOQ9O50UDSBMJUDO&VA`.

split lv_source at `=` into lv_first_part lv_second_part.
split lv_second_part at `&` into lv_second_part lv_third_part.

Lv_some_other_value = `BlahBlahBlah`.
CONCATENATE lv_first_part `=` lv_some_other_value `&` lv_third_part into lv_target.

write:/ lv_source.
write:/ lv_target.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
515

looks like you want to read the url parameter , see the class CL_HTTP_ENTITY , method GET_FORM_FIELD logic.