SAP ABAP ALV Report with Double Click Event

sap abap programming report sample code is about using alv double click event and its execution in a alv report.The sample coding is as shown below.


type-pools:
slis.
tables:
mara.

types:
begin of x_mara,
matnr like mara-matnr,
box(1),
end of x_mara.

data:
t_mara type standard table of x_mara,
t_events type SLIS_T_EVENT,
t_fieldcat type SLIS_T_FIELDCAT_ALV with header line.

data:
wa_matnr type x_mara,
WA_FIELDCAT LIKE t_fieldcat.
selection-screen begin of block b1.
select-options:
s_matnr for mara-matnr.
selection-screen end of block b1.

start-of-selection.

select matnr from mara into table t_mara
where matnr in s_matnr.
if sy-subrc = 0.
sort t_mara by matnr.
endif.

t_fieldcat-fieldname = 'BOX'.
t_fieldcat-seltext_l = 'Selection'.
t_fieldcat-tabname = 'T_MARA'.
t_fieldcat-checkbox = 'X'.
t_fieldcat-col_pos = 1.
t_fieldcat-input = 'X'.
t_fieldcat-edit = 'X'.
*T_FIELDCAT-hotspot = 'X'.
append t_fieldcat.

clear t_fieldcat.

t_fieldcat-fieldname = 'MATNR'.
t_fieldcat-seltext_l = 'Material'.
t_fieldcat-tabname = 'T_MARA'.
t_fieldcat-col_pos = 2.
T_FIELDCAT-hotspot = 'X'.
append t_fieldcat.

perform f_get_events.
perform f_display_report.

FORM USER_COMMAND1 USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
data:
l_matnr like mara-matnr.

CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'
EXPORTING
input = rs_selfield-value
IMPORTING
OUTPUT = l_matnr.
IF sy-subrc 0.
  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

delete t_mara where matnr = l_matnr.
perform f_display_report.
  • perform f_display_report.
  • CALL TRANSACTION 'KO03' AND SKIP FIRST SCREEN.
ENDFORM. " USER_COMMAND1

&---------------------------------------------------------------------
*& Form f_display_report
----------------------------------------------------------------------
form f_display_report.

data:
l_prog like sy-repid.
l_prog = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
  • I_INTERFACE_CHECK = ' '
  • I_BYPASSING_BUFFER =
  • I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = l_prog
  • I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'USER_COMMAND1'
  • 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 = t_fieldcat[]
  • IT_EXCLUDING =
  • IT_SPECIAL_GROUPS =
  • IT_SORT =
  • IT_FILTER =
  • IS_SEL_HIDE =
I_DEFAULT = 'X'
  • I_SAVE = ' '
  • 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
  • IT_ALV_GRAPHICS =
  • IT_ADD_FIELDCAT =
  • IT_HYPERLINK =
  • I_HTML_HEIGHT_TOP =
  • I_HTML_HEIGHT_END =
  • IT_EXCEPT_QINFO =
  • IMPORTING
  • E_EXIT_CAUSED_BY_CALLER =
  • ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_mara
  • 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. " f_display_report

here all meterials are displayed, as N when i click on the material number it will delete the selected material from the list and it will display's the report, like wise your can check the interactive event how it will works.

2 comments :

  1. hI
    ALV REPORT DOUBLE CLICK EVENT PROGRAM IS ERRORS
    PLZ HELP

    ReplyDelete
  2. perform f_get_events.

    for this where is the form in above report.

    ReplyDelete