Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Sep 28, 2008 at 06:48 AM

    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.
    
    

    Add comment
    10|10000 characters needed characters exceeded