ABAP ME28 ME2M 增加展示字段增强

4 篇文章 0 订阅


前言

业务需求:在ME2M、ME28增加客制化显示字段。


一、获取展示显示结构

F1如下:

结构:MEREP_OUTTAB_PURCHDOC

二、显示结构新增客制化字段

APPENDING字段

三、增强点:

BADI->ES_BADI_ME_REPORTING

代码如下: 

上图物料编码为:EMATN 

METHOD if_ex_me_change_outtab_cus~fill_outtab.

  BREAK itl_abap04.
  FIELD-SYMBOLS:
    <fs_matnr> TYPE mara-matnr,
    <fs_zclph> TYPE mara-zclph,
    <fs_zthgg> TYPE mara-zthgg.
  FIELD-SYMBOLS:
    <fs_ebeln>  TYPE ekkn-ebeln,
    <fs_ebelp>  TYPE ekkn-ebelp,
    <fs_aufnr>  TYPE afpo-aufnr,
    <fs_matnr2> TYPE afpo-matnr,
    <fs_maktx>  TYPE makt-maktx.

  IF ( sy-tcode EQ 'ME2M' AND im_struct_name EQ 'MEREP_OUTTAB_PURCHDOC' )
     OR ( sy-tcode EQ 'ME28' AND im_struct_name EQ 'MEREP_OUTTAB_PURCHDOC_REL' ).

    LOOP AT ch_outtab ASSIGNING <fs_outtab>.

      ASSIGN COMPONENT 'EMATN'  OF STRUCTURE <fs_outtab> TO <fs_matnr>.
      ASSIGN COMPONENT 'ZZCLPH' OF STRUCTURE <fs_outtab> TO <fs_zclph>.
      ASSIGN COMPONENT 'ZZTHGG' OF STRUCTURE <fs_outtab> TO <fs_zthgg>.
      IF <fs_matnr> IS ASSIGNED
        AND <fs_zclph> IS ASSIGNED
        AND <fs_zthgg> IS ASSIGNED.
        SELECT SINGLE zclph,zthgg FROM mara WHERE matnr = @<fs_matnr> INTO ( @<fs_zclph>,@<fs_zthgg> ).
      ENDIF.
      UNASSIGN <fs_matnr>.
      UNASSIGN <fs_zclph>.
      UNASSIGN <fs_zthgg>.
      ASSIGN COMPONENT 'EBELN'   OF STRUCTURE <fs_outtab> TO <fs_ebeln>.
      ASSIGN COMPONENT 'EBELP'   OF STRUCTURE <fs_outtab> TO <fs_ebelp>.
      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_ebeln> IS ASSIGNED
        AND <fs_ebelp>  IS ASSIGNED
        AND <fs_aufnr>  IS ASSIGNED
        AND <fs_matnr2> IS ASSIGNED
        AND <fs_maktx>  IS ASSIGNED.
        SELECT SINGLE
          ekkn~aufnr,
          afpo~matnr,
          makt~maktx
          FROM ekkn
          INNER JOIN afpo ON afpo~aufnr = ekkn~aufnr
          LEFT  JOIN makt ON makt~matnr = afpo~matnr AND makt~spras = '1'
          WHERE ekkn~ebeln = @<fs_ebeln>
            AND ekkn~ebelp = @<fs_ebelp>
          INTO ( @<fs_aufnr>,@<fs_matnr2>,@<fs_maktx> ).
      ENDIF.
      UNASSIGN <fs_ebeln>.
      UNASSIGN <fs_ebelp>.
      UNASSIGN <fs_aufnr>.
      UNASSIGN <fs_matnr2>.
      UNASSIGN <fs_maktx>.
    ENDLOOP.

  ENDIF.

ENDMETHOD.

四、效果如下

ME2M

 ME28

五、LAYOUT

如果客制化字段长度较长,展示效果比较长,没有最优化列宽,隐士增强代码如下:

SE24:CL_ALV_CML_CONFIGURATION

方法:SET_DATA_TO_GRID


总结

很多报表增加客制化字段都可用增强点:ES_BADI_ME_REPORTING 会同步发布文章,比较清晰,谢谢~~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值