ABAP 的message 的创建及使用
- se91创建一个message,
图1:
图2:
- 由于作的小测试,代码的命名不太规范
*测试message。
SELECTION-SCREEN begin of BLOCK bk2 WITH FRAME TITLE text-002.
parameters: p_budget type n,
p_area type c,
p_wemge type n.
SELECTION-SCREEN END OF BLOCK bk2.
IF p_budget IS NOT INITIAL.
MESSAGE I000(zfi01) WITH p_budget p_area p_wemge.
endif." ‘ I ’是类型;(zfi01)对应的是图1:message class;000 是对应的图2的message下的消息号:000;with 后的是三个变量,单价、面积、预算。
- 运行代码
图3:
- 弹出结果。因为类型 是‘I’,所以是弹出来的对话框,也可以设置为类型‘e’等。
图4:
PS: 不创建message ,直接运用message:
- se91创建一个message,
图1:
图2:
- 由于作的小测试,代码的命名不太规范
*测试message。
SELECTION-SCREEN begin of BLOCK bk2 WITH FRAME TITLE text-002.
parameters: p_budget type n,
p_area type c,
p_wemge type n.
SELECTION-SCREEN END OF BLOCK bk2.
IF p_budget IS NOT INITIAL.
MESSAGE I000(zfi01) WITH p_budget p_area p_wemge.
endif." ‘ I ’是类型;(zfi01)对应的是图1:message class;000 是对应的图2的message下的消息号:000;with 后的是三个变量,单价、面积、预算。
运行代码
图3:
弹出结果。因为类型 是‘I’,所以是弹出来的对话框,也可以设置为类型‘e’等。
图4:
PS: 不创建message ,直接运用消息:
lMESSAGE 'Test message type I' TYPE 'I'.
结果:图5
PS:
所有的消息都存储在系统数据表T100中,包含四个字段,语言代码,消息类,消息序列号,消息文本。进入消息的初始界面的事务代码为SE91。消息类型(与消息类不同)共六种,A,E,I S,W,X。系统消息类为00。
例: MESSAGE S001(ZMM01) WITH 'Data was not found'."S是消息类型,001是消息文本,在此处为&占位符,所以需要WITH文本来替代,ZMM01是消息类。
TYPES: BEGIN OF task_type,
name TYPE string,
dest TYPE string,
END OF task_type.
DATA: snd_jobs TYPE i,
rcv_jobs TYPE i,
exc_flag TYPE i,
info TYPE rfcsi,
mess TYPE c LENGTH 80,
indx TYPE c LENGTH 4,
name TYPE c LENGTH 8,
task_list TYPE STANDARD TABLE OF task_type,
task_wa TYPE task_type.
DO 10 TIMES.
indx = sy-index.
CONCATENATE 'Task' indx INTO name.
CALL FUNCTION 'RFC_SYSTEM_INFO'
STARTING NEW TASK name
DESTINATION IN GROUP DEFAULT
PERFORMING rfc_info ON END OF TASK
EXCEPTIONS
system_failure = 1 MESSAGE mess
communication_failure = 2 MESSAGE mess
resource_failure = 3.
CASE sy-subrc.
WHEN 0.
snd_jobs = snd_jobs + 1.
WHEN 1 OR 2.
MESSAGE mess TYPE 'I'.
WHEN 3.
IF snd_jobs >= 1 AND
exc_flag = 0.
exc_flag = 1.
WAIT UNTIL rcv_jobs >= snd_jobs
UP TO 5 SECONDS.
ENDIF.
IF sy-subrc = 0.
exc_flag = 0.
ELSE.
MESSAGE 'Resource failure' TYPE 'I'.
ENDIF.
WHEN OTHERS.
MESSAGE 'Other error' TYPE 'I'.
ENDCASE.
ENDDO.
WAIT UNTIL rcv_jobs >= snd_jobs.
LOOP AT task_list INTO task_wa.
WRITE: / task_wa-name, task_wa-dest.
ENDLOOP.
FORM rfc_info USING name.
task_wa-name = name.
rcv_jobs = rcv_jobs + 1.
RECEIVE RESULTS FROM FUNCTION 'RFC_SYSTEM_INFO'
IMPORTING
rfcsi_export = info
EXCEPTIONS
system_failure = 1 MESSAGE mess
communication_failure = 2 MESSAGE mess.
IF sy-subrc = 0.
task_wa-dest = info-rfcdest.
ELSE.
task_wa-dest = mess.
ENDIF.
APPEND task_wa TO task_list.
ENDFORM.
http://hunanlsy1983.blog.163.com/blog/static/6163411820104181044220/