TYPES:BEGIN OF TY_ALV.
INCLUDE TYPE ZTFI037_OA.
TYPES:
CHAR1 TYPE CHAR1,
SEL,
END OF TY_ALV.
DATA:GT_ALV TYPE STANDARD TABLE OF TY_ALV.
DATA:GO_GRID TYPE REF TO CL_GUI_ALV_GRID.
SELECT * FROM ZTFI037_OA INTO CORRESPONDING FIELDS OF TABLE GT_ALV .
.
IF GT_ALV[] IS NOT INITIAL.
DATA: LS_LAYOUT TYPE LVC_S_LAYO,
LT_FIELDCAT TYPE LVC_T_FCAT WITH HEADER LINE.
* LT_EVENT TYPE SLIS_T_EVENT.
DATA: L_COLUMN TYPE I.
CHECK SY-BATCH EQ SPACE.
DEFINE SET_FIELD_CATALOG.
l_column = l_column + 1.
lt_fieldcat-col_pos = l_column.
lt_fieldcat-fieldname = &1.
lt_fieldcat-scrtext_m = &2.
lt_fieldcat-key = &3.
lt_fieldcat-no_zero = &4.
IF lt_fieldcat-fieldname = 'CHAR1'.
lt_fieldcat-CHECKBOX = 'X' .
lt_fieldcat-EDIT = 'X'.
ENDIF.
APPEND lt_fieldcat.
CLEAR lt_fieldcat.
END-OF-DEFINITION.
SET_FIELD_CATALOG:
'CHAR1' '选择' 'X' '',
'ZNUM' 'OA表单编码' 'X' '',
'LINE' '行项' 'X' ''.
LS_LAYOUT-ZEBRA = ABAP_TRUE.
LS_LAYOUT-CWIDTH_OPT = ABAP_TRUE.
LS_LAYOUT-BOX_FNAME = 'SEL'.
DATA: LT_EVENT TYPE SLIS_T_EVENT,
LS_EVENT TYPE SLIS_ALV_EVENT.
CONSTANTS: SLIS_EV_DATA_CHANGED TYPE SLIS_FORMNAME VALUE 'DATA_CHANGED',
SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT'.
CLEAR LS_EVENT.
LS_EVENT-NAME = SLIS_EV_CALLER_EXIT_AT_START.
LS_EVENT-FORM = SLIS_EV_CALLER_EXIT_AT_START.
APPEND LS_EVENT TO LT_EVENT.
CLEAR LS_EVENT.
LS_EVENT-NAME = SLIS_EV_DATA_CHANGED.
LS_EVENT-FORM = SLIS_EV_DATA_CHANGED.
APPEND LS_EVENT TO LT_EVENT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
* i_callback_top_of_page = 'FRM_TOP_OF_PAGE'
IS_LAYOUT_LVC = LS_LAYOUT
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT_LVC = LT_FIELDCAT[]
IT_EVENTS = LT_EVENT
I_SAVE = 'A'
TABLES
T_OUTTAB = GT_ALV.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form PF_STATUS_SET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM PF_STATUS_SET USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'PF_STATUS' .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text 工具栏 操作响应
*----------------------------------------------------------------------*
* -->P_GT_FIELDCAT text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM TYPE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = GO_GRID.
* 获取屏幕更新数据
CALL METHOD GO_GRID->CHECK_CHANGED_DATA.
ENDFORM.
FORM DATA_CHANGED USING OR_DATA_CHANGED TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
DATA: LS_MOD_CELLS TYPE LVC_S_MODI.
DATA: LV_TABIX TYPE SY-TABIX,
LV_OK TYPE CHAR1.
FIELD-SYMBOLS: <FS_VALUE> TYPE ANY.
CLEAR: LV_OK,LV_TABIX.
IF <FS_VALUE> IS ASSIGNED.
CLEAR: <FS_VALUE>.
ENDIF.
LOOP AT OR_DATA_CHANGED->MT_GOOD_CELLS INTO LS_MOD_CELLS.
IF LS_MOD_CELLS-FIELDNAME = 'CHAR1'.
READ TABLE GT_ALV INTO DATA(LS_LAV) INDEX LS_MOD_CELLS-ROW_ID.
IF SY-SUBRC = 0.
LS_LAV-CHAR1 = LS_MOD_CELLS-VALUE.
MODIFY GT_ALV FROM LS_LAV TRANSPORTING CHAR1 WHERE ZNUM = LS_LAV-ZNUM.
ENDIF.
ENDIF.
ENDLOOP.
PERFORM FRM_REF_ALV.
ENDFORM. " DATA_CHANGED
*&---------------------------------------------------------------------*
*& Form FRM_REF_ALV
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FRM_REF_ALV .
DATA: LS_STBL TYPE LVC_S_STBL.
LS_STBL-ROW = ABAP_TRUE.
LS_STBL-COL = ABAP_TRUE.
CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LS_STBL.
ENDFORM.
FORM CALLER_EXIT USING U_EXIT TYPE SLIS_DATA_CALLER_EXIT.
DATA LT_F4 TYPE LVC_T_F4.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = GO_GRID.
CALL METHOD GO_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_ENTER
EXCEPTIONS
ERROR = 1
OTHERS = 2.
CALL METHOD GO_GRID->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
ERROR = 1
OTHERS = 2.
ENDFORM. "CALLER_EXIT
ABAP ALV 获取当前行,选中后相同订单同时勾选
最新推荐文章于 2024-03-29 15:44:04 发布