您的位置:首页 > 其它

If 1=2. What is this code about? MESSAGE where used list

2010-12-01 15:29 441 查看
http://www.saptechnical.com/Tips/ABAP/if1=2.htm

We all might have seen the code "IF 1=2. ....do this...EndIF" and we also know that this code never turns true. The main purpose of such code is for "Maintainability" of the program. Confused?? Read the following:

Depending upon the scenario, we would either issue the messages in the program using MESSAGE statement or sometimes might have to call the standard function module MESSAGE_PREPARE to prepare the whole message and use it wherever required.

CALL FUNCTION 'MESSAGE_PREPARE'
   EXPORTING
     msg_id = msg_id
     msg_no = msg_no
     MSG_VAR1 = sy-msgv1
     MSG_VAR2 = sy-msgv2
     MSG_VAR3 = sy-msgv3
     MSG_VAR4 = sy-msgv4
  IMPORTING
     MSG_TEXT = tdoc-text
  EXCEPTIONS
     FUNCTION_NOT_COMPLETED = 1
     MESSAGE_NOT_FOUND = 2
     OTHERS = 3.

Assume that we have defined custom message class for issuing the messages. If we have to modify certain message in this message class, we first need to check for the where-used list of the message to study the impact of the message change. If the message is issued using the MESSAGE statement in any program, then that program would appear in the where-used list. But if the message is used in the program using the FM MESSAGE_PREPARE or any similar function module, then this program would not appear in the where-used list. So in order to have this program include in the where-used list, we would code the following after the call to the function module MESSAGE_PREPARE.

IF 1=2.

Message E003(xx).

ENDIF.

Since the check "IF 1=2" never gets true, the message would never trigger in the program and this program would appear in the where-used list of that message.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐