1.背景
这个函数好象是去表中的字段,比如我下面这个表就是取的RKWA这个表的字段名,但这个表有20多个字段,但最后只取了18个,这个原因我后面再来探索.
2.代码
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = c_repid
i_internal_tabname = 'lt_RKWA'
i_structure_name = 'CONALV'
CHANGING
ct_fieldcat = t_fieldcat[].
3.以下是具体看应用的一个例子(以下是我加了两个描述)
FORM field_catalog_build TABLES
t_fieldcat TYPE slis_t_fieldcat_alv.
*-- Fieldcatalog create automatically --------------------------------*
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = c_repid
i_internal_tabname = 'LT_RKWA' " moidify it by jingguilin 2020/03/29(rkwa is replaced by lt_rkwa)
i_structure_name = 'CONALV'
CHANGING
ct_fieldcat = t_fieldcat[].
LOOP AT t_fieldcat.
CASE t_fieldcat-fieldname.
WHEN 'BSTME'.
t_fieldcat-seltext_l = text-116.
t_fieldcat-seltext_m = text-116.
t_fieldcat-seltext_s = text-116.
t_fieldcat-reptext_ddic = text-116.
WHEN 'BSTMG'.
t_fieldcat-seltext_l = text-115.
t_fieldcat-seltext_m = text-115.
t_fieldcat-seltext_s = text-115.
t_fieldcat-reptext_ddic = text-115.
WHEN 'BUKRS'. " Kopffeld andere Farbe
t_fieldcat-emphasize = 'X'.
WHEN 'LIFNR'. " Kopffeld andere Farbe
t_fieldcat-emphasize = 'X'.
WHEN 'TEXT'.
t_fieldcat-seltext_l = text-007. "Informationstext
t_fieldcat-seltext_m = text-008. "Infotext
t_fieldcat-seltext_s = text-008.
t_fieldcat-reptext_ddic = text-008.
WHEN 'WRBTR'.
t_fieldcat-seltext_l = text-117.
t_fieldcat-seltext_m = text-117.
t_fieldcat-seltext_s = text-117.
t_fieldcat-reptext_ddic = text-117.
WHEN 'BELNR'.
t_fieldcat-hotspot = 'X'.
WHEN 'MBLNR'.
t_fieldcat-hotspot = 'X'.
ENDCASE.
MODIFY t_fieldcat.
ENDLOOP.
t_fieldcat-fieldname = 'MAKTX'.
t_fieldcat-seltext_l = t_fieldcat-seltext_m = t_fieldcat-seltext_s = t_fieldcat-reptext_ddic = '物料描述' .
APPEND t_fieldcat.
t_fieldcat-fieldname = 'NAME1'.
t_fieldcat-seltext_l = t_fieldcat-seltext_m = t_fieldcat-seltext_s = t_fieldcat-reptext_ddic = '供应商描述' .
APPEND t_fieldcat.
CLEAR:t_fieldcat.