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

Modify a text

Former Member
0 Likes
383

i have a requirement where an Order has 2 material and each material have 2 VAT tax. I need to write a text in the output. and I stored the text in string ZMESSAGE1.

read table vattab where matnr = mat1 and kschl = 'VAT1'.

if sy-subrc ne 0. "Create a a new entries

l_vatper = itab-kbetr.

vatab-amt = itab-kwert.

l_strlen = STRLEN( wa_customers-zmessage1 ) + 1.

if wa_customers-zmessage1 IS INITIAL.

CONCATENATE 'VAT at ' l_vatper '%' vatab-amt l_delim

INTO wa_customers-zmessage1+l_strlen(20)

SEPARATED BY space.

ELSE.

CONCATENATE wa_customers-zmessage1 'VAT at ' l_vatper '%' vatab-amt l_delim

INTO wa_customers-zmessage1+l_strlen(20)

SEPARATED BY space.

endif.

append vatab.

else. "Modify the existing entries with amount field changed

vatab-amt =vatab-amt + itab-kwert.

MODIFY vatab TRANSPORTING AMT.

Now my question is " I need to UPDATE MESSAGE TEXT " ZMESSAGE1 with the new vatab-amt'

eg: VAT AT 4 % 120.00 - original message text

Now my amt = 140

so my final message text should be VAT AT 4% 260.00

Is there any way where I can modify the existing text???

any help..

hope it is clear

thanks

1 ACCEPTED SOLUTION
Read only

venkat_o
Active Contributor
0 Likes
349

Hi, <li>Try this way.


REPORT ztest_notepad.

DATA:str        TYPE string VALUE 'VAT AT 4 % 120.00'.
DATA:new        TYPE string VALUE '260.00'.
DATA:off        TYPE i.
DATA:len        TYPE i.
DATA:remain_len TYPE i.

FIND '%' IN str MATCH OFFSET off.
off        = off + 2.
len        = STRLEN( str ).
remain_len = len - off.

REPLACE str+off(remain_len) IN str WITH new.

WRITE str.
Thanks Venkat.O

1 REPLY 1
Read only

venkat_o
Active Contributor
0 Likes
350

Hi, <li>Try this way.


REPORT ztest_notepad.

DATA:str        TYPE string VALUE 'VAT AT 4 % 120.00'.
DATA:new        TYPE string VALUE '260.00'.
DATA:off        TYPE i.
DATA:len        TYPE i.
DATA:remain_len TYPE i.

FIND '%' IN str MATCH OFFSET off.
off        = off + 2.
len        = STRLEN( str ).
remain_len = len - off.

REPLACE str+off(remain_len) IN str WITH new.

WRITE str.
Thanks Venkat.O