REPORT z_demo_alv_event_exit_3.
*>*********************************************************************
* This report reads and displays data from table TRDIR, *
* using the FM : REUSE_ALV_GRID_DISPLAY *
* The field Counter is filled with the Sort Order *
*---------------------------------------------------------------------*
* Author : Michel PIOUD *
* Email : mpioud@yahoo.fr HomePage : http://www.geocities.com/mpioud *
***********************************************************************
SELECTION-SCREEN :
BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '99' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
TYPE-POOLS slis. " ALV Global Types
*---------------------------------------------------------------------*
TYPES:
BEGIN OF ty_trdir,
name TYPE trdir-name, " ABAP program name
cnam TYPE trdir-cnam, " Created by
cdat TYPE trdir-cdat, " Created on
unam TYPE trdir-unam, " Last changed by
udat TYPE trdir-udat, " Last changed on
accnt TYPE trdir-ldbname,
END OF ty_trdir.
*---------------------------------------------------------------------*
DATA:
gt_trdir TYPE TABLE OF ty_trdir. " Data displayed
*---------------------------------------------------------------------*
INITIALIZATION.
v_1 = 'Maximum of records to read'.
*---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
*---------------------------------------------------------------------*
* Form f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.
SELECT name cnam cdat unam udat
INTO TABLE gt_trdir
UP TO p_max ROWS
FROM trdir
WHERE name LIKE 'Z%'.
PERFORM f_update_counter.
ENDFORM. " F_READ_DATA
*---------------------------------------------------------------------*
* Form f_display_data
*---------------------------------------------------------------------*
FORM f_display_data.
* Macro definition
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = &2.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_event_exit.
clear ls_event_exit.
ls_event_exit-ucomm = &1.
ls_event_exit-after = 'X'.
append ls_event_exit to lt_event_exit.
END-OF-DEFINITION.
DATA :
ls_layout TYPE slis_layout_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_event_exit TYPE slis_event_exit,
lt_event_exit TYPE slis_t_event_exit.
* Build Field Catalog
m_fieldcat 'ACCNT' 'SOID'.
m_fieldcat 'NAME' 'TRDIR'.
m_fieldcat 'CNAM' 'TRDIR'.
m_fieldcat 'CDAT' 'TRDIR'.
m_fieldcat 'UNAM' 'TRDIR'.
m_fieldcat 'UDAT' 'TRDIR'.
* Build Event Exit Table
m_event_exit '&OUP'. " Sort up
m_event_exit '&ODN'. " Sort Down
ls_layout-zebra = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_event_exit = lt_event_exit
TABLES
t_outtab = gt_trdir.
ENDFORM. " F_DISPLAY_DATA
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield. "#EC CALLED
CASE u_ucomm.
WHEN '&OUP' OR '&ODN'. " Sort
PERFORM f_update_counter.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* Form F_UPDATE_COUNTER
*---------------------------------------------------------------------*
FORM f_update_counter.
FIELD-SYMBOLS :
<trdir> TYPE ty_trdir.
LOOP AT gt_trdir ASSIGNING <trdir>.
<trdir>-accnt = sy-tabix.
ENDLOOP.
ENDFORM. " F_UPDATE_COUNTER
******** END OF PROGRAM Z_DEMO_ALV_EVENT_EXIT_3 ***********************
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
7 | Tree ALV 샘플 [5] | 양키(이경환) | 2014.02.05 | 10554 |
6 | 데이터 이메일(e-mail) xls 파일로 보내기 [2] | sapjoy | 2014.10.10 | 6683 |
5 | 파일 메일(e-mail) 첨부로 보내기 [2] | sapjoy | 2014.10.10 | 7206 |
4 | ALV EDIT 샘플 프로그램 | sapjoy | 2015.06.26 | 9258 |
3 | XML 을 아밥 스트럭쳐 또는 인터널테이블로 변경시키는 로직 [1] | 대략나 | 2016.12.20 | 3814 |
2 | HTTP 통신하는 로직 [3] | 대략나 | 2016.12.20 | 5711 |
1 | KR_POSTCODE : 한국주소입력 Version 2.0 | 대략나 | 2021.03.31 | 1012 |
유용하게 사용하겠습니다. 감사합니다^^