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

Offset/Replacing in a string?

Former Member
0 Likes
2,134

Hi there,

I have a very simple question. I have A STRING-variable in my program which contains comma-sperated data (CSV). Now I want to delete the last ";" which is in this line because it is not needed there.

I tried the following, but it doesn't work (syntax error):



*   Deletion of the last semicolon in the variable lv_line
    lv_length = strlen( lv_line ).
    lv_line+lv_length(1) = space.

It seems to be not possible to use offset in combination with a STRING-variable. CHAR I can't use because I don't know how long the char will be.

Is there any easy way to implement such a replacing of the last semicolon in a string?

Kind regards

Markus

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,316

You don't want to have the last character right.

then use it this way

declare a new variable of string type

data: v_temp type string.

  • Deletion of the last semicolon in the variable lv_line

lv_length = strlen( lv_line ).

v_temp = lv_line(lv_length) .

Hope it proves helpful.

4 REPLIES 4
Read only

Former Member
0 Likes
1,316

what u can do is reverse the string using fm STRING_REVERSE

and use replace first occurence of ';' in our structure with space.

just check the syntax

Read only

robert_altenstraer
Active Participant
0 Likes
1,316

hi

you use the full stinglengh as offset, but you should substact the last char...

lv_lengh = lv_lengh - 1 .

then replace...

or:

replace all occurances of ';' in string by space

robert

Read only

Former Member
0 Likes
1,317

You don't want to have the last character right.

then use it this way

declare a new variable of string type

data: v_temp type string.

  • Deletion of the last semicolon in the variable lv_line

lv_length = strlen( lv_line ).

v_temp = lv_line(lv_length) .

Hope it proves helpful.

Read only

faisalatsap
Active Contributor
0 Likes
1,316

Hi,

Have a Look at my [Sample Code in this Thread|] Hope it will help you to solve out your problem,

Best Regards,

Faisal