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

Use of variable in text elements

Former Member
0 Likes
36,687

Hi All,

I am inputting the value of variable A1 from selection screen.

Now i am using text element to display some msg where i want to use A1.

For eg: text-001.

And in 001 i have wrritten msg 'The status of (value of A1) is OK'

So how to pass variable A1 there??

Any help appreciated.

Regards,

Samruddhi

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
14,482

If your text-001 was 'The status of &1 is OK', then you could copy the value in variable and then replace &1 with value of the field, not very funny.

worktext = text-001. 
REPLACE '&1' WITH field INTO worktext.

Better way, is to use messages.

Via SE91 you define a message say ZMSG number 001 with text 'The status of &1 is OK'

Then in your program you only have to write

MESSAGE S001(ZMSG) WITH field.

The &1 or & characters will be replaced with the parameter of the message (0 to 4 parameters)

Regards

If your text-001 was 'The status of &1 is OK', then you could copy the value in variable and then replace &1 with value of the field, not very funny.

worktext = text-001. 
REPLACE '&1' WITH field INTO worktext.

Better way, is to use messages.

Via SE91 you define a message say ZMSG number 001 with text 'The status of &1 is OK'

Then in your program you only have to write

MESSAGE S001(ZMSG) WITH field.

The &1 or & characters will be replaced with the parameter of the message (0 to 4 parameters)

Regards

11 REPLIES 11
Read only

Former Member
0 Likes
14,482

Hi,

Paste this code.

REPORT Y_TEST_1 message-id ytest .

parameters: mat type matnr.

if not mat is initial.

message e001 with mat.

endif.

(double click on Ytest message -id and give text as "materail & doesnt exist".)

"& "--> will be replaced by mat i.e variable.

Revert back if any issues.

Reward with points if hhelpful.

regards,

Naveen

Read only

0 Likes
14,482

Hi,

Thanks for quick reply.

But, i have some different scenario.

I don't want to display it as a error or warning message..

This will be the final output of my program.

So i am displaying it as follows

A2 = text-001.(where A2 is one variable):

Calling a function module RSSM_ICON_CREATE which creates icon(green colour, or red or yellow) which needs 2 parameters:

text(passing A2) and icon code.

And then using WRITE statement displaying the result.

Read only

0 Likes
14,482

Hi Samruddhi,

Then u cannot change the Value Dynamically in the TEXT-001 statement, as it wiil be constatnt.

so u can use some string function there by u can display that.

revert back if any issues,

Rewrad with points if helpful.

Regards,

Naveen

Read only

Former Member
0 Likes
14,482

Hi

Also you can...

*for example lenght 50

DATA field(50) type c.

Use---> CONCATENATE text-001 ' ' A1 into field.

and display "field".

Regards

Yossi

Read only

RaymondGiuseppi
Active Contributor
14,483

If your text-001 was 'The status of &1 is OK', then you could copy the value in variable and then replace &1 with value of the field, not very funny.

worktext = text-001. 
REPLACE '&1' WITH field INTO worktext.

Better way, is to use messages.

Via SE91 you define a message say ZMSG number 001 with text 'The status of &1 is OK'

Then in your program you only have to write

MESSAGE S001(ZMSG) WITH field.

The &1 or & characters will be replaced with the parameter of the message (0 to 4 parameters)

Regards

Read only

0 Likes
14,482

Thanks for your help.

My problem is almost solved.

But it is displaying 'The status of (value of A1) is OK'

Why the space is comming between A1 value and is??

Any help appreciated..

Read only

0 Likes
14,482

If you use message, no extra space should appear, if you use worktext and your value is not full (leading/trailing spaces) use CONDENSE worktext before using the result.

Regards

Read only

0 Likes
14,482

Thanks for your help.

My problem is solved.

Read only

former_member194669
Active Contributor
0 Likes
14,481

HI,

In SE91 create a message of your message class like this way

"The status of & is OK"

then Use

message e001(ymsg) with text-001.

aRs

Read only

Former Member
0 Likes
14,481

Hi,

The best way to achieve what you eant to is to use a message.In the message add a place holder & and then when you call the message call it like:

message i320(mssgcalss) with 'A'.

'A' will appear in the message.

Thanks,

Sandeep.

Read only

varma_narayana
Active Contributor
0 Likes
14,481

Hi..

You have to Call a <b>Message</b> from the program instead of Text Elements<b></b>

Put the Following Statment in Your Code.

**Calling a message in a program

MESSAGE S001(ZMSGCL) WITH A1.

To Create the Message Class ZMSGCL and the Message Number 001 you have to double click on the Message class ZMSGCL.

It will create the Message class and gives the message numbers from 000 to 999

You enter the following message for 001

001 The status of &1 is OK

Here &1 is the Variable where the Value of A1 is displayed.

Save the Message class and Execute the program.

<b>Reward if Helpful</b>