1.1ALV屏幕
1.1.1定义无CONTAINER屏幕
1、屏幕中可以不使用定制控制控件画范围,直接定义一个屏幕即可
"-----------------------------------------@斌将军--------------------------------------------
g_grid_9000 TYPE REF TO cl_gui_alv_grid, "容器的实例
g_container_9000 TYPE REF TO cl_gui_docking_container, "容器 不用画屏幕容器
"-----------------------------------------@斌将军--------------------------------------------
2、创建容器
"-----------------------------------------@斌将军--------------------------------------------
CREATE OBJECT g_container_9000
EXPORTING
repid = sy-repid
dynnr = '9000'
* side = cl_gui_docking_container=>dock_at_right”ALV贴屏幕右边,从屏幕右边开始算宽度
side = cl_gui_docking_container=>dock_at_top"ALV贴屏幕左边,从左边算屏幕宽度,
extension = 1000 "屏幕宽度
* ratio = 95 "屏幕比例 小于5大于95会报cntl_error异常
style = cl_gui_control=>ws_child "可选参数,设置ALV是否可拖动大小
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
"-----------------------------------------@斌将军--------------------------------------------
3、创建容器实例
"-----------------------------------------@斌将军--------------------------------------------
* 创建容器实例
CREATE OBJECT g_grid_9000
EXPORTING
i_parent = g_container_9000
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"-----------------------------------------@斌将军--------------------------------------------
4、排序汇总
在业务中,需要根据提货单号,将相同提货单号的行的提货单数量汇总。
首先设置排序
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_alv_sort_9000.
CLEAR:gs_sort.
gs_sort-fieldname = 'THDXH'.
gs_sort-UP = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
设置汇总
"-----------------------------------------@斌将军--------------------------------------------
gs_fieldcat-do_sum = &3.
init_fill_fcat 'ZBCJHSL' '提货单数量' 'X' '' '' '' '' '' ''.
"-----------------------------------------@斌将军--------------------------------------------
5、事件注册
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_alv_event_9001.
DATA: lr_event_handler TYPE REF TO alv_event_9001.
DATA: lt_f4 TYPE lvc_t_f4,
ls_f4 TYPE lvc_s_f4.
CLEAR:ls_f4.
ls_f4-fieldname = 'Z_ZFBZ'."作废标记
ls_f4-register = 'X'.
ls_f4-chngeafter = 'X'.
INSERT ls_f4 INTO TABLE lt_f4.
CALL METHOD g_grid_9001->register_edit_event "注册回车事件
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD g_grid_9001->register_edit_event "注册失去鼠标事件
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD g_grid_9001->register_f4_for_fields "注册搜索帮助事件
EXPORTING
it_f4 = lt_f4.
IF lr_event_handler IS INITIAL.
CREATE OBJECT lr_event_handler.
ENDIF.
SET HANDLER lr_event_handler->handle_data_changed FOR g_grid_9001. "数据改动事件
SET HANDLER lr_event_handler->handle_double_click FOR g_grid_9001.
SET HANDLER lr_event_handler->handle_on_f4 FOR g_grid_9001.
SET HANDLER lr_event_handler->handle_hotspot_click FOR g_grid_9001 .
SET HANDLER lr_event_handler->handle_toolbar FOR g_grid_9001. "工具栏事件
SET HANDLER lr_event_handler->handle_user_command FOR g_grid_9001. "用户命令事件
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
6、展示ALV
"-----------------------------------------@斌将军--------------------------------------------
CALL METHOD g_grid_9000->set_table_for_first_display
EXPORTING
is_variant = gs_variant_9000
* i_save = 'A'
is_layout = gs_layout_9000
it_toolbar_excluding = gt_exclude_9000
CHANGING
it_outtab = gt_selalv "输出数据的内表
it_fieldcatalog = gt_fieldcat_9000 "
it_sort = gt_sort"排序
it_filter = gt_filt
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"-----------------------------------------@斌将军--------------------------------------------
7、屏幕刷新
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_refresh_alv_9000 .
DATA: lt_celltab TYPE lvc_t_styl,
ls_celltab TYPE lvc_s_styl,
ls_stable TYPE lvc_s_stbl.
ls_stable-row = 'X'. "固定行
ls_stable-col = 'X'. "固定列
CHECK g_grid_9000 IS NOT INITIAL.
CALL METHOD g_grid_9000->refresh_table_display
EXPORTING
is_stable = ls_stable
* I_SOFT_REFRESH = 'X'
EXCEPTIONS
finished = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
1.1.2定义有CONTAINER屏幕
1、首先在屏幕中使用空间画一个框
2、如果使用定制控制在控件中画范围,则需要使用另一个类。
"-----------------------------------------@斌将军--------------------------------------------
g_container_9000 TYPE REF TO cl_gui_custom_container"ALV container容器 需要画屏幕容器
"-----------------------------------------@斌将军--------------------------------------------
并且为屏幕中的控件定义名字,在程序中使用
"-----------------------------------------@斌将军--------------------------------------------
gv_9000 TYPE scrfname VALUE 'Z9000_ITEM', "GV_TABLE 是屏幕中定义的控件
"-----------------------------------------@斌将军--------------------------------------------
3、创建容器
"-----------------------------------------@斌将军--------------------------------------------
* 创建 容器
CREATE OBJECT g_container_9000
EXPORTING
container_name = gv_9000.
CREATE OBJECT g_grid_9000
EXPORTING
i_parent = g_container_9000.
"-----------------------------------------@斌将军--------------------------------------------
4、创建容器实例
"-----------------------------------------@斌将军--------------------------------------------
* 创建容器实例
CREATE OBJECT g_grid_9000
EXPORTING
i_parent = g_container_9000
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
"-----------------------------------------@斌将军--------------------------------------------
其他的部分都与无CONTAINER的创建方法一致。
1.2事件处理
1.2.1定义事件类
1、初始化事件类
"-----------------------------------------@斌将军--------------------------------------------
INITIALIZATION.
CLASS alv_event_9000 DEFINITION DEFERRED.
"-----------------------------------------@斌将军--------------------------------------------
2、定义事件类的方法
"-----------------------------------------@斌将军--------------------------------------------
CLASS alv_event_9000 DEFINITION.
PUBLIC SECTION.
METHODS handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid"数据改动事件
IMPORTING er_data_changed e_onf4 e_onf4_before e_onf4_after e_ucomm.
METHODS handle_double_click FOR EVENT double_click OF cl_gui_alv_grid"双击事件
IMPORTING e_row e_column es_row_no.
METHODS handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid"F4
IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data et_bad_cells e_display.
METHODS handle_user_command FOR EVENT user_command OF cl_gui_alv_grid"用户按钮事件
IMPORTING e_ucomm.
METHODS handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid"热区单击事件
IMPORTING e_row_id e_column_id es_row_no.
METHODS handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid"工具条事件
IMPORTING e_object e_interactive.
ENDCLASS.
"-----------------------------------------@斌将军--------------------------------------------
3、实现类的方法
"-----------------------------------------@斌将军--------------------------------------------
CLASS alv_event_9000 IMPLEMENTATION.
METHOD handle_data_changed. "数据改动事件
PERFORM frm_handle_data_changed USING er_data_changed.
ENDMETHOD.
METHOD handle_double_click . "双击事件
PERFORM frm_double_click USING e_row e_column es_row_no.
ENDMETHOD. "HANDLE_USER_COMMAND
METHOD handle_on_f4 . "F4
PERFORM frm_alv_on_f4 USING e_fieldname e_fieldvalue es_row_no er_event_data e_display.
er_event_data->m_event_handled = 'X' .
ENDMETHOD.
METHOD handle_user_command. "用户按钮事件
PERFORM frm_handle_user_command9000 USING e_ucomm.
ENDMETHOD.
METHOD handle_hotspot_click. "热区单击事件
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no.
ENDMETHOD. "handle_hotspot_click
METHOD handle_toolbar. "工具条事件
PERFORM frm_handle_toolbar9000 USING e_object e_interactive."设置工具条图标
ENDMETHOD. "HANDLE_DOUBLE_CLICK
ENDCLASS.
"-----------------------------------------@斌将军--------------------------------------------
1.2.2搜索帮助事件
1、定义响应F4的字段
"-----------------------------------------@斌将军--------------------------------------------
DATA: lr_event_handler TYPE REF TO alv_event_9001.
DATA: lt_f4 TYPE lvc_t_f4,
ls_f4 TYPE lvc_s_f4.
CLEAR:ls_f4.
ls_f4-fieldname = 'Z_ZFBZ'."作废标记
ls_f4-register = 'X'.
ls_f4-chngeafter = 'X'.
INSERT ls_f4 INTO TABLE lt_f4.
"-----------------------------------------@斌将军--------------------------------------------
2、将F4内表注册到搜索帮助
"-----------------------------------------@斌将军--------------------------------------------
CALL METHOD g_grid_9001->register_f4_for_fields "注册搜索帮助事件
EXPORTING
it_f4 = lt_f4.
"-----------------------------------------@斌将军--------------------------------------------
3、将搜索帮助注册到屏幕
"-----------------------------------------@斌将军--------------------------------------------
IF lr_event_handler IS INITIAL.
CREATE OBJECT lr_event_handler.
ENDIF.
SET HANDLER lr_event_handler->handle_on_f4 FOR g_grid_9001.
"-----------------------------------------@斌将军--------------------------------------------
4、定义字段为F4属性
"-----------------------------------------@斌将军--------------------------------------------
gs_fieldcat-f4availabl = &5.
init_fill_fcat 'Z_ZFBZ' '作废标记' '' '' 'X' '' 'X' '' ''.
"-----------------------------------------@斌将军--------------------------------------------
5、定义F4响应逻辑
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_alv_on_f4 USING pv_fieldname pv_fieldvalue pv_row_no TYPE lvc_s_roid
pv_event_data TYPE REF TO cl_alv_event_data
pv_display.
DATA:lv_fieldname1 TYPE dfies-fieldname,
lv_fieldname2 TYPE help_info-dynprofld.
DATA:rs_selfield TYPE slis_selfield.
DATA:ref_grid TYPE REF TO cl_gui_alv_grid.
DATA:lt_return TYPE STANDARD TABLE OF ddshretval,
ls_return TYPE ddshretval.
DATA:BEGIN OF lt_zf OCCURS 0,
z_zfbz TYPE ztthdvk-z_zfbz, "作废标志
END OF lt_zf.
DATA:ls_zf LIKE lt_zf.
REFRESH:lt_zf.
CLEAR:ls_zf.
ls_zf-z_zfbz = 'X'.
APPEND ls_zf TO lt_zf. "作废标记不可逆,一旦打上X,则不可能再更改过来
lv_fieldname1 = pv_fieldname ."搜索帮助的字段名
lv_fieldname2 = pv_fieldname ."搜索帮助的字段名
CONDENSE lv_fieldname1 NO-GAPS.
CONDENSE lv_fieldname2 NO-GAPS.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid. "获取全局变量
* PERFORM frm_refresh_alv.
REFRESH:lt_return.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = lv_fieldname1
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = lv_fieldname2
value_org = 'S'
display = 'F'
TABLES
value_tab = lt_zf
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
CLEAR:gs_head.
READ TABLE gt_head INTO gs_head INDEX pv_row_no-row_id.
IF sy-subrc = 0.
READ TABLE lt_return INTO ls_return INDEX 1.
IF sy-subrc = 0.
gs_head-z_zfbz = ls_return-fieldval.
ENDIF.
MODIFY gt_head FROM gs_head INDEX pv_row_no-row_id."更新ALV内表
ENDIF.
PERFORM frm_refresh_alv_9001.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
6、当出现多列的搜索帮助时,需要在点击某一行时,返回多列的值。例如点击承运商搜索帮助,点击承运商后,也需要返回承运商代码,则需要特殊处理。
搜索帮助内表需要定义为两列
"-----------------------------------------@斌将军--------------------------------------------
TYPES:BEGIN OF ty_cys,
zcysdm TYPE ztthdvk-zcysdm, "承运商编码
zcys TYPE ztthdvk-zcys, "承运商名称
END OF ty_cys.
ls_cys-zcysdm = gs_zttlifnrc-lifnr.
ls_cys-zcys = gs_zttlifnrc-ztext.
APPEND ls_cys TO lt_cys.
CLEAR:ls_cys.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = pv_fieldname1
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = pv_fieldname2
value_org = 'S'
display = 'F'
* 可以返回两个返回值-begin
callback_program = sy-repid
callback_form = 'USER_F4_FORM'
* --end
TABLES
value_tab = lt_cys
return_tab = pt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
*---------------------------------------------------------------------*
* F4搜索帮助的回调函数,除了F4IF_INT_TABLE_VALUE_REQUEST
* 中定义的字段,还可以返回其他列的字段值
*----------------------------------------------------------------------*
FORM user_f4_form TABLES record_tab STRUCTURE seahlpres CHANGING shlp TYPE shlp_descr_t callcontrol LIKE ddshf4ctrl .
DATA: interface LIKE LINE OF shlp-interface.
READ TABLE shlp-interface INTO interface INDEX 1.
CLEAR interface.
interface-shlpfield = 'F0001'. "调试可知,承运商代码列名为F0001
interface-valfield = 'ZCYSDM'. "字段名称
APPEND interface TO shlp-interface.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
1.2.3数据改变事件
1、回车事件和失去鼠标焦点事件都称为数据改变事件
"-----------------------------------------@斌将军--------------------------------------------
CALL METHOD g_grid_9000->register_edit_event "注册回车事件
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD g_grid_9000->register_edit_event "注册失去鼠标事件
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
SET HANDLER lr_event_handler->handle_data_changed FOR g_grid_9000. "数据改动事件
"-----------------------------------------@斌将军--------------------------------------------
2、数据改变事件处理
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_handle_data_changed USING pv_data_changed TYPE REF TO cl_alv_changed_data_protocol.
DATA:lt_data TYPE lvc_t_modi,
ls_data LIKE LINE OF lt_data.
DATA:lv_zbcjhsl TYPE ztthdvb-zbcjhsl, "本次交货数量
lv_jiansh TYPE ztthdvb-jiansh, "件数
lv_value TYPE char100.
CLEAR:gv_stop."流程控制标识
lt_data = pv_data_changed->mt_mod_cells.
LOOP AT lt_data INTO ls_data.
IF ls_data-fieldname = 'ZBCJHSL'.
CLEAR:lv_zbcjhsl.
CALL METHOD pv_data_changed->get_cell_value "获取单元格中的值
EXPORTING
i_row_id = ls_data-row_id "行号
i_fieldname = 'ZBCJHSL' "要获取的列的列名
IMPORTING
e_value = lv_zbcjhsl. "获取到的单元格中的值
...处理逻辑
ENDIF.
ENDLOOP.
PERFORM frm_refresh_alv_9001.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
3、关于数据改变的验证
业务中需要对数据改变之后的有效性做校验,判断改变后的数据是否符合业务要求,在合适位置加上校验逻辑即可,报响应的消息。
"-----------------------------------------@斌将军--------------------------------------------
IF lv_zbcjhsl <= 0.
gv_stop = 'X'."当需要中断程序时打上标识
REFRESH:pv_data_changed->mt_mod_cells."清掉编辑框中的数据,恢复至内表中的正确数据 此处如果不清理,展示的字段内容仍然是编辑后的错误数据
MESSAGE s024(zsd) WITH ls_data-row_id DISPLAY LIKE 'E'.
PERFORM frm_refresh_alv_9000.
RETURN.
ENDIF.
"-----------------------------------------@斌将军--------------------------------------------
后来发现,因为消息并不是E类型,直接终止程序。所以,如果对于数据改变之后,一不敲回车,二直接点击创建等操作按钮后,虽然也会报消息,但是RETURN只是推出了数据改变事件这一流程块,但是仍然进入创建按钮的逻辑。因此,我们可以在报错时,加入流程控制标识:gv_stop = 'X'."当需要中断程序时打上标识,这样在执行创建逻辑时加入判断:CHECK gv_stop <> 'X'."流程控制,判断事件处理是否有误,并在执行完之后清除流程控制符。
3.2.4工具条事件
1、因OOALV定义的状态栏的标准按钮时无法使用的,所以应使用OOALV屏幕中自带的工具栏,定义的GUI状态栏只负责定义返回按钮即可。
2、自定义的工具栏按钮,可以添加到OOALV屏幕自带的工具栏
3、当自定义的GUI状态栏只有返回按钮没有应用程序工具栏按钮时,会在标准的屏幕工具栏上边出现一条空白,影响美观,我们可以在屏幕中做设置。
这样就可以只使用GUI状态栏的返回退出按钮,而不必出现空白。
4、定义屏幕工具栏的自定义按钮
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_handle_toolbar9000 USING p_object p_interactive.
PERFORM frm_handle_toolbar_pro USING p_object 'CREATE_THD' '@5Y@' '生成提货单'.
ENDFORM.
FORM frm_handle_toolbar_pro USING p_object TYPE REF TO cl_alv_event_toolbar_set
p_function TYPE stb_button-FUNCTION
p_icon TYPE stb_button-ICON
p_text TYPE stb_button-TEXT.
DATA: ls_toolbar TYPE stb_button,
lv_quickinfo TYPE stb_button-quickinfo.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type. " 分隔符
APPEND ls_toolbar TO p_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type. " 按钮(正常)
MOVE p_function TO ls_toolbar-FUNCTION. "功能码
MOVE p_icon TO ls_toolbar-ICON. "图标
MOVE p_text TO ls_toolbar-TEXT. "显示文本
lv_quickinfo = p_text.
MOVE lv_quickinfo TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO p_object->mt_toolbar.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
5、自定义的屏幕工具栏按钮响应
6、GUI状态的按钮响应,需要在屏幕的PAI中定义
1.3细节处理
1.3.1选择屏幕设置
当选择屏幕需要切换时,如果输入框有必输字段则需要输入值才能切换到另一个界面
一般的处理方法是,去掉必输标识,用程序控制是否必输,报消息提醒,但是这种方法毕竟没法给用户直观的必输体验,因此可以采用下面的方法:
销售组织不设置必输
此处只打上勾,但是却不自动校验是否输值,只是一个外观效果
"-----------------------------------------@斌将军--------------------------------------------
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'S_VKORG-LOW'.
screen-required = '2'."外观上打钩必输,但不自动校验
ENDIF.
MODIFY SCREEN.
ENDLOOP.
"-----------------------------------------@斌将军--------------------------------------------
"-----------------------------------------@斌将军--------------------------------------------
FORM frm_check_srceen.
IF s_vkorg-low IS INITIAL.
MESSAGE e016(zsd).
ENDIF.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
1.3.2选择框
在OOALV中,定义侧边栏BOX选择框是不起作用的,但是勾选的选择框对于大量的数据实在比较不方便,因此我们需要使用侧边栏BOX,并做特殊处理。
在调用创建等操作按钮之前,使用get_selected_rows获取选中的行,先将上一次选中的行的BOX标记去掉,之后将选中行的BOX字段打上标记。
"-----------------------------------------@斌将军--------------------------------------------
CALL METHOD g_grid_9000->get_selected_rows
IMPORTING
et_index_rows = lt_row
et_row_no = lt_roid.
* 因为OOALV中侧边栏选择框不起作用,但是需要使用,就将选中的行的侧边栏的值修改一下
gs_item-box = ''.
MODIFY gt_item FROM gs_item TRANSPORTING box WHERE box = 'X'.
LOOP AT lt_row INTO ls_row.
READ TABLE gt_item INTO gs_item INDEX ls_row-INDEX.
IF sy-subrc EQ 0.
gs_item-box = 'X'.
MODIFY gt_item FROM gs_item INDEX ls_row-INDEX TRANSPORTING box .
ENDIF.
CLEAR:ls_row,gs_item.
ENDLOOP.
"-----------------------------------------@斌将军--------------------------------------------
1.3.3动态列
在OOALV中需要实现不同条件下,显示不同列。
1、DATA: G_GRID TYPE REF TO CL_GUI_ALV_GRID.
使用G_GRID->GET_FRONTEND_FIELDCATALOG ,获取当前的列信息,之后修改为需要显示的列,或者直接清空,用PERFORM INIT_FIELDCAT1.重新赋值。之后使用G_GRID->SET_FRONTEND_FIELDCATALOG,传入新赋值的列内表即可。
1.3.4获取双击单元格的值
"-----------------------------------------@斌将军--------------------------------------------
*&---------------------------------------------------------------------*
*& Form FRM_DOUBLE_CLICK
*&---------------------------------------------------------------------*
FORM frm_double_click_9001 USING p_e_row_id TYPE lvc_s_row
p_e_column_id TYPE lvc_s_col
p_es_row_no TYPE lvc_s_roid.
"获取当前单元格的内容
DATA:e_value TYPE char255.
CALL METHOD g_grid_9001->get_current_cell
IMPORTING
e_value = e_value.
CASE p_e_column_id-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD e_value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
WHEN 'PLNUM'."计划订单
SET PARAMETER ID 'PAF' FIELD e_value.
CALL TRANSACTION 'MD13' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM.
"-----------------------------------------@斌将军--------------------------------------------
1.3.5没有保存布局按钮
OOALV中只有更改布局按钮,没有保存布局按钮
插入代码
"-----------------------------------------@斌将军--------------------------------------------
gs_variant_9000-report = sy-repid && sy-dynnr.
"-----------------------------------------@斌将军--------------------------------------------
其中I_SAVE参数传值注解:
I_SAVE = ''. 不能保存布局
I_SAVE = 'U'. 仅保存自定义的布局
I_SAVE = 'X'. 仅保存全局布局
I_SAVE = 'A'. 可保存自定义的布局和全局的布局
出现了保存布局按钮