首页 > Linux操作系统 > Linux操作系统 > ALV 双击类事件 (2)
*&---------------------------------------------------------------------*
*& Form transfer_data_form
*&---------------------------------------------------------------------*
FORM. transfer_data_form. USING P_INDEX.
clear itab1.
refresh itab1.
read table itab index p_index.
itab1-werks = itab-werks.
itab1-matnr = itab-matnr.
itab1-maktx = itab-maktx.
append itab1.
clear itab1.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form initial_data_form
*&---------------------------------------------------------------------*
FORM. initial_data_form.
if alv_container1 is initial.
create object alv_container1 “创建Container(容器)
exporting
container_name = 'ALV1'.
create object alv_grid1 “创建ALV Grid
exporting
i_parent = alv_container1.
perform. fill_field_form.
call method alv_grid1->set_table_for_first_display
exporting
is_layout = alv_layout
i_save = 'A'
changing
it_outtab = itab[]
it_fieldcatalog = lt_fieldcat.
create object event_receiver.
set handler event_receiver->handle_double_click for alv_grid1.
endif.
ENDFORM.
*&-------------------------------------------------------*
*& Form fill_field_form
*&--------------------------------------------------------*
FORM. fill_field_form.
clear lt_fieldcat.
refresh lt_fieldcat.
perform. alv_form_filed using:
'1' 'WERKS' 'ITAB' 'Plant' '8',
'2' 'MATNR' 'ITAB' 'PartNo' '18',
'3' 'MAKTX' 'ITAB' 'Mat.desc' '40'.
ENDFORM.
*&----------------------------------------------------*
*& Form alv_form_filed
*&-----------------------------------------------------*
FORM. alv_form_filed USING col_pos
fieldname
tabname
desc
len.
ls_fieldcat-col_pos = col_pos.
ls_fieldcat-fieldname = fieldname.
ls_fieldcat-tabname = tabname.
ls_fieldcat-REPTEXT = desc.
ls_fieldcat-outputlen = len.
append ls_fieldcat to lt_fieldcat.
ENDFORM.
*&-------------------------------------------------------*
*& Form fill_field_form
*&--------------------------------------------------------*
FORM. fill_field_form1.
clear lt_fieldcat1.
refresh lt_fieldcat1.
perform. alv_form_filed1 using:
'1' 'WERKS' 'ITAB' 'Plant' '8',
'2' 'MATNR' 'ITAB' 'PartNo' '18',
'3' 'MAKTX' 'ITAB' 'Mat.desc' '40'.
ENDFORM.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/15117617/viewspace-617067/ ,如需转载,请注明出处,否则将追究法律责任。