cl_gui_alv_grid 输出字段控制
一般:
有时候部分字段不需要输出
使用 LVC_FIELDCATALOG_MERGE 函数
DATA: gb_fieldcat TYPE lvc_t_fcat.
DATA ls_fldcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'Z_KEMU_INFOR'
CHANGING
ct_fieldcat = gb_fieldcat.
"得到 Z_KEMU_INFOR 结构字段
"控制具体输出
LOOP AT gb_fieldcat INTO ls_fldcat.
ls_fldcat-hotspot = 'X'.
"热键
CASE ls_fldcat-fieldname.
WHEN 'HKONT'.
"当字段是 HKONT时,输出11位
ls_fldcat-outputlen = 11.
WHEN 'TSLVT'.
ls_fldcat-outputlen = 20.
WHEN 'HKONT_DESC'.
ls_fldcat-outputlen = 50.
WHEN OTHERS.
"其他字段不输出
ls_fldcat-no_out = 'X'.
ENDCASE.
MODIFY gb_fieldcat FROM ls_fldcat.
ENDLOOP.
CALL METHOD alv_grid->set_table_for_first_display
CHANGING
it_outtab = l_data_show[]
it_fieldcatalog = gb_fieldcat[].
"控制具体输出
http://blog.sina.com.cn/sapliumeng