REPORT YLTL_TEST.
TYPES: BEGIN OF TY_DATA,
SEL TYPE ABAP_BOOL,
COL01 TYPE STRING,
COL02 TYPE STRING,
COL03 TYPE STRING,
END OF TY_DATA.
DATA GO_ALV TYPE REF TO CL_GUI_ALV_GRID.
DATA GT_DATA TYPE TABLE OF TY_DATA WITH HEADER LINE.
DATA GS_STABLE TYPE LVC_S_STBL.
DATA GS_LAYOUT TYPE LVC_S_LAYO.
DATA GT_FIELDCAT TYPE LVC_T_FCAT.
DATA GS_FIELDCAT TYPE LVC_S_FCAT.
DATA GT_EVENT TYPE SLIS_T_EVENT.
DATA GS_EVENT TYPE SLIS_ALV_EVENT.
DEFINE %%FILL_DATA.
CLEAR GT_DATA.
GT_DATA-COL01 = &1.
GT_DATA-COL02 = &2.
GT_DATA-COL03 = &3.
APPEND GT_DATA.
END-OF-DEFINITION.
DEFINE %%FILL_FIELDCAT.
CLEAR GS_FIELDCAT.
GS_FIELDCAT-FIELDNAME = &1.
GS_FIELDCAT-SCRTEXT_M = &2.
GS_FIELDCAT-EDIT = &3.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
END-OF-DEFINITION.
START-OF-SELECTION.
%%FILL_DATA '调用SET_FRONTEND_LAYOUT方法并将新的LAYOUT填入参数即可' '调用SET_LDCAT填入参数即可' '调用SED_FIELDFICAT填即可'.
%%FILL_DATA '调用SET_FRONTEND_LA2UT方法并将新的LAYOUT填入参数即可' '调用SET_FRONTEND_FDC参数即可' '调用SET_4IELDCLDC数即可'.
%%FILL_DATA '调用SET_FRONTEND_LAYOU1方法并将新的LAYOUT填入参数即可' '调用SET_FROCAT填入参数即可' '调用S并将新的F即可'.
END-OF-SELECTION.
GS_LAYOUT-ZEBRA = 'X'.
GS_EVENT-NAME = 'CALLER_EXIT'.
GS_EVENT-FORM = 'CALLER_EXIT'.
APPEND GS_EVENT TO GT_EVENT.
%%FILL_FIELDCAT 'COL01' 'COL01' ''.
%%FILL_FIELDCAT 'COL02' 'COL02' ''.
%%FILL_FIELDCAT 'COL03' 'COL03' ''.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* 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_LVC = GS_LAYOUT
IT_FIELDCAT_LVC = GT_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS_LVC =
* IT_SORT_LVC =
* IT_FILTER_LVC =
* IT_HYPERLINK =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = GT_EVENT
* IT_EVENT_EXIT =
* IS_PRINT_LVC =
* IS_REPREP_ID_LVC =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO_LVC =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = GT_DATA
* EXCEPTIONS
* PROGRAM_ERROR = 1
.
*&---------------------------------------------------------------------*
*& Form PF_STATUS_SET
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ALV_STANDARD' EXCLUDING RT_EXTAB.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM USER_COMMAND USING I_UCOMM LIKE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD.
CASE I_UCOMM.
WHEN 'U1'.
%%FILL_DATA '调用SET_FRONTEND_LAYOU1方法并将新的LAYOUT填入参数即可' '调用SET_FRONTEND_FI2DC' '调用SET_4RONTEND_F即可'.
GS_STABLE-ROW = '1'.
GS_STABLE-COL = '1'.
CALL METHOD GO_ALV->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = GS_STABLE.
WHEN 'U2'.
GS_LAYOUT-BOX_FNAME = 'SEL'.
GS_LAYOUT-SEL_MODE = 'A'.
GS_LAYOUT-CWIDTH_OPT = 'X'.
GS_LAYOUT-NO_TOOLBAR = 'X'.
CALL METHOD GO_ALV->SET_FRONTEND_LAYOUT
EXPORTING
IS_LAYOUT = GS_LAYOUT.
WHEN 'U3'.
REFRESH GT_FIELDCAT.
%%FILL_FIELDCAT 'COL01' '列1' 'X'.
%%FILL_FIELDCAT 'COL02' '列2' 'X'.
%%FILL_FIELDCAT 'COL03' '列3' 'X'.
CALL METHOD GO_ALV->SET_FRONTEND_FIELDCATALOG
EXPORTING
IT_FIELDCATALOG = GT_FIELDCAT.
ENDCASE.
IS_SELFIELD-REFRESH = 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CALLER_EXIT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM CALLER_EXIT USING U_EXIT TYPE SLIS_DATA_CALLER_EXIT.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = GO_ALV.
*注册编辑响应事件
CALL METHOD GO_ALV->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER "按enter键
EXCEPTIONS
ERROR = 1
OTHERS = 2.
CALL METHOD GO_ALV->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED "光标移动
EXCEPTIONS
ERROR = 1
OTHERS = 2.
ENDFORM.