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: 

How to fill variable in product basic text?

former_member188321
Contributor
0 Kudos
179

Hi,

in product master, for any product/service we have a set type: texts. under this,  we have text category basic text.

This text may have variables like: %product_end_date%.

how to fill such variables in abap code when we read this text?

1 ACCEPTED SOLUTION

former_member16322
Participant
0 Kudos
130

Use REPLACE statement.

For example

DATA:

     l_text TYPE string,

     l_product_end_date TYPE c     " Program Variable containing value

     .

REPLACE ALL OCCURRENCES OF '%product_end_date%' IN l_text WITH l_product_end_date .

You may need to do some explicit type conversions if the variable's data is in a type other then character.

3 REPLIES 3

former_member16322
Participant
0 Kudos
131

Use REPLACE statement.

For example

DATA:

     l_text TYPE string,

     l_product_end_date TYPE c     " Program Variable containing value

     .

REPLACE ALL OCCURRENCES OF '%product_end_date%' IN l_text WITH l_product_end_date .

You may need to do some explicit type conversions if the variable's data is in a type other then character.

0 Kudos
130

Hi Steve,

Is this the standard way to fill such variables?

0 Kudos
130

Replace is the standard way to replace one character string with another from with in a character string; if you want to view standard code that does something similar, look at Function MESSAGE_TEXT_BUILD. It is slightly different because it does not use named variable place holders and instead just uses & symbols to indicate variables; however, it should illustrate replacing variables in a text string.