1、获取鼠标光标位置
DATA :gv_line TYPE i.
gv_index = tc_material-top_line + gv_line - 1.
CLEAR : gs_tc_material_wa.
READ TABLE gt_tc_material_itab INDEX gv_index INTO gs_tc_material_wa.
2、点击删除按钮弹出确认提示框
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
text_question = 'Are you sure to delete this line?'
icon_button_1 = 'Yes'
icon_button_2 = 'No'
default_button = '2'
display_cancel_button = ''
IMPORTING
answer = lv_answer
* TABLES
* PARAMETER =
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
3、如果确认删除
删除数据后弹出提示Message,删除成功后刷新页面
IF lv_answer EQ 1. "Yes
DELETE ztv_xx_tst_ctrl
FROM gs_tc_material_wa.
* data delete successfully!
MESSAGE s005(zvtst_screen).
CLEAR : gv_tc_material_copied.
REFRESH CONTROL 'tc_material' FROM SCREEN '9000'.
ENDIF.
4、插入数据
* insert current row data into table
CLEAR : gs_tc_material_wa.
gs_tc_material_wa-mandt = sy-mandt.
gs_tc_material_wa-matnr = ''.
gs_tc_material_wa-maktx = ''.
gs_tc_material_wa-flag = ''.
APPEND gs_tc_material_wa TO gt_tc_material_itab.
REFRESH CONTROL 'tc_material' FROM SCREEN '9000'.
点击INSERT之前表格行不能输入
点击之后可输入
点击保存数据
CLEAR : gs_tc_material_wa.
LOOP AT gt_tc_material_itab INTO gs_tc_material_wa.
MODIFY ztv_xx_tst_ctrl
FROM gs_tc_material_wa.
ENDLOOP.
IF sy-subrc EQ 0.
MESSAGE s003(zvtst_screen).
ENDIF.
标签:gv,gs,鼠标,wa,SCREEN,material,插入,button,tc
From: https://blog.csdn.net/weixin_57651709/article/details/140457216