【ABAP】MM02保存后数据传输至外围系统

【问题】MM02更改物料主数据之后,传递最新数据至外围系统。
【方案】找到MM02保存后所触发的增强点。
【执行】从第一代增强到第四代增强,前三代都没找到合适的增强点,只在第四代增强BTE里面找到一个触发点 00001250

  1. 运行事务码:FIBF,进入维护事务BTE,选择菜单“环境->信息系统(P/S)(I)->F8 运行程序

  2. 找到业务交易事件【00001250 物料主数据:过帐】,选中后点击模式函数模块

  3. 跳转到函数构建器,将带出的功能模块复制一份(以Z开头),函数组不需要变动

  4. 进入功能模块,写入你需要实现功能的代码

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
      CHECK sy-tcode = 'MM02'.

    DATA: lt_mara TYPE mara OCCURS 0 WITH HEADER LINE,
    lt_marc TYPE marc OCCURS 0 WITH HEADER LINE,
    ls_makt TYPE makt,
    lt_makt TYPE makt OCCURS 0 WITH HEADER LINE,
    ls_marm TYPE marm,
    lt_marm TYPE marm OCCURS 0 WITH HEADER LINE,
    lt_zmara TYPE zmara OCCURS 0 WITH HEADER LINE.

    DATA: ls_msgr TYPE zsha047_msgout.

    DATA:lt_material TYPE TABLE OF zmaterial_master,
    ls_material TYPE zmaterial_master.

    APPEND i_mara_new TO lt_mara.
    APPEND i_marc_new TO lt_marc.

    MOVE-CORRESPONDING t_makt_new TO ls_makt.
    ls_material-maktx = ls_makt-maktx.
    APPEND ls_makt TO lt_makt.

    MOVE-CORRESPONDING t_marm_new TO ls_marm.
    APPEND ls_marm TO lt_marm.

    ls_material-matnr = i_mara_new-matnr.
    ls_material-mtart = i_mara_new-mtart.
    ls_material-matkl = i_mara_new-matkl.
    ls_material-meins = i_mara_new-meins.
    ls_material-lvorm = i_mara_new-lvorm.
    ls_material-werks = i_marc_new-werks.
    ls_material-lvorm = i_mara_new-lvorm.
    APPEND ls_material to lt_material.

    *srm物料主数据接收
    CALL FUNCTION 'ZYHG02_IFX001'
    EXPORTING
    iv_comit = 'X'
    IMPORTING
    es_msgr = ls_msgr
    TABLES
    it_mara = lt_mara
    it_makt = lt_makt
    it_marc = lt_marc
    it_marm = lt_marm
    it_zmara = lt_zmara.

    *wms物料主数据接收
    IF lt_marc IS NOT INITIAL.
    CALL FUNCTION 'ZYHG03_IFX001'
    EXPORTING
    iv_comit = 'X'
    IMPORTING
    es_msgr = ls_msgr
    TABLES
    it_marc = lt_marc.
    ENDIF.

    *bsp物料数据接收
    IF lt_material IS NOT INITIAL.
    CALL FUNCTION 'ZYHG05_IFX001'
    EXPORTING
    iv_comit = 'X'
    IMPORTING
    es_msgr = ls_msgr
    TABLES
    lt_material = lt_material.
    ENDIF.

    clear:ls_msgr,ls_material,ls_makt,ls_marm.

  5. 代码写完之后,还差最后一步,回到FIBF创建产品,设置——产品——一个客户的

  6. 配置产品,事件及函数模块,设置——发布/订阅模块——一个客户的

  7. 最后测试一下,传递数据是否为最新数据。