新手提问:如何在ALV里限制显示出部分字段目录
--------------------编程问答-------------------- TABLES里面还有一个属性值,是传表头的内表,将你要显示的几个表头加到表头列表中就好了 --------------------编程问答-------------------- form frm_alv_output .data:
l_repid like sy-repid,
ls_fieldcat type slis_fieldcat_alv,
ls_layout type slis_layout_alv,
ls_variant type disvariant,
lt_fieldcat type slis_t_fieldcat_alv.
l_repid = sy-repid.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = l_repid
i_internal_tabname = 'IT_OUTPUT'
i_inclname = l_repid
changing
ct_fieldcat = lt_fieldcat.
loop at lt_fieldcat into ls_fieldcat.
case ls_fieldcat-fieldname.
when 'WGBEZ'.
ls_fieldcat-seltext_l = '车型'(o01).
ls_fieldcat-seltext_m = '车型'(o01).
ls_fieldcat-seltext_s = '车型'(o01).
ls_fieldcat-reptext_ddic = '车型'(o01).
ls_fieldcat-key = space.
when 'NAME1'.
ls_fieldcat-seltext_l = '客户描述'(o05).
ls_fieldcat-seltext_m = '客户描述'(o05).
ls_fieldcat-seltext_s = '客户描述'(o05).
ls_fieldcat-reptext_ddic = '客户描述'(o05).
ls_fieldcat-key = space.
when 'PRICE'.
ls_fieldcat-seltext_l = '单价'(o02).
ls_fieldcat-seltext_m = '单价'(o02).
ls_fieldcat-seltext_s = '单价'(o02).
ls_fieldcat-reptext_ddic = '单价'(o02).
ls_fieldcat-key = space.
when 'ZTNUM'.
ls_fieldcat-seltext_l = '金穗发票号码'(o03).
ls_fieldcat-seltext_m = '金穗发票号码'(o03).
ls_fieldcat-seltext_s = '金穗发票号码'(o03).
ls_fieldcat-reptext_ddic = '金穗发票号码'(o03).
ls_fieldcat-key = space.
when 'ZCOMM'.
ls_fieldcat-seltext_l = '金穗发票备注'(o04).
ls_fieldcat-seltext_m = '金穗发票备注'(o04).
ls_fieldcat-seltext_s = '金穗发票备注'(o04).
ls_fieldcat-reptext_ddic = '金穗发票备注'(o04).
ls_fieldcat-key = space.
endcase.
modify lt_fieldcat from ls_fieldcat index sy-tabix
transporting seltext_l seltext_m seltext_s
reptext_ddic key.
endloop.
ls_variant-report = sy-repid.
ls_variant-username = sy-uname.
ls_variant-handle = '1'.
call function 'REUSE_ALV_GRID_DISPLAY' "#EC *
exporting
i_save = 'A'
is_variant = ls_variant
is_layout = ls_layout
it_fieldcat = lt_fieldcat
tables
t_outtab = it_output
exceptions
program_error = 1
others = 2.
endform. " frm_alv_output --------------------编程问答-------------------- 要显示字段的FIELDCAT 里面有个no_out属性,你要显示前5个字段,就把前5个字段的这个属性置为空,后面5个字段的这个属性置为'X',这样肯定能实现你的要求 --------------------编程问答-------------------- 楼上的方法最简单。
补充:企业软件 , ERP/CRM