在 ABAP 中的消息语句中显示变量 [英] Displaying variables inside message statement in ABAP
问题描述
如何在不使用消息类的情况下在消息语句中显示变量?
How do I display a variable inside a message statement, without using a message class?
IF acct_bal < min_bal.
MESSAGE 'customer balance less than minimum. Balance-->', acct_bal TYPE 'E'.
ENDIF.
我的程序有语法错误,因为系统不允许 acct_bal
进入消息语句.我不想使用带有占位符的消息类来执行此操作:
My program has a syntax error since the system does not allow acct_bal
into the message statement. I don't want to use a message class with placeholders to do this:
Program z_test.
DATA: acct_bal TYPE 'I' value 10,
min_bal TYPE 'I' value 100.
IF acct_bal < min_bal.
MESSAGE 'customer balance less than minimum. Balance-->', acct_bal type 'E'.
ENDIF.
推荐答案
有很多可能性.以下是其中一些.
There are lots of possibilities. Here are some of them.
您可以使用 字符串模板:
MESSAGE |customer balance less than minimum. Balance-->{ acct_bal }| TYPE 'E'.
或者,如果您希望您的消息可通过文本符号进行翻译:
Or if you want your message be translatable via a text symbol:
MESSAGE |{ replace( val = 'customer balance less than minimum. Balance-->&1'(001)
sub = '&1' with = acct_bal ) }| TYPE 'E'.
或者,如果您希望您的消息可通过消息类进行翻译,请通过事务代码 SE91
创建消息 ID,文本customer balance 小于最小值.余额-->&1
,例如消息类ZMSGCLASS
中的ID001
:
Or if you want your message be translatable via a message class, create a Message ID via transaction code SE91
, with the text customer balance less than minimum. Balance-->&1
, for instance the ID 001
in the message class ZMSGCLASS
:
MESSAGE e001(zmsgclass) TYPE 'E' WITH acct_bal.
等
这篇关于在 ABAP 中的消息语句中显示变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!