业务需求:在ME55增加客制化显示字段。
F1如下:
结构:MEREP_OUTTAB_EBANOV
1.MEREP_OUTTAB_EBAN 里 APPENDING字段也可,包含关系:
BADI->ES_BADI_ME_REPORTING
代码如下:
METHOD if_ex_me_change_outtab_cus~fill_outtab.
BREAK itl_abap04.
FIELD-SYMBOLS:
<fs_banfn> TYPE ebkn-banfn,
<fs_bnfpo> TYPE ebkn-bnfpo,
<fs_aufnr> TYPE afpo-aufnr,
<fs_matnr2> TYPE afpo-matnr,
<fs_maktx> TYPE makt-maktx.
IF sy-tcode EQ 'ME55' AND im_struct_name EQ 'MEREP_OUTTAB_EBANOV' .
LOOP AT ch_outtab ASSIGNING FIELD-SYMBOL(<fs_outtab>).
ASSIGN COMPONENT 'BANFN' OF STRUCTURE <fs_outtab> TO <fs_banfn>.
ASSIGN COMPONENT 'BNFPO' OF STRUCTURE <fs_outtab> TO <fs_bnfpo>.
ASSIGN COMPONENT 'ZZAUFNR' OF STRUCTURE <fs_outtab> TO <fs_aufnr>.
ASSIGN COMPONENT 'ZZMATNR' OF STRUCTURE <fs_outtab> TO <fs_matnr2>.
ASSIGN COMPONENT 'ZZMAKTX' OF STRUCTURE <fs_outtab> TO <fs_maktx>.
IF <fs_banfn> IS ASSIGNED
AND <fs_bnfpo> IS ASSIGNED
AND <fs_aufnr> IS ASSIGNED
AND <fs_matnr2> IS ASSIGNED
AND <fs_maktx> IS ASSIGNED.
SELECT SINGLE
ebkn~aufnr,
afpo~matnr,
makt~maktx
FROM ebkn
INNER JOIN afpo ON afpo~aufnr = ebkn~aufnr
LEFT JOIN makt ON makt~matnr = afpo~matnr AND makt~spras = '1'
WHERE ebkn~banfn = @<fs_banfn>
AND ebkn~bnfpo = @<fs_bnfpo>
INTO ( @<fs_aufnr>,@<fs_matnr2>,@<fs_maktx> ).
ENDIF.
UNASSIGN <fs_banfn>.
UNASSIGN <fs_bnfpo>.
UNASSIGN <fs_aufnr>.
UNASSIGN <fs_matnr2>.
UNASSIGN <fs_maktx>.
ENDLOOP.
ENDIF.
ENDMETHOD.
如果客制化字段长度较长,展示效果比较长,没有最优化列宽,隐士增强代码如下:
SE24:CL_ALV_CML_CONFIGURATION
方法:SET_DATA_TO_GRID
很多报表增加客制化字段都可用增强点:ES_BADI_ME_REPORTING 会同步发布文章,比较清晰,谢谢~~~