Classical Reports have following events, these events are common for Interactive Reports:
- LOAD-OF-PROGRAM : First event fired, loads program in memory
- INITIALIZATION: Initialize variable
- START-OF-SELECTION : Actual Business Logic (After START-OF-SELECTION)
- END-OF-SELECTION : To end above
- AT SELECTION-SCREEN : To validate Multiple Input fields (After Initialization and before START-OF-SELECTION) (After
- AT SELECTION-SCREEN OUTPUT: To manipulate Dynamic screen
- AT SELECTION-SCREEN ON
- AT SELECTION-SCREEN ON END OF
- AT SELECTION-SCREEN ON BLOCK
- AT SELECTION-SCREEN ON RADIOBUTTON GROUP
- AT SELECTION-SCREEN ON VALUE REQUEST
- TOP-OF-PAGE : To print heading
- END-OF-PAGE: To print footer
Events of Interactive Report in SAP ABAP:
- TOP-OF-PAGE
- END-OF-PAGE
- AT-LINE-SELECTION
- AT USER-COMMAND
- AT PFnn
- SET USER-COMMAND
Sample Program :
REPORT ZEVENTS.
TABLES: mara.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda, " CREATED ON
mtart TYPE mara-mtart, " MATERIAL TYPE
END OF ty_mara.
DATA: itab TYPE TABLE OF ty_mara,
wa TYPE ty_mara.
DATA: it_makt TYPE TABLE OF makt.
" FIELDCATALOG DECLARATION
* types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.
* "SLIS_T_FIELDCAT_ALV" IS A TABLE TYPE WITH STRUCTURE TYPE "SLIS_FIELDCAT_ALV"
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
"****************************** AT SELECTION SCREEN ******************************
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE header.
PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND u1. " FOR ALV
PARAMETERS: p_mara TYPE mara-matnr MODIF ID abc.
PARAMETERS: r2 RADIOBUTTON GROUP g1 . " FOR CLASSICAL
PARAMETERS: p_mtart TYPE mara-mtart MODIF ID xyz.
SELECTION-SCREEN: END OF BLOCK b1.
"****************************** INITIALIZATION ******************************
INITIALIZATION.
header = 'SELECTION CRITERIA'.
p_mara = '000000000000000001'.
p_mtart = 'VERP'.
"****************************** AT SELECTION SCREEN - OUTPUT ******************************
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
IF r2 = 'X'.
screen-active = 0.
ELSE.
screen-active = '1'.
ENDIF.
* MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'XYZ'.
IF r1 = 'X'.
screen-active = 0.
ELSE.
screen-active = '1'.
ENDIF.
* MODIFY SCREEN.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
"****************************** AT SELECTION SCREEN ******************************
AT SELECTION-SCREEN. " FOR WHOLE SELECTION SCREEN VALIDATION
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr = p_mara OR mtart = p_mtart.
IF sy-subrc NE 0.
MESSAGE: 'NOT FOUND' TYPE 'I' DISPLAY LIKE 'I' .
ENDIF.
* ***************************** AT SELECTION SCREEN - ON FIELD ******************************
AT SELECTION-SCREEN ON p_mtart. " FOR ONLY ON REQUIRED FIELD VALIDATON
SELECT SINGLE mtart FROM t134 INTO mara-mtart WHERE mtart = p_mtart.
IF sy-subrc NE 0.
MESSAGE: 'NOT FOUND' TYPE 'E' DISPLAY LIKE 'I'.
ENDIF.
* ***************************** AT SELECTION SCREEN - ON VALUE REQUEST ******************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_mara.
TYPES: BEGIN OF ty_str,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
END OF ty_str.
DATA: itab1 TYPE TABLE OF ty_str.
SELECT matnr ersda FROM mara INTO TABLE itab1 UP TO 10 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'P_MARA'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = '1000'
dynprofield = 'P_MARA'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = itab1[]
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"****************************** START OF SELECTION ******************************
START-OF-SELECTION.
PERFORM: get_data.
PERFORM: display_data.
* &---------------------------------------------------------------------*
* & Form GET_DATA
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM get_data .
IF r1 = 'X'.
SELECT matnr
ersda
mtart FROM mara INTO TABLE itab WHERE matnr = p_mara .
ELSEIF r2 = 'X'.
SELECT matnr
ersda
mtart FROM mara INTO TABLE itab WHERE mtart = p_mtart .
ENDIF.
ENDFORM. " GET_DATA
* &---------------------------------------------------------------------*
* & Form DISPLAY_DATA
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM display_data .
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_MARA.'.
wa_fieldcat-seltext_m = 'MAT_NO.'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-seltext_m = 'CRATED ON.'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-seltext_m = 'MAT_TYPE'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = '2ND-SCREEN'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
i_save = 'A'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_DATA
"************ At USER COMMAND **********************************
FORM 2nd-screen USING r_ucomm TYPE sy-ucomm " CAPTURE CURSOR NEXT ACTION - LIKE SAVE, DOUBLE CLICK
r_sel TYPE slis_selfield. " SLIS_SELFIELD - --- CURSOR POSTION(VALUE)
DATA: var1 TYPE mara-matnr.
var1 = r_sel-value.
SELECT * FROM makt INTO TABLE it_makt WHERE matnr = var1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'MAKT'
i_default = 'X'
TABLES
t_outtab = it_makt[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
TABLES: mara.
TYPE-POOLS: slis.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda, " CREATED ON
mtart TYPE mara-mtart, " MATERIAL TYPE
END OF ty_mara.
DATA: itab TYPE TABLE OF ty_mara,
wa TYPE ty_mara.
DATA: it_makt TYPE TABLE OF makt.
" FIELDCATALOG DECLARATION
* types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.
* "SLIS_T_FIELDCAT_ALV" IS A TABLE TYPE WITH STRUCTURE TYPE "SLIS_FIELDCAT_ALV"
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
"****************************** AT SELECTION SCREEN ******************************
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE header.
PARAMETERS: r1 RADIOBUTTON GROUP g1 USER-COMMAND u1. " FOR ALV
PARAMETERS: p_mara TYPE mara-matnr MODIF ID abc.
PARAMETERS: r2 RADIOBUTTON GROUP g1 . " FOR CLASSICAL
PARAMETERS: p_mtart TYPE mara-mtart MODIF ID xyz.
SELECTION-SCREEN: END OF BLOCK b1.
"****************************** INITIALIZATION ******************************
INITIALIZATION.
header = 'SELECTION CRITERIA'.
p_mara = '000000000000000001'.
p_mtart = 'VERP'.
"****************************** AT SELECTION SCREEN - OUTPUT ******************************
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'ABC'.
IF r2 = 'X'.
screen-active = 0.
ELSE.
screen-active = '1'.
ENDIF.
* MODIFY SCREEN.
ENDIF.
IF screen-group1 = 'XYZ'.
IF r1 = 'X'.
screen-active = 0.
ELSE.
screen-active = '1'.
ENDIF.
* MODIFY SCREEN.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
"****************************** AT SELECTION SCREEN ******************************
AT SELECTION-SCREEN. " FOR WHOLE SELECTION SCREEN VALIDATION
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr = p_mara OR mtart = p_mtart.
IF sy-subrc NE 0.
MESSAGE: 'NOT FOUND' TYPE 'I' DISPLAY LIKE 'I' .
ENDIF.
* ***************************** AT SELECTION SCREEN - ON FIELD ******************************
AT SELECTION-SCREEN ON p_mtart. " FOR ONLY ON REQUIRED FIELD VALIDATON
SELECT SINGLE mtart FROM t134 INTO mara-mtart WHERE mtart = p_mtart.
IF sy-subrc NE 0.
MESSAGE: 'NOT FOUND' TYPE 'E' DISPLAY LIKE 'I'.
ENDIF.
* ***************************** AT SELECTION SCREEN - ON VALUE REQUEST ******************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_mara.
TYPES: BEGIN OF ty_str,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
END OF ty_str.
DATA: itab1 TYPE TABLE OF ty_str.
SELECT matnr ersda FROM mara INTO TABLE itab1 UP TO 10 ROWS.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
* DDIC_STRUCTURE = ' '
retfield = 'P_MARA'
* PVALKEY = ' '
dynpprog = sy-repid
dynpnr = '1000'
dynprofield = 'P_MARA'
* STEPL = 0
* WINDOW_TITLE =
* VALUE = ' '
value_org = 'S'
* MULTIPLE_CHOICE = ' '
* DISPLAY = ' '
* CALLBACK_PROGRAM = ' '
* CALLBACK_FORM = ' '
* MARK_TAB =
* IMPORTING
* USER_RESET =
TABLES
value_tab = itab1[]
* FIELD_TAB =
* RETURN_TAB =
* DYNPFLD_MAPPING =
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"****************************** START OF SELECTION ******************************
START-OF-SELECTION.
PERFORM: get_data.
PERFORM: display_data.
* &---------------------------------------------------------------------*
* & Form GET_DATA
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM get_data .
IF r1 = 'X'.
SELECT matnr
ersda
mtart FROM mara INTO TABLE itab WHERE matnr = p_mara .
ELSEIF r2 = 'X'.
SELECT matnr
ersda
mtart FROM mara INTO TABLE itab WHERE mtart = p_mtart .
ENDIF.
ENDFORM. " GET_DATA
* &---------------------------------------------------------------------*
* & Form DISPLAY_DATA
* &---------------------------------------------------------------------*
* text
* ----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
* ----------------------------------------------------------------------*
FORM display_data .
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-tabname = 'IT_MARA.'.
wa_fieldcat-seltext_m = 'MAT_NO.'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ERSDA'.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-seltext_m = 'CRATED ON.'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-tabname = 'IT_MARA'.
wa_fieldcat-seltext_m = 'MAT_TYPE'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = '2ND-SCREEN'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
i_default = 'X'
i_save = 'A'
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab[]
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_DATA
"************ At USER COMMAND **********************************
FORM 2nd-screen USING r_ucomm TYPE sy-ucomm " CAPTURE CURSOR NEXT ACTION - LIKE SAVE, DOUBLE CLICK
r_sel TYPE slis_selfield. " SLIS_SELFIELD - --- CURSOR POSTION(VALUE)
DATA: var1 TYPE mara-matnr.
var1 = r_sel-value.
SELECT * FROM makt INTO TABLE it_makt WHERE matnr = var1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'MAKT'
i_default = 'X'
TABLES
t_outtab = it_makt[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
No comments:
Post a Comment