Better syntax for the purpose (user-exit QQMA0014)
DATA: lv_qmnum TYPE qmnum.
CLEAR lv_qmnum.
IF sy-tcode = 'IW21' AND i_viqmel-qmart = 'M2'.
SELECT SINGLE qmnum FROM viqmel INTO lv_qmnum
WHERE equnr = i_viqmel-equnr AND qmart = 'M2' AND phase IN ('1', '3') .
IF lv_qmnum IS NOT INITIAL.
MESSAGE 'There are open notifications on this Equipment !' TYPE 'I'.
RAISE exit_from_save.
ENDIF.
ENDIF.
Though this is an old and closed discussion, felt like giving an improvised code for the purpose benefiting the solution searching members.
Thank you
KJogeswaraRao