ABAP ALV LVC_T_SORT 合并单元格问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ABAP ALV LVC_T_SORT 合并单元格问题相关的知识,希望对你有一定的参考价值。
我用类做ALV,不知道怎么回事排序了就是相同的内容合并不了。
DATA pt_sort1 TYPE LVC_T_SORT.
PERFORM prepare_sort_table CHANGING pt_sort1 .
FORM prepare_sort_table CHANGING pt_sort TYPE lvc_t_sort .
DATA ls_sort TYPE lvc_s_sort .
ls_sort-spos = '01' .
ls_sort-fieldname = 'MATNR' .
ls_sort-up = 'X' . "A to Z
ls_sort-down = space .
APPEND ls_sort TO pt_sort .
ENDFORM. " prepare_sort_table
CALL METHOD WCL_ALV->set_table_for_first_display
EXPORTING
I_SAVE = 'A'
is_layout = gs_layout
IT_TOOLBAR_EXCLUDING = UI_FUNCTIONS1
CHANGING
it_outtab = ITAB[]
it_fieldcatalog = gt_fieldcat
IT_SORT = pt_sort1[]
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
有谁知道是什么原因吗?
我运行后显示出来,那个字段列名的旁边是有排序的那个符号了,可就是相同内容没有合并
如果是的话:
你的代码仅仅是对MATNR做了排序动作,ALV显示结果肯定不会自动合并;
除非还有一列是要汇总一下,也就是按照MATNR分类汇总另外一个字段后,才能出现合并的效果; 参考技术A 你这只有排序没有合并啊? 参考技术B 这个可能跟layout有关,你把layout注释了试试本回答被提问者采纳
ABAP ALV单个单元格状态编辑-简单版本
*&---------------------------------------------------------------------*
*& Report ZPPR0024
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zppr0024.
TYPE-POOLS: slis.
*- Fieldcatalog
DATA: it_fieldcat TYPE lvc_t_fcat.
DATA: x_fieldcat TYPE lvc_s_fcat.
DATA: x_layout TYPE lvc_s_layo.
"第1步:用操作具体单元的是否可编辑的内表和工作区
DATA: ls_edit TYPE lvc_s_styl,
lt_edit TYPE lvc_t_styl,
gr_alvgrid TYPE REF TO cl_gui_alv_grid .
"第2步:在内表定义添加字段,用于控制具体行的具体单元是否可编辑
DATA: BEGIN OF it_vbap OCCURS 0,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
style TYPE lvc_t_styl, "FOR DISABLE
END OF it_vbap.
DATA: ls_outtab LIKE LINE OF it_vbap.
SELECT vbeln posnr
UP TO 100 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_vbap
FROM vbap.
DATA:l_pos TYPE i VALUE 1.
CLEAR: l_pos.
l_pos = l_pos + 1.
x_fieldcat-seltext = ‘VBELN‘.
x_fieldcat-fieldname = ‘VBELN‘.
x_fieldcat-tabname = ‘ITAB‘.
x_fieldcat-col_pos = l_pos.
x_fieldcat-edit = ‘X‘.
x_fieldcat-outputlen = ‘10‘.
x_fieldcat-ref_field = ‘VBELN‘.
x_fieldcat-ref_table = ‘VBAK‘.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
x_fieldcat-seltext = ‘POSNR‘.
x_fieldcat-fieldname = ‘POSNR‘.
x_fieldcat-tabname = ‘ITAB‘.
x_fieldcat-col_pos = l_pos.
x_fieldcat-edit = ‘X‘.
x_fieldcat-outputlen = ‘5‘.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
l_pos = l_pos + 1.
********************************************************
PERFORM set_status USING 6 ‘VBELN‘.
PERFORM set_status USING 6 ‘POSNR‘.
INSERT LINES OF lt_edit INTO TABLE ls_outtab-style.
MODIFY it_vbap INDEX 6 FROM ls_outtab TRANSPORTING style .
********************************************************
x_layout-stylefname = ‘STYLE‘.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC‘
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = x_layout
it_fieldcat_lvc = it_fieldcat
TABLES
t_outtab = it_vbap[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
FORM SET_STATUS_DISABLED USING index TYPE sy-tabix fieldname TYPE lvc_s_styl-fieldname .
sy-tabix = index.
ls_edit-fieldname = fieldname.
ls_edit-style = cl_gui_alv_grid=>mc_style_disabled.
ls_edit-style2 = space.
ls_edit-style3 = space.