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

Passing Variable in READ_TEXT

Former Member
0 Likes
1,954

Dear Gurus,

Can we pass Variable used in TEXT created by TCODE "so10" in executable Program.

for e.g.

Text created using so10 as :

Your account &knvp-kunnr& has been exceeded the limit.

Can I pass &knvp-kunnr& value ? if yes then how?

I am using the FM READ_TEXT in my Executable report and getting output as:

Your account &knvp-kunnr& has been exceeded the limit.

I need knvp-kunnr values.

Please help ASAP.

12 REPLIES 12
Read only

Former Member
0 Likes
1,574

Not sure why you are using READ_TEXT for this purpose?

Just use Message with place holders would do this job for you.

Please help ASAP.

Please resist yourself to write down these words into your post.

Read only

0 Likes
1,574

thanks for making correction.

then what should i use instead of read_text?

Read only

0 Likes
1,574

http://www.google.co.in/search?hl=en&q=messagewithplaceholders%2BSAP&meta=&aq=f&oq=

Read only

0 Likes
1,574

they are neither messages nor text elements..

I have to use those Text to send emails.

Having 5 different types of email.

so will be creating 5 different text in so10.

using READ_TEXT, making that text available for email in text. but want to replace the variables.

as there are many variables needs to be used in mail.

For e.g.

Your Account number [Variable1] has been exceeded to [variable2]. Please contact your [variable 3]..... and so on.

I hope this clears the requirment.

Read only

0 Likes
1,574

Hi Neha,

You can save the text as

'Your Account number &1 has been exceeded to &2. Please contact your &3..... and so on.'

Then in the code, search for &1 and replace it with desired value (value1).

Search for &2, and replace it with value2.

You can use any word which you are sure will not be present in your message.

For eg : &1/&2 , or, AAAA/BBBB/CCCCC, etc.

Sample code below:

LOOP AT itab INTO wa.

l_codeword_1 = '&1'.

SEARCH wa-line FOR l_codeword_1.

IF sy-subrc EQ 0.

l_value_1 = <pass knvp-kunnr value>

REPLACE l_codeword_1 WITH l_value_1 INTO wa-line.

ENDIF.

SEARCH wa-line FOR l_codeword_2.

IF sy-subrc EQ 0.

l_value_2 = <pass second variable value>

REPLACE l_codeword_2 WITH l_value_2 INTO wa-line.

ENDIF.

wa2-line = wa-line.

APPEND wa2 TO itab2.

ENDLOOP.

This will solve your problem.

Thanks,

Nisha Vengal.

Read only

0 Likes
1,574

Thanks nisha...

but is there any method so that instead of searching and replacing....in READ_TEXT FM only the value of variable gets replaced ?

Read only

0 Likes
1,574

Hi Neha,

I am not sure if there is any better solution for this.

You should not modify the original text, unless requirement is like that.

Just modify the itab with the variable values.

Thanks,

Nisha Vengal.

Read only

Former Member
0 Likes
1,574

Hi,

You want to display the values in Sapscript or Smartforms or report ???

Read only

0 Likes
1,574

in Report I will be using this which will be used in sending emails.

Read only

Former Member
0 Likes
1,574

Hi,

You can create a document in SE61 with your variable &KUNNR& embedded within the text.

Use FM 'DOCU_GET' to read the document in program. Then call FM 'TEXT_SYMBOL_REPLACE' to replace the variable with the value of KUNNR, which is already populated in your program.

SAP standard program RSWUWFML2 for extended notifications uses this logic. You can refer this program for more information.

Read only

Former Member
0 Likes
1,574

Thanks, I am closing this thread, as the same kinda reply I am getting.

I got the solution by own.

Thanks all.

Read only

0 Likes
1,574

Hi Neha,

can you share your solution? TQVM.

Regards,

CN