功能需求是:
在系统标准功能MB51物料凭证查询的基础上增强四个字段
1、供应商描述:根据表MSEG中的供应商LIFNR去GOHEAD-VENDORNAME中取值
2、物料组:根据MSEG中的物料编码MATNR去表MARA中取MATKL
3、物料组描述:根据物料组MARA-MATKL去取T023T-WGBEZ
4、成本中心描述:根据MSEG-KOSTL去取CSKT-LTEXT
增强的四个字段放在“更改格式”里,需要时取出即可
首先进入MB51的标准程序,点击增强按钮,然后点击菜单里面的增强选择把程序的所有隐式增强显示出来,
而后在下面几个地方增加如下代码:
1.在INCLUDE RM07DOCS_GENERATED里面的内表定义ITAB增强需要的这几个字段
DATA: BEGIN OF ITAB OCCURS 0. DATA: ANLN1 TYPE MSEG-ANLN1 . DATA: ANLN2 TYPE MSEG-ANLN2 . DATA: APLZL TYPE MSEG-APLZL . DATA: AUFNR TYPE MSEG-AUFNR . DATA: AUFPL TYPE MSEG-AUFPL . DATA: BKTXT TYPE MKPF-BKTXT . DATA: BLDAT TYPE MKPF-BLDAT . DATA: BPMNG TYPE MSEG-BPMNG . DATA: BPRME TYPE MSEG-BPRME . DATA: BSTME TYPE MSEG-BSTME . DATA: BSTMG TYPE MSEG-BSTMG . DATA: BUDAT TYPE MKPF-BUDAT . DATA: BUKRS TYPE MSEG-BUKRS . DATA: BWART TYPE MSEG-BWART . DATA: BWTAR TYPE MSEG-BWTAR . DATA: CHARG TYPE MSEG-CHARG . DATA: CPUDT TYPE MKPF-CPUDT . DATA: CPUTM TYPE MKPF-CPUTM . DATA: DMBTR TYPE MSEG-DMBTR . DATA: EBELN TYPE MSEG-EBELN . DATA: EBELP TYPE MSEG-EBELP . DATA: ERFME TYPE MSEG-ERFME . DATA: ERFMG TYPE MSEG-ERFMG . DATA: EXBWR TYPE MSEG-EXBWR . DATA: EXVKW TYPE MSEG-EXVKW . DATA: GRUND TYPE MSEG-GRUND . DATA: KDAUF TYPE MSEG-KDAUF . DATA: KDEIN TYPE MSEG-KDEIN . DATA: KDPOS TYPE MSEG-KDPOS . DATA: KOSTL TYPE MSEG-KOSTL . DATA: KUNNR TYPE MSEG-KUNNR . DATA: KZBEW TYPE MSEG-KZBEW . DATA: KZVBR TYPE MSEG-KZVBR . DATA: KZZUG TYPE MSEG-KZZUG . DATA: LGORT TYPE MSEG-LGORT . DATA: LIFNR TYPE MSEG-LIFNR . DATA: MATNR TYPE MSEG-MATNR . DATA: MAT_KDAUF TYPE MSEG-MAT_KDAUF . DATA: MAT_KDPOS TYPE MSEG-MAT_KDPOS . DATA: MBLNR TYPE MKPF-MBLNR . DATA: MEINS TYPE MSEG-MEINS . DATA: MENGE TYPE MSEG-MENGE . DATA: MJAHR TYPE MKPF-MJAHR . DATA: NPLNR TYPE MSEG-NPLNR . DATA: PS_PSP_PNR TYPE MSEG-PS_PSP_PNR . DATA: RSNUM TYPE MSEG-RSNUM . DATA: RSPOS TYPE MSEG-RSPOS . DATA: SHKZG TYPE MSEG-SHKZG . DATA: SOBKZ TYPE MSEG-SOBKZ . DATA: USNAM TYPE MKPF-USNAM . DATA: VGART TYPE MKPF-VGART . DATA: VKWRT TYPE MSEG-VKWRT . DATA: WAERS TYPE MSEG-WAERS . DATA: WERKS TYPE MSEG-WERKS . DATA: XABLN TYPE MKPF-XABLN . DATA: XAUTO TYPE MSEG-XAUTO . DATA: XBLNR TYPE MKPF-XBLNR . DATA: ZEILE TYPE MSEG-ZEILE . ************************************增强供应商描述,物料组和物料组描述和成本中心四个字段 DATA: NAME TYPE LFA1-NAME1. DATA: MATKL TYPE MARA-MATKL . DATA: WGBEZ TYPE T023T-WGBEZ . DATA: LTEXT TYPE CSKT-LTEXT . ************************************增强供应商描述,物料组和物料组描述和成本中心四个字段
DATA: END OF ITAB.
2.在FORM DATA_SELECTION DATA_SELECTION_VIA_MATNR DATA_SELECTION_VIA_BUDAT 的尾部增加如下代码:
LOOP AT ITAB. IF ITAB-LIFNR IS NOT INITIAL. SELECT SINGLE NAME1 INTO ITAB-NAME FROM LFA1 WHERE LIFNR EQ ITAB-LIFNR. ENDIF. IF ITAB-MATNR IS NOT INITIAL. SELECT SINGLE MATKL INTO ITAB-MATKL FROM MARA WHERE MATNR EQ ITAB-MATNR. ENDIF. IF ITAB-MATKL IS NOT INITIAL. SELECT SINGLE WGBEZ INTO ITAB-WGBEZ FROM T023T WHERE MATKL EQ ITAB-MATKL. ENDIF. IF ITAB-KOSTL IS NOT INITIAL. SELECT SINGLE LTEXT INTO ITAB-LTEXT FROM CSKT WHERE KOSTL EQ ITAB-KOSTL. ENDIF. MODIFY ITAB. ENDLOOP.
3.在FORM BUILD_RUNTIMETABLE 尾部增加如下代码
************************************增强供应商描述,物料组和物料组描述和成本中心四个字段 RX1 ‘ZMB51′ ‘NAME’ ‘00′ ‘00′. RX1 ‘ZMB51′ ‘MATKL’ ‘00′ ‘00′. RX1 ‘ZMB51′ ‘WGBEZ’ ‘00′ ‘00′. RX1 ‘ZMB51′ ‘LTEXT’ ‘00′ ‘00′. ************************************增强供应商描述,物料组和物料组描述和成本中心四个字段
5.DEFINE RX1. CS-TABNAME = &1. CS-FIELDNAME = &2. CS-SELECTION_POSITION = &3. CS-OUTPUT_POSITION = &4. APPEND CS TO RTT. END-OF-DEFINITION.