Lab 7 (Event and Subroutine) - Ans
Lab 7 (Event and Subroutine) - Ans
Exercise1
1. Use SE91 to create a new message class called Z_MESSAGE and add at least one message like
‘Data not found’.
Answer:
3. In the program, capture data from table SPFLI with the selection criteria.
4. Show data (carrid, connid, cityfrom and cityto) if found but show pop-up error message if not
found. (sy-subrc = 4)
1
5. Error message should make use of the message class Z_MESSAGE.
Answer:
*&---------------------------------------------------------------------*
*& Report Z_07_MESSAGE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
Exercise 2
*** create the MACRO here and then call the MACRO***
2
Answer:
*&---------------------------------------------------------------------*
*& Report Z_07_MACRO *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Z_07_MACRO .
TYPES: BEGIN OF int_rec,
customer TYPE c LENGTH 5,
lname TYPE c LENGTH 15,
fname TYPE c LENGTH 15,
END OF int_rec.
DEFINE append_fields.
CLEAR int_wa.
int_wa-customer = &1.
int_wa-lname = &2.
int_wa-fname = &3.
APPEND int_wa TO int_tab.
END-OF-DEFINITION.
3
Exercise 3
Answer:
*&---------------------------------------------------------------------*
*& Report Z_07_SB_DIVIDE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
IF num2 = 0.
MESSAGE i003.
ELSE.
COMPUTE resu = num1 / num2.
ENDIF.
ENDFORM.
4
Exercise 4
1. Write another program named Z_07_SB_DIVIDE1 which call the subroutine externally. That is,
the program will call the subroutine DIVIDE_NUM in program Z_07_SB_DIVIDE.
Answer:
*&---------------------------------------------------------------------*
*& Report Z_07_SB_DIVIDE1 *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
END.