一、在MB52报表中新增字段
实现如图效果
二、增强实现
MB52程序为RM07MLBS,在程序中找到定义的内表结构bestand,在最后创建隐式增强,加入增强字段,该内表为将来展示的ALV数据
设置ALV列,在子例程最后创建隐式增强,加入列字段,在子例程fieldcatalog和f0300_fieldcat_flat中都添加
"-----------------------------------------@斌将军--------------------------------------------
"-----------------------------fieldcatalog-------------------------------
ENHANCEMENT 2 ZMB52. "active versionCLEAR 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
"-----------------------------------------@斌将军--------------------------------------------
"-----------------------------------------@斌将军--------------------------------------------
"-----------------------------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 versiondata:l_index type i.DATA:LT_CHAR TYPE TABLE OF BAPI1003_ALLOC_VALUES_CHAR WITH HEADER LINE.IF bestand[] IS NOT INITIAL.SELECTKUNNR,NAME1FROM KNA1INTO TABLE @DATA(LT_KNA1)FOR ALL ENTRIES IN @bestandWHERE KUNNR = @bestand-KUNNR.SELECTPRPS~PSPNR,PRPS~POST1,"WBS名称PRPS~PSPHI,"项目号PROJ~POST1 AS ZXMMC"项目名称FROM PRPSINNER JOIN PROJ ON PRPS~PSPHI = PROJ~PSPNRINTO TABLE @DATA(LT_PRPS)FOR ALL ENTRIES IN @bestandWHERE 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."-----------------------------------------@斌将军--------------------------------------------