MFBF:装配反冲-----收货过账

1、此文章主要是针对MFBF事务码中的装配反冲,就是进行收货过账的,原本这个装配反冲可以用BAPI_REPMANCONF_CREATE_MTS进行过账的,但是由于BAPI不能修改移动类型,导致最后只能使用BDC进行过账

MFBF中装配反冲的原始界面:
MFBF:装配反冲-----收货过账_第1张图片
不能用BAPI_REPMANCONF_CREATE_MTS过账的原因如下

MFBF:装配反冲-----收货过账_第2张图片
程序示例如下:移动类型不同,导致BDC录屏也不同

if pv_bwart = '132' or pv_bwart = 'Z50'.
    clear:gt_bdcdata.
    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ZPKT'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    perform bdc_field       using 'RM61B-REP_POINTS'  'X'.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                     '=REVR'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'BDC_CURSOR' 'RM61B-ERFMG'.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                   '=PARA'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'BDC_CURSOR'  'RM61B-ACHARG'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    perform bdc_field       using 'RM61B-REP_POINTS'  'X'.
    perform bdc_field       using 'RM61B-ZPUNKT' pv_zpunkt. "报告点
    if pv_charg is not initial.
      perform bdc_field       using 'RM61B-ACHARG' pv_charg. "系统批次
    endif.
    perform bdc_field       using 'RM61B-ERFMG' pv_menge. "数量

    perform bdc_dynpro      using 'SAPLBARM' '0150'.
    perform bdc_field       using 'BDC_CURSOR'  'RM61B-BWAWE'.
    perform bdc_field       using 'BDC_OKCODE'   '=GOON'.
    perform bdc_field       using 'RM61B-LBOFF' 'X'.
    perform bdc_field       using 'RM61B-RADIOFR' 'X'.
    perform bdc_field       using 'RM61B-BWAWE' pv_bwart. "移动类型
    perform bdc_field       using 'RM61B-BWAWA' '262'.
    perform bdc_field       using 'RM61B-BWAWEM' '572'.
    perform bdc_field       using 'RM61B-BWAWAM' '571'.
    perform bdc_field       using 'RM61B-BWACR' '292'.
    perform bdc_field       using 'RM61B-BWASC' '552'.
    perform bdc_field       using 'RM61B-BWACO' '532'.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'  '=POST'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-PLWERK'  pv_werks.
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    if pv_charg  is  not initial.
      perform bdc_field       using 'RM61B-ACHARG' pv_charg. "系统批次
    endif.
    perform bdc_field       using 'RM61B-ERFMG' pv_menge. "数量

  else.
    clear:gt_bdcdata.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                  '=ZPKT'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    perform bdc_field       using 'RM61B-REP_POINTS'  'X'.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                     '=GOON'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    perform bdc_field       using 'RM61B-REP_POINTS'  'X'.
    perform bdc_field       using 'RM61B-ZPUNKT' pv_zpunkt. "报告点
    perform bdc_field       using 'RM61B-ERFMG' pv_menge. "数量

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                   '=PARA'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-PLWERK'  pv_werks.
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    if  pv_charg is not initial.
      perform bdc_field       using 'RM61B-ACHARG' pv_charg. "系统批次
    endif.
    perform bdc_field       using 'RM61B-ERFMG' pv_menge. "数量

    perform bdc_dynpro      using 'SAPLBARM' '0150'.
    perform bdc_field       using 'BDC_CURSOR'
                                  'RM61B-BWAWE'.
    perform bdc_field       using 'BDC_OKCODE'
                                   '=GOON'.
    perform bdc_field       using 'RM61B-LBOFF' 'X'.
    perform bdc_field       using 'RM61B-RADIOFR' 'X'.
    perform bdc_field       using 'RM61B-BWAWE' pv_bwart. "移动类型
    perform bdc_field       using 'RM61B-BWAWA' '261'.
    perform bdc_field       using 'RM61B-BWAWEM' '571'.
    perform bdc_field       using 'RM61B-BWAWAM' '572'.
    perform bdc_field       using 'RM61B-BWACR' '291'.
    perform bdc_field       using 'RM61B-BWASC' '551'.
    perform bdc_field       using 'RM61B-BWACO' '531'.

    perform bdc_dynpro      using 'SAPLBARM' '0800'.
    perform bdc_field       using 'BDC_OKCODE'
                                    '=POST'.
    perform bdc_field       using 'RM61B-BUDAT' pv_budat. "过账日期
    perform bdc_field       using 'RM61B-BLDAT' pv_bldat. "凭证日期
    perform bdc_field       using 'RM61B-RB_BAUGR' 'X'.
    perform bdc_field       using 'RM61B-MATNR' pv_matnr. "物料号
    perform bdc_field       using 'RM61B-WERKS' pv_werks. "工厂
    perform bdc_field       using 'RM61B-VERID' pv_verid. "生产版本
    perform bdc_field       using 'RM61B-PLWERK'  pv_werks.
    perform bdc_field       using 'RM61B-ALORT' pv_lgort. "库存地点
    if pv_charg is not initial  .
      perform bdc_field       using 'RM61B-ACHARG' pv_charg. "系统批次
    endif.
    perform bdc_field       using 'RM61B-ERFMG' pv_menge. "数量

  endif.

  clear: gt_messtab.
  call transaction 'MFBF'
        using gt_bdcdata
        mode 'N' "A:前台执行 N:后台执行
        update 'S' "S:同步 A:异步
        messages into gt_messtab.
  clear: lt_return.
  call function 'CONVERT_BDCMSGCOLL_TO_BAPIRET2'
    tables
      imt_bdcmsgcoll = gt_messtab
      ext_return     = lt_return.

  read table lt_return into ls_return with key type = 'E'. "#EC CI_STDSEQ
  if sy-subrc eq 0. "BDC出现错误
    cv_flag = 'X'.
    move-corresponding ls_return to cs_return.
    return.
  else. "BDC更新成功
    commit work.
    read table lt_return into ls_return with key type = 'S' id = 'RM'." number = '190' or '191' or '215'. "#EC CI_STDSEQ
    if sy-subrc eq 0.
      move-corresponding ls_return to cs_return.
      cv_flag = ''.
      cv_mblnr = ls_return-message_v1. "凭证号
    endif.
  endif.

你可能感兴趣的:(ABAP,abap,sap)