Application Development 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: 

Replace a variable in a string by an internal table field value

Former Member
0 Kudos

Hi,

I have a internal table with a field message of length 1500.

I have to replace &1 and &2 in the message field with the value of year and Amount.

For example:

ITAB-Message - 'The letter is for the year &1 and the total amount to be payed is &2'.

In this, &1 should be replace with the year value.

and &2 by amount value.

Can you help me in this?

Thanks,

Vimala

1 REPLY 1

Former Member
0 Kudos

Try this




REPORT ZPROG .


data: begin of itab,
      msg(255) type c,
      end of itab.

data: itab1 like itab occurs 0 with header line.

data: year(4) type n value '1995',
      amount(4) type n value '4000'.


itab1-msg = 'The letter is for year &1 and total amount to payed is &2'
.

replace '&1' with year into itab1-msg.

replace '&2' with amount into itab1-msg.


write:/ itab1-msg.