目标: 掌握SAP MM模块,主要流程相关的BAPI 函数的使用,主要有如下模块:
询价 报价 货源清单 配额安排 采购信息记录 框架协议-合同 框架协议-计划协议 采购订单 采购收货 发票校验 发票过账
BAPI是SAP系统标准函数,比如:采购申请创建函数、采购订单创建函数等等。
采购信息记录修改 | https://blog.csdn.net/java_zhong1990/article/details/132476941 |
框架协议-合同创建 | https://blog.csdn.net/java_zhong1990/article/details/132478515 |
框架协议-合同修改 | https://blog.csdn.net/java_zhong1990/article/details/132478515 |
框架协议-计划协议创建 | https://blog.csdn.net/java_zhong1990/article/details/132480611 |
采购申请创建 | https://blog.csdn.net/java_zhong1990/article/details/132494183 |
采购订单创建 | https://blog.csdn.net/java_zhong1990/article/details/132497843 |
采购订单收货创建 | https://blog.csdn.net/java_zhong1990/article/details/132500259 |
采购发票预制 | https://blog.csdn.net/java_zhong1990/article/details/132513256 |
采购发票过账 | https://blog.csdn.net/java_zhong1990/article/details/132514113 |
ME_INFORECORD_MAINTAIN | 采购信息记录修改 |
BAPI_CONTRACT_CREATE | 框架协议-合同创建 |
BAPI_CONTRACT_CHANGE | 框架协议-合同修改 |
BAPI_SAG_CREATE | 框架协议-计划协议创建 |
BAPI_PR_CREATE | 采购申请创建 |
BAPI_PO_CREATE1 | 采购订单创建 |
BAPI_GOODSMVT_CREATE | 采购订单收货创建 |
BAPI_INCOMINGINVOICE_PARK | 采购发票预制 |
BAPI_INCOMINGINVOICE_POST | 采购发票过账 |
ref:https://may82jftve.feishu.cn/docx/IrFMdpxLcoHOE9xJQCmcMQSdnt9
1.3.1 创建
1.3.2 修改
FORM call_bapi_change .
DATA:
l_mode TYPE c,
lw_eina TYPE eina,
lw_eine TYPE eine,
lw_i_eina TYPE mewieina,
lw_i_einax TYPE mewieinax,
lw_i_eine TYPE mewieine,
lw_i_einex TYPE mewieinex,
lw_eina_db TYPE eina,
lw_eine_db TYPE eine,
lt_return TYPE mewi_t_return,
lw_return LIKE LINE OF lt_return,
lw_e_eina TYPE mewieina,
lw_e_eine TYPE mewieine,
lt_con_vali TYPE TABLE OF mewivalidity,
lw_con_vali TYPE mewivalidity,
lt_condition TYPE TABLE OF mewicondition,
lw_condition TYPE mewicondition.
LOOP AT it_alv WHERE checkbox = 'X'.
CLEAR:lt_return[],lt_con_vali[],lt_condition[],lw_i_eina,lw_i_eine,lw_i_einex.
*补齐物料号的前导零
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = it_alv-matnr
IMPORTING
output = it_alv-matnr
EXCEPTIONS
length_error = 1
OTHERS = 2.
*补齐供应商的前导零
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = it_alv-lifnr
IMPORTING
output = it_alv-lifnr.
SELECT SINGLE meins FROM eina INTO @DATA(lv_meins) WHERE matnr = @it_alv-matnr.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF @lw_eina_db
FROM eina
WHERE matnr = @it_alv-matnr
AND lifnr = @it_alv-lifnr.
SELECT SINGLE *
INTO CORRESPONDING FIELDS OF @lw_eine_db
FROM eine
WHERE infnr = @lw_eina_db-infnr
AND ekorg = @it_alv-ekorg "采购组织
AND esokz = @it_alv-esokz "采购信息记录分类
AND werks = @it_alv-werks."工厂
IF sy-subrc = 0.
l_mode = 'M'."修改
lw_i_eina-info_rec = lw_eina_db-infnr."采购信息记录号
lw_i_eine-info_rec = lw_eina_db-infnr."
lw_i_einex-info_rec = 'X'.
lw_i_einax-vendor = 'X'.
lw_i_einax-material = 'X'.
ELSE.
* MESSAGE e000(zmm01) WITH '该类型信息记录不存在'.
it_alv-icon = '@5C@'.
it_alv-msg = '该类型信息记录不存在,请使用创建!'.
MODIFY it_alv.
CONTINUE.
ENDIF.
lw_i_eina-vendor = it_alv-lifnr."供应商
lw_i_eina-material = it_alv-matnr."物料编码
"
lw_i_eine-purch_org = it_alv-ekorg."采购组织
IF lw_i_eine-purch_org IS NOT INITIAL.
lw_i_einex-purch_org = 'X'.
ENDIF.
lw_i_eine-info_type = it_alv-esokz."信息类别
IF lw_i_eine-info_type IS NOT INITIAL.
lw_i_einex-info_type = 'X'.
ENDIF.
lw_i_eine-plant = it_alv-werks."工厂
IF lw_i_eine-plant IS NOT INITIAL.
lw_i_einex-plant = 'X'.
ENDIF.
* lw_i_eine-pur_group = lw_eine-ekgrp."采购组
* IF lw_i_eine-pur_group IS NOT INITIAL.
* lw_i_einex-pur_group = 'X'.
* ENDIF.
lw_i_eine-currency = it_alv-konwa."货币码
IF lw_i_eine-currency IS NOT INITIAL.
lw_i_einex-currency = 'X'.
ENDIF.
lw_i_eine-tax_code = it_alv-mwsk1."税码
IF lw_i_eine-tax_code IS NOT INITIAL.
lw_i_einex-tax_code = 'X'.
ENDIF.
* lw_i_eine-plnd_delry = it_alv-aplfz."计划交货时间(天)
* IF lw_i_eine-plnd_delry IS NOT INITIAL.
* lw_i_einex-plnd_delry = 'X'.
* ENDIF.
lw_i_eine-net_price = it_alv-netpr."净价
IF lw_i_eine-net_price IS NOT INITIAL.
lw_i_einex-net_price = 'X'.
ENDIF.
lw_i_eine-gr_basediv = it_alv-webre.
lw_i_einex-gr_basediv = 'X'.
* lw_i_eine-orderpr_un = it_alv-bprme."采购单位
* IF lw_i_eine-orderpr_un IS NOT INITIAL.
* lw_i_einex-orderpr_un = 'X'.
* ENDIF.
lw_i_eine-price_unit = it_alv-kpein."价格单位
IF lw_i_eine-price_unit IS NOT INITIAL.
lw_i_einex-price_unit = 'X'.
ENDIF.
lw_i_eine-under_tol = it_alv-untto. "交货不足容差
IF lw_i_eine-under_tol IS NOT INITIAL.
lw_i_einex-under_tol = 'X'.
ENDIF.
lw_i_eine-overdeltol = it_alv-uebto. "过量交货容差
IF lw_i_eine-overdeltol IS NOT INITIAL.
lw_i_einex-overdeltol = 'X'.
ENDIF.
lw_i_eine-min_po_qty = it_alv-minbm. "最小采购订单数量
IF lw_i_eine-min_po_qty IS NOT INITIAL.
lw_i_einex-min_po_qty = 'X'.
ENDIF.
* lw_i_eine-nrm_po_qty = it_alv-norbm. "标准采购订单数量
* IF lw_i_eine-nrm_po_qty IS NOT INITIAL.
* lw_i_einex-nrm_po_qty = 'X'.
* ENDIF.
IF it_alv-netpr IS NOT INITIAL.
*} INSERT
lw_i_eine-nrm_po_qty = it_alv-norbm."标准采购订单数量
lw_i_einex-nrm_po_qty = 'X'.
lw_con_vali-plant = it_alv-werks."工厂
IF it_alv-datab IS INITIAL.
lw_con_vali-valid_from = sy-datum.
ELSE.
lw_con_vali-valid_from = it_alv-datab.
ENDIF.
IF it_alv-datbi IS INITIAL.
lw_con_vali-valid_to = '99991231'.
ELSE.
lw_con_vali-valid_to = it_alv-datbi.
ENDIF.
APPEND lw_con_vali TO lt_con_vali.
ENDIF.
lw_condition-cond_type = 'PB00'."固定值
lw_condition-currency = it_alv-konwa."货币码
lw_condition-cond_value = it_alv-netpr."净价
lw_condition-cond_p_unt = it_alv-kpein."条件定价单位
IF lv_meins IS NOT INITIAL.
lw_condition-cond_unit = lv_meins."条件单位
ENDIF.
APPEND lw_condition TO lt_condition.
"对数据进行修改
CALL FUNCTION 'ME_INFORECORD_MAINTAIN'
EXPORTING
i_eina = lw_i_eina
i_einax = lw_i_einax
i_eine = lw_i_eine
i_einex = lw_i_einex
* IMPORTING
* e_eina = lw_e_eina
* e_eine = lw_e_eine
TABLES
return = lt_return.
"理论上这里可以不用commit就能更改条件
CLEAR:lw_i_einex-net_price."一定要清空这个变量,不然程序会报错
CALL FUNCTION 'ME_INFORECORD_MAINTAIN'
EXPORTING
i_eina = lw_i_eina
i_eine = lw_i_eine
i_einex = lw_i_einex
* IMPORTING
* e_eina = lw_e_eina
* e_eine = lw_e_eine
TABLES
cond_validity = lt_con_vali
condition = lt_condition
return = lt_return.
READ TABLE lt_return INTO lw_return WITH KEY type = 'E'.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
it_alv-icon = '@5C@'.
it_alv-msg = '信息记录' && '修改失败'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
it_alv-icon = '@5B@'.
it_alv-msg = '信息记录' && '修改成功'.
ENDIF.
MODIFY it_alv.
ENDLOOP.
ENDFORM.
1.3.3 删除
采购信息记录(Purchase Info Record),它是SAP MM(Materials Management)模块的一部分,用于维护有关供应商和物料之间的采购协议和条件的信息。采购信息记录是采购管理中的重要组成部分,它包含了供应商和物料之间的价格、交货条件、付款条件等关键信息。
以下是有关SAP采购信息记录的主要内容和功能:
供应商信息:采购信息记录包括与特定供应商相关的信息,如供应商代码、名称、联系人等。
物料信息:它还包括与特定物料相关的信息,如物料号码、描述、计量单位等。
价格条件:采购信息记录中存储了与供应商和物料相关的价格条件,如采购价格、最小订购数量、折扣等。
付款条件:它还包括与采购订单付款相关的信息,如付款条件、付款方式等。
交货条件:采购信息记录中存储了供应商提供物料的交货条件,如交货时间、交货地点、运输方式等。
有效性期限:每个采购信息记录通常都有一个有效性期限,指定了协议的有效时间范围。
采购组织数据:与采购组织相关的信息也可能包括在采购信息记录中,以确定采购协议适用于哪个采购组织或公司代码。
采购信息记录的主要功能和用途包括:
4.1 基于Tcode的顺序排列
供应商主数据 | 物料主数据 | 货源清单 | 配额安排 | 采购信息记录 | 采购订单 | 框架协议 | 采购询价/报价 | 采购申请 | 订单收货 | 发票校验 | 物料需求计划 |
BP-供应商主数据 | MM01 - 物料主数据新增 | ME01 - 维护 | MEQ1 - 维护 | ME11 - 创建 | ME21N - 创建 | 框架协议-合同: | 询价: | ME51N - 创建采购申请 | MIGO - 货物移动 | MIRO - 发票校验 | MD01 - 联机 |
XK01 - 创建 | MM02 - 物料主数据修改 | ME03 - 显示 | MEQ3 - 显示 | ME12 - 修改 | ME22N - 更改 | ME31K - 创建 | ME41 - 创建 | ME52N - 更改采购申请 | MB03 - 显示物料凭证 | MD04 - 显示库存/需求状况 | |
XK02 - 更改 | MM03 - 物料主数据查询 | ME0M - 清单查询 | MEQ4 - 更改 | ME13 - 查询 | ME23N - 显示 | ME32K - 更改 | ME42 - 更改 | ME53N - 显示采购申请 | MB51 - 物料凭证清单 | ||
XK03 - 显示 | MM04 - 物料主数据冻结与解冻 | ME04 - 修改记录查询 | MEQM - 按物料 (清单显示) | ME14 - 修改记录查询 | ME29N - 审批 | ME33K - 显示 | ME43 - 显示 | ME54N - 批准采购请求 | MMBE - 库存总览 | ||
XK04 - 修改 | MM50 - 扩充物料视图 | ME15 - 删除 | ME34K - 维护补充 | ME44 - 维护补充 | ME5A - 清单查询 | MB52 - 现有仓库库存清单 | |||||
XK05 - 冻结 | MM06 - 删除物料标记 | ME1L - 清单查询 | ME35K - 审批 | ME45 - 审批 | |||||||
XK06 - 删除标记 | MM60 - 物料清单 | 框架协议-计划协议: | 报价: | ||||||||
XK07 - 科目组改变 | MM17 - 成批维护 | ME31L - 已知供应商 | ME47 - 维护 | ||||||||
ME37 - 库存传送计划协议 | ME48 - 显示 | ||||||||||
ME32L - 更改 | ME49 - 价格比较 | ||||||||||
ME33L - 显示 | |||||||||||
ME34L - 维护补充 | |||||||||||
ME35L - 审批 |
鸣谢:感谢查阅,请多多指教,有用请收藏、点赞哦 !