MB52增强

一、在MB52报表中新增字段

实现如图效果

二、增强实现

MB52程序为RM07MLBS,在程序中找到定义的内表结构bestand,在最后创建隐式增强,加入增强字段,该内表为将来展示的ALV数据

设置ALV列,在子例程最后创建隐式增强,加入列字段,在子例程fieldcatalog和f0300_fieldcat_flat中都添加

form fieldcatalog.

"-----------------------------------------@斌将军--------------------------------------------
"
-----------------------------fieldcatalog------------------------------- ENHANCEMENT 2 ZMB52. "active version CLEAR fieldcat. fieldcat-fieldname = 'ZKHMC'. fieldcat-seltext_l = fieldcat-seltext_s = fieldcat-seltext_m = '客户名称'. APPEND fieldcat. CLEAR fieldcat. fieldcat-fieldname = 'POST1'. fieldcat-seltext_l = fieldcat-seltext_s = fieldcat-seltext_m = 'WBS名称'. APPEND fieldcat. CLEAR fieldcat. fieldcat-fieldname = 'PSPHI'. fieldcat-seltext_l = fieldcat-seltext_s = fieldcat-seltext_m = '项目号'. APPEND fieldcat. CLEAR fieldcat. fieldcat-fieldname = 'ZXMMC'. fieldcat-seltext_l = fieldcat-seltext_s = fieldcat-seltext_m = '项目名称'. APPEND fieldcat. ENDENHANCEMENT.

*$*$-End:   (2)---------------------------------------------------------------------------------$*$*
ENDFORM.                               " FELDKATALOG_AUFBAUEN
"-----------------------------------------@斌将军--------------------------------------------

form f0300_fieldcat_flat.

"-----------------------------------------@斌将军--------------------------------------------
"-----------------------------f0300_fieldcat_flat-----------------------
        fieldcat-seltext_l     = '客户名称'.
        macro_fill_fieldcat 'ZKHMC'  ''   c_out.
        fieldcat-seltext_l     = 'WBS名称'.
        macro_fill_fieldcat 'POST1'  ''   c_out.
        fieldcat-seltext_l     = '项目号'.
        macro_fill_fieldcat 'PSPHI'  ''   c_out.
        fieldcat-seltext_l     = '项目名称'.
        macro_fill_fieldcat 'ZXMMC'  ''   c_out.
ENDENHANCEMENT.
*$*$-End:   (4)---------------------------------------------------------------------------------$*$*
ENDFORM.                     "f0300_fieldcat_flat
"-----------------------------------------@斌将军--------------------------------------------

 

获取数据,在子例程list_output中加入隐式增强,查询字段的数据

"-----------------------------------------@斌将军--------------------------------------------
FORM
list_output. """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(3) Form LIST_OUTPUT, Anfang A *$*$-Start: (3)---------------------------------------------------------------------------------$*$* ENHANCEMENT 3 ZMB52. "active version data:l_index type i. DATA:LT_CHAR TYPE TABLE OF BAPI1003_ALLOC_VALUES_CHAR WITH HEADER LINE. IF bestand[] IS NOT INITIAL. SELECT KUNNR, NAME1 FROM KNA1 INTO TABLE @DATA(LT_KNA1) FOR ALL ENTRIES IN @bestand WHERE KUNNR = @bestand-KUNNR. SELECT PRPS~PSPNR, PRPS~POST1,"WBS名称 PRPS~PSPHI,"项目号 PROJ~POST1 AS ZXMMC"项目名称 FROM PRPS INNER JOIN PROJ ON PRPS~PSPHI = PROJ~PSPNR INTO TABLE @DATA(LT_PRPS) FOR ALL ENTRIES IN @bestand WHERE PRPS~PSPNR = @bestand-PSPNR. ENDIF. LOOP AT bestand . l_index = sy-tabix. "客户名称 READ TABLE lt_kna1 INTO DATA(ls_kna1) WITH KEY kunnr = bestand-kunnr. IF sy-subrc EQ 0. bestand-zkhmc = ls_kna1-name1. ENDIF. READ TABLE LT_PRPS INTO DATA(LS_PRPS) WITH KEY PSPNR = bestand-PSPNR. IF SY-SUBRC EQ 0. bestand-POST1 = LS_PRPS-POST1. bestand-PSPHI = LS_PRPS-PSPHI. bestand-ZXMMC = LS_PRPS-ZXMMC. ENDIF. MODIFY bestand INDEX l_index. ENDLOOP.

ENDENHANCEMENT.
*$*$-End: (3)---------------------------------------------------------------------------------$*$*


* set pf-status 'STANDARD'.


ENHANCEMENT-SECTION rm07mlbs_09 SPOTS es_rm07mlbs.

"-----------------------------------------@斌将军--------------------------------------------

 

定期更文,欢迎关注

 
 
 
posted @ 2021-10-25 16:29  斌将军  阅读(854)  评论(0编辑  收藏  举报