SAP 各模块常用的BAPI

时间:2024-04-27 15:36:11
MM模块
1、 BAPI_MATERIAL_SAVEDATA 创建物料主数据
注意参数EXTENSIONIN的使用,可以创建自定义字段
例如:WA_BAPI_TE_MARA-MATERIAL = ITAB_UP-MATNR.
         T_EXTENSIONIN-STRUCTURE = 'BAPI_TE_MARA'.
         T_EXTENSIONIN-VALUEPART1 = WA_BAPI_TE_MARA.
        APPEND T_EXTENSIONIN.
        WA_BAPI_TE_MARAX-MATERIAL = ITAB_UP-MATNR.
   T_EXTENSIONINX-STRUCTURE = 'BAPI_TE_MARAX'.
        T_EXTENSIONINX-VALUEPART1 = WA_BAPI_TE_MARAX.
       APPEND T_EXTENSIONINX.
2、 BAPI_OBJCL_CREATE 分类视图的创建
3、 BAPI_OBJCL_GETCLASSES 分类视图得到详细信息
4、 BAPI_MATERIAL_SAVEREPLICA 物料视图的扩充
5、 BAPI_GOODSMVT_CREATE 创建物料凭证 注意表T158G可以决定goodsmvt_code
      GOODSMVT_CODE参数对应值:
  01 MB01
  02 MB31
  03 MB1A
  04 MB1B
  05 MB1C
  06 MB11
  07 MB04
6、 BAPI_GOODSMVT_CANCEL 冲销物料凭证
7、 BAPI_PR_CREATE 创建PR
8、 BAPI_PO_CREATE1 创建PO
9、 BAPI_PO_CHANGE 修改PO和删除PO
10、WS_REVERSE_GOODS_ISSUE 冲销交货单的过账发货
11、BAPI_RESERVATION_CREATE1 创建预留   如果要检查ATP,必须使用
      BAPI_RESERVATION_CREATE
12、BAPI_RESERVATION_CHANGE 修改和删除预留
13、PRICES_CHANGE PRICES_POST 更改物料移动平均价或者标准价格
如果要检查ATP,必须使用第二个
SD模块
1、 BAPI_SALESORDER_CREATEFROMDAT2 创建销售订单
2、 SD_SALESDOCUMENT_CREATE 创建销售订单
3、 BAPI_OUTB_DELIVERY_CREATE_SLS 根据销售订单创建交货单
4、 BAPI_BILLINGDOC_CREATEMULTIPLE 创建发票,注意参数ref_doc_ca
5、 BAPI_SALESORDER_CHANGE 修改或者删除销售订单
6、 MB_CANCEL_GOODS_MOVEMENT 冲销交货单的过账发货
7、 BAPI_BILLINGDOC_CANCEL1 发票的冲销
8、 BAPI_OUTB_DELIVERY_CHANGE 修改外向交货单
9、 SD_DELIVERY_UPDATE_PICKING 修改外向交货单拣配数量
10、WS_DELIVERY_UPDATE 外向交货单的发货过账
11、SD_CUSTOMER_MAINTAIN_ALL   创建客户 。
        table参数中有很多表,其中X打头代表要插入的数据,Y打头代表要删除的数据。
DATA: TMP   TYPE STRING,
LEN TYPE I,
FLAG TYPE CHAR1,
SY_SUBRC() TYPE C. CLEAR :E_MESS. *--判断是否存在同名客户
IF I_KNA1-KUNNR IS INITIAL.
SELECT SINGLE NAME1 INTO TMP
FROM KNA1
WHERE NAME1 = I_KNA1-NAME1
AND NAME2 = I_KNA1-NAME2
.
IF SY-SUBRC = .
FLAG = 'X'.
E_STATU = 'E'.
E_MESS = '存在名称相同的客户'.
ENDIF.
ENDIF.
*--判断邮编的长度
LEN = STRLEN( I_KNA1-PSTLZ ).
IF LEN <> .
FLAG = 'X'.
E_STATU = 'E'.
E_MESS = '邮编应该是6位数'.
ENDIF. IF FLAG = ''. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = I_KNA1-KUNNR
IMPORTING
OUTPUT = I_KNA1-KUNNR
. I_KNA1-LAND1 = 'CN'.
I_KNA1-SPRAS = .
**--客户的销售数据
I_KNVV-KUNNR = I_KNA1-KUNNR.
* I_KNVV-VKORG = ' ' ."销售组织
I_KNVV-VTWEG = '' . "分销渠道
I_KNVV-SPART = '' . "产品组
* I_KNVV-BZIRK = ' ' ."销售地区
* I_KNVV-VKBUR = ' ' ."销售部门
I_KNVV-WAERS = 'RMB' . "货币
I_KNVV-KALKS = '' . "定价过程
I_KNVV-VERSG = '' . "客户统计组
I_KNVV-ANTLF = ''. "最大部分交货
I_KNVV-VSBED = ''. "装运条件
I_KNVV-KZAZU = 'X'. "订单组合chk
I_KNVV-ZTERM = ''. "付款条件
I_KNVV-KABSS = ''. " 付款担保过程
I_KNVV-KKBER = ''. "信贷控制范围
I_KNVV-KTGRD = ''. "账户分配组 IF I_KNA1-KTOKD = 'A001'.
I_KNVV-KDGRP = ''. "客户组
I_KNVV-KONDA = ''. "价格组
I_KNB1-FDGRV = 'E1'. " 现金管理组
ELSEIF I_KNA1-KTOKD = 'A002'.
I_KNVV-KDGRP = ''. "客户组
I_KNVV-KONDA = ''. "价格组
I_KNB1-FDGRV = 'E2'. " 现金管理组
ENDIF.
**--客户的公司数据 I_KNB1-KUNNR = I_KNA1-KUNNR.
I_KNB1-BUKRS = I_KNVV-VKORG.
* I_KNB1-AKONT = ''. "统驭科目
I_KNB1-ZTERM = ''. "付款条件
I_KNB1-XZVER = 'X'. "付款历史记录chk
**--银行
READ TABLE T_XKNBK INDEX .
IF I_KNA1-KUNNR IS NOT INITIAL.
SELECT SINGLE * INTO T_YKNBK
FROM KNBK
WHERE KUNNR = I_KNA1-KUNNR
AND BANKS = 'CN'.
IF SY-SUBRC EQ .
APPEND T_YKNBK.
ENDIF.
ENDIF. T_XKNBK-KUNNR = I_KNA1-KUNNR.
T_XKNBK-BANKS = 'CN'. "银行国家代码
T_XKNBK-BANKL = ''. "银行码
MODIFY T_XKNBK INDEX TRANSPORTING KUNNR BANKS BANKL. **--客户联系人
READ TABLE T_XKNVK INDEX .
IF I_KNA1-KUNNR IS NOT INITIAL.
SELECT SINGLE * INTO T_YKNVK
FROM KNVK
WHERE KUNNR = I_KNA1-KUNNR.
IF SY-SUBRC EQ .
APPEND T_YKNVK.
ENDIF.
ENDIF. T_XKNVK-KUNNR = I_KNA1-KUNNR.
T_XKNVK-NAMEV = '#'.
T_XKNVK-ABTNR = ''.
T_XKNVK-PAFKT = ''.
MODIFY T_XKNVK INDEX TRANSPORTING KUNNR NAMEV ABTNR PAFKT.
** 合作伙伴
IF I_KNA1-KUNNR IS NOT INITIAL.
SELECT SINGLE * INTO T_YKNVP
FROM KNVP
WHERE KUNNR = I_KNA1-KUNNR
AND VKORG = I_KNVV-VKORG
AND VTWEG = ''
AND SPART = ''
AND PARVW = 'VE'.
IF SY-SUBRC EQ .
APPEND T_YKNVP.
ENDIF.
ENDIF.
T_XKNVP-KUNNR = I_KNA1-KUNNR.
T_XKNVP-VKORG = I_KNVV-VKORG ."销售组织
T_XKNVP-VTWEG = '' ."分销渠道
T_XKNVP-SPART = '' ."产品组
T_XKNVP-PARVW = 'VE '.
* T_XKNVP-PERNR = ''.
MODIFY T_XKNVP INDEX TRANSPORTING KUNNR VKORG VTWEG SPART PARVW.
**税收
IF I_KNA1-KUNNR IS NOT INITIAL.
SELECT SINGLE * INTO T_YKNVI
FROM KNVI
WHERE KUNNR = I_KNA1-KUNNR
AND ALAND = 'CN'
AND TATYP = 'MWST'.
IF SY-SUBRC EQ .
APPEND T_YKNVI.
ENDIF.
ENDIF.
T_XKNVI-KUNNR = I_KNA1-KUNNR.
T_XKNVI-ALAND = 'CN'.
T_XKNVI-TATYP = 'MWST'.
T_XKNVI-TAXKD = ''.
APPEND T_XKNVI . CALL FUNCTION 'SD_CUSTOMER_MAINTAIN_ALL'
EXPORTING
I_KNA1 = I_KNA1
I_KNB1 = I_KNB1
I_KNVV = I_KNVV
I_MAINTAIN_ADDRESS_BY_KNA1 = 'X'
I_KNB1_REFERENCE = I_KNB1_REFERENCE
I_FORCE_EXTERNAL_NUMBER_RANGE = I_FORCE_EXTERNAL_NUMBER_RANGE
I_NO_BANK_MASTER_UPDATE = I_NO_BANK_MASTER_UPDATE
I_CUSTOMER_IS_CONSUMER = I_CUSTOMER_IS_CONSUMER
I_RAISE_NO_BTE = I_RAISE_NO_BTE
PI_POSTFLAG = 'X'
PI_CAM_CHANGED = PI_CAM_CHANGED
PI_ADD_ON_DATA = PI_ADD_ON_DATA
I_FROM_CUSTOMERMASTER = 'X'
IMPORTING
E_KUNNR = E_KUNNR
O_KNA1 = O_KNA1
TABLES
T_XKNAS = T_XKNAS
T_XKNBK = T_XKNBK
T_XKNB5 = T_XKNB5
T_XKNEX = T_XKNEX
T_XKNVA = T_XKNVA
T_XKNVD = T_XKNVD
T_XKNVI = T_XKNVI
T_XKNVK = T_XKNVK
T_XKNVL = T_XKNVL
T_XKNVP = T_XKNVP
T_XKNZA = T_XKNZA T_YKNAS = T_YKNAS
T_YKNBK = T_YKNBK
T_YKNB5 = T_YKNB5
T_YKNEX = T_YKNEX
T_YKNVA = T_YKNVA
T_YKNVD = T_YKNVD
T_YKNVI = T_YKNVI
T_YKNVK = T_YKNVK
T_YKNVL = T_YKNVL
T_YKNVP = T_YKNVP
T_YKNZA = T_YKNZA
T_UPD_TXT = T_UPD_TXT
EXCEPTIONS
CLIENT_ERROR =
KNA1_INCOMPLETE =
KNB1_INCOMPLETE =
KNB5_INCOMPLETE =
KNVV_INCOMPLETE =
KUNNR_NOT_UNIQUE =
SALES_AREA_NOT_UNIQUE =
SALES_AREA_NOT_VALID =
INSERT_UPDATE_CONFLICT =
NUMBER_ASSIGNMENT_ERROR =
NUMBER_NOT_IN_RANGE =
NUMBER_RANGE_NOT_EXTERN =
NUMBER_RANGE_NOT_INTERN =
ACCOUNT_GROUP_NOT_VALID =
PARNR_INVALID =
BANK_ADDRESS_INVALID =
TAX_DATA_NOT_VALID =
NO_AUTHORITY =
COMPANY_CODE_NOT_UNIQUE =
DUNNING_DATA_NOT_VALID =
KNB1_REFERENCE_INVALID =
CAM_ERROR =
OTHERS =
.
IF SY-SUBRC NE .
SY_SUBRC = SY-SUBRC.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. E_STATU = 'E'.
CONCATENATE '客户更新失败(' SY_SUBRC ')' INTO E_MESS. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
IF SY-SUBRC = .
E_STATU = 'S'.
E_MESS = '客户更新成功'.
E_KUNNR = O_KNA1-KUNNR.
ELSE.
E_STATU = 'E'.
CONCATENATE '客户更新失败(' SY_SUBRC ')' INTO E_MESS.
ENDIF. ENDIF. ENDIF.

PM模块

1、BAPI_OBJCL_CREATE 、
     BAPI_OBJCL_CHANGE、
     BAPI_OBJCL_GETDETAIL
     计量点通用属性导入
2、MEASUREM_DOCUM_RFC_SINGLE_001 计量凭证创建
FI模块
1、K_HIERARCHY_TABLES_READ 成本要素组明细
2、BAPI_ACC_DOCUMENT_POST 创建会计凭证
3、BAPI_ACC_DOCUMENT_REV_POST 反冲会计凭证   可以冲销自开发程序生成的凭证   必须传入交易码参数
     BAPI_ACC_GL_POSTING_REV_POST 只能冲销标准TCODE生成的凭证
4、FCOM_COSTCENTER_CHANGEMULTIPLE
      FCOM_COSTCENTER_CREATEMULTIPLE
      BAPI_COSTCENTER_CHANGEMULTIPLE :Change One or More Cost Centers
      BAPI_COSTCENTER_CHECKMULTIPLE  :Check One or More Cost Centers
      BAPI_COSTCENTER_CREATEMULTIPLE :Create One or More Cost Centers
      BAPI_COSTCENTER_DELETEMULTIPLE :Delete One or More Cost Centers
CALL FUNCTION 'FCOM_COSTCENTER_CHANGEMULTIPLE'
EXPORTING
iv_coarea = ''
it_costcenter = it_mm
IMPORTING
et_message = lt_mm
EXCEPTIONS
failed =
OTHERS = .CALL FUNCTION 'FCOM_COSTCENTER_CREATEMULTIPLE'
EXPORTING
iv_coarea = ''
it_costcenter = it_cc
IMPORTING
et_message = lt_cc
EXCEPTIONS
failed =
OTHERS = .
    SELECT SINGLE * FROM BKPF INTO L_BKPF
WHERE BUKRS = IW_BUKRS
AND BELNR = IW_bELNR
AND GJAHR = IW-GJAHR. REVERSAL-OBJ_TYPE = L_BKPF-AWTYP.
CONCATENATE IW_-BELNR IW_-BUKRS IW_-GJAHR INTO REVERSAL-OBJ_KEY_R.
REVERSAL-OBJ_KEY = REVERSAL-OBJ_KEY_R.
REVERSAL-OBJ_KEY = '$'. CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
OWN_LOGICAL_SYSTEM = REVERSAL-OBJ_SYS
EXCEPTIONS
OWN_LOGICAL_SYSTEM_NOT_DEFINED =
OTHERS = . REVERSAL-REASON_REV = ''. "原因
REVERSAL-PSTNG_DATE = SY-DATUM. CLEAR: RETURN. CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_POST'
EXPORTING
REVERSAL = REVERSAL
BUS_ACT = 'RFBU'
IMPORTING
OBJ_TYPE = OBJTYPE
OBJ_KEY = OBJKEY
OBJ_SYS = OBJSYS
TABLES
RETURN = RETURN
.
4、BAPI_INCOMINGINVOICE_CREATE 发票检验(miro)
5、BAPI_INCOMINGINVOICE_CANCEL 发票校验冲销(mr8m)
PS模块
1、BAPI_PS_INITIALIZATION、BAPI_BUS2001_CREATE、BAPI_PS_PRECOMMIT 创建项目定义
2、BAPI_PS_INITIALIZATION、BAPI_BUS2054_CREATE_MULTI、BAPI_PS_PRECOMMIT 创建WBS
创建WBS的时候,注意参数 wbs_left和 wbs_up,这个是创建有层级的WBS必须要填写的
3、KBPP_EXTERN_UPDATE_CO 修改项目和WBS的预算
--------------------------------------------------------------------------------------------------------------
BAPI:BAPI_SALESORDER_CHANGE (TCODE:VA02 销售订单修改)
*&---------------------------------------------------------------------*
*& Form FRM_CHANGE_SALESORDER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_ITEM text
* -->P_LT_COND text
* -->P_LT_MSG text
* -->P_LS_HEAD text
* <--P_LV_EIND text
*----------------------------------------------------------------------* UPDATEFLAGS:
  • U = change  flg值的三种不同意义

  • D = delete

  • I = add
FORM frm_change_salesorder  TABLES  tp_item    STRUCTURE zrmxsds004
tp_cond STRUCTURE zrmxsds005
tp_message STRUCTURE zifsret01
USING up_head LIKE zrmxsds003
CHANGING cp_eind TYPE c. DATA: ls_item LIKE zrmxsds004,
ls_cond LIKE zrmxsds005,
ls_msg LIKE zifsret01,
ls_vbep LIKE vbep. DATA: wa_header TYPE bapisdh1, "表头
wa_headerx TYPE bapisdh1x, "表头标志 wa_partner TYPE bapiparnr, "业务伙伴
wa_partnerc TYPE bapiparnrc, wa_item TYPE bapisditm, "行项目
wa_itemx TYPE bapisditmx, wa_cond TYPE bapicond, "价格条件
wa_condx TYPE bapicondx, wa_schdl TYPE bapischdl, "交付计划
wa_schdlx TYPE bapischdlx, wa_return TYPE bapiret2,
wa_sdls TYPE bapisdls, wa_text TYPE bapisdtext. "文本 DATA:
lt_partner TYPE STANDARD TABLE OF bapiparnr,
lt_partnerc TYPE STANDARD TABLE OF bapiparnrc, lt_item TYPE STANDARD TABLE OF bapisditm,
lt_itemx TYPE STANDARD TABLE OF bapisditmx, lt_schdl TYPE STANDARD TABLE OF bapischdl,
lt_schdlx TYPE STANDARD TABLE OF bapischdlx, lt_cond TYPE STANDARD TABLE OF bapicond,
lt_condx TYPE STANDARD TABLE OF bapicondx, lt_return TYPE STANDARD TABLE OF bapiret2, lt_text LIKE STANDARD TABLE OF bapisdtext. DATA: lt_sokey TYPE STANDARD TABLE OF zrmxsds015,
ls_sokey TYPE zrmxsds015. *--------------------------------------------------------------------*
* Header
CLEAR: wa_header,wa_headerx. IF up_head-updateflag = cns_update.
wa_header-pmnttrms = up_head-zterm. "付款条件 wa_headerx-pmnttrms = cns_yes.
wa_headerx-updateflag = cns_update. "Update *--------------------------------------------------------------------*
* Header texts
*表头文本,若传输空值,则清空该字段
CLEAR: wa_text,lt_text[].
wa_text-itm_number = space.
wa_text-text_id = cns_textid.
wa_text-langu = sy-langu.
wa_text-format_col = '*'.
wa_text-text_line = up_head-tknum. "运输合同号
APPEND wa_text TO lt_text. ENDIF. *--------------------------------------------------------------------*
* Partners IF up_head-kunnr_re IS NOT INITIAL.
"收票方
CLEAR: wa_partnerc.
wa_partnerc-document = up_head-vbeln.
wa_partnerc-itm_number = ''.
wa_partnerc-updateflag = cns_update.
wa_partnerc-partn_role = 'RE'.
wa_partnerc-p_numb_new = up_head-kunnr_re.
APPEND wa_partnerc TO lt_partnerc.
ENDIF. IF up_head-kunnr_rg IS NOT INITIAL.
"付款方
CLEAR: wa_partnerc.
wa_partnerc-document = up_head-vbeln.
wa_partnerc-itm_number = ''.
wa_partnerc-updateflag = cns_update.
wa_partnerc-partn_role = 'RG'.
wa_partnerc-p_numb_new = up_head-kunnr_rg.
APPEND wa_partnerc TO lt_partnerc.
ENDIF. IF up_head-kunnr_we IS NOT INITIAL.
"送达方
CLEAR: wa_partnerc.
wa_partnerc-document = up_head-vbeln.
wa_partnerc-itm_number = ''.
wa_partnerc-updateflag = cns_update.
wa_partnerc-partn_role = 'WE'.
wa_partnerc-p_numb_new = up_head-kunnr_we.
APPEND wa_partnerc TO lt_partnerc.
ENDIF. *--------------------------------------------------------------------*
* Items
REFRESH: lt_item, lt_cond, lt_schdl,
lt_itemx, lt_condx,lt_schdl. LOOP AT tp_item INTO ls_item. IF ls_item-updateflag = cns_new.
"新增行项目
CLEAR wa_item.
wa_item-itm_number = ls_item-posnr.
wa_item-material = ls_item-mabnr. "物料
wa_item-sales_unit = ls_item-vrkme. "计量单位
wa_item-plant = ls_item-werks. "工厂
wa_item-store_loc = ls_item-lgort. "库存地
APPEND wa_item TO lt_item.
"行状态
wa_itemx-itm_number = ls_item-posnr.
wa_itemx-updateflag = cns_new.
wa_itemx-material = cns_yes.
wa_itemx-sales_unit = cns_yes.
wa_itemx-plant = cns_yes.
wa_itemx-store_loc = cns_yes.
APPEND wa_itemx TO lt_itemx. "Schedule lines
CLEAR: wa_schdl,wa_schdlx.
wa_schdl-itm_number = ls_item-posnr.
wa_schdl-req_qty = ls_item-kwmeng. "数量
APPEND wa_schdl TO lt_schdl. wa_schdlx-itm_number = ls_item-posnr.
wa_schdlx-updateflag = cns_new.
wa_schdlx-req_qty = cns_yes.
APPEND wa_schdlx TO lt_schdlx. "新增行,需要对自动生成的生产订单进行下达
CLEAR ls_sokey.
ls_sokey-vbeln = up_head-vbeln.
ls_sokey-posnr = ls_item-posnr.
APPEND ls_sokey TO lt_sokey. ELSEIF ls_item-updateflag = cns_update.
"更新行项目信息 * Schedule line
* 仅行数量
CLEAR: wa_schdl,wa_schdlx.
wa_schdl-itm_number = ls_item-posnr.
wa_schdl-sched_line = ''. "默认都是第一行
wa_schdl-req_qty = ls_item-kwmeng. "数量
APPEND wa_schdl TO lt_schdl. wa_schdlx-itm_number = ls_item-posnr.
wa_schdlx-sched_line = ''.
wa_schdlx-updateflag = cns_update.
wa_schdlx-req_qty = cns_yes.
APPEND wa_schdlx TO lt_schdlx.
ENDIF. ENDLOOP. *--------------------------------------------------------------------*
* Item Conditions
* 价格条件,需要设置该参数,才能够修改价格条件
wa_sdls-cond_handl = cns_yes. LOOP AT tp_cond INTO ls_cond. IF ls_cond-updateflag = cns_new.
"新增价格条件记录
CLEAR: wa_cond,wa_condx.
wa_cond-itm_number = ls_cond-posnr.
wa_cond-cond_type = ls_cond-kschl. "定价条件
wa_cond-cond_value = ls_cond-kbetr. "价格
wa_cond-currency = ls_cond-koein. "货币或%
wa_cond-cond_unit = ls_cond-kmein. "条件单位
wa_cond-cond_p_unt = ls_cond-kpein. "条件定价单位
APPEND wa_cond TO lt_cond. wa_condx-itm_number = ls_cond-posnr.
wa_condx-cond_type = ls_cond-kschl. "定价条件
wa_condx-updateflag = cns_new.
wa_condx-cond_value = cns_yes. "价格
wa_condx-currency = cns_yes. "货币或%
wa_condx-cond_unit = cns_yes. "条件单位
wa_condx-cond_p_unt = cns_yes. "条件定价单位
APPEND wa_condx TO lt_condx. ELSEIF ls_cond-updateflag = cns_update.
"更新价格条件记录
CLEAR: wa_cond,wa_condx. "需要读取已经存在行的Key
PERFORM frm_get_cond_key USING up_head-vbeln
ls_cond-posnr
ls_cond-kschl
CHANGING wa_cond-cond_st_no
wa_cond-cond_count. wa_cond-itm_number = ls_cond-posnr.
* wa_cond-cond_st_no = 040.
* wa_cond-cond_count = 01.
wa_cond-cond_type = ls_cond-kschl. "定价条件 wa_cond-cond_value = ls_cond-kbetr. "价格
wa_cond-currency = ls_cond-koein. "货币或%
wa_cond-cond_unit = ls_cond-kmein. "条件单位
wa_cond-cond_p_unt = ls_cond-kpein. "条件定价单位
APPEND wa_cond TO lt_cond. wa_condx-itm_number = ls_cond-posnr.
wa_condx-cond_st_no = wa_cond-cond_st_no.
wa_condx-cond_count = wa_cond-cond_count.
wa_condx-cond_type = ls_cond-kschl. wa_condx-updateflag = cns_update.
wa_condx-cond_value = cns_yes.
wa_condx-currency = cns_yes.
wa_condx-cond_unit = cns_yes.
wa_condx-cond_p_unt = cns_yes.
APPEND wa_condx TO lt_condx. ELSE.
"报错
ENDIF.
ENDLOOP. * Call BAPI CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = up_head-vbeln
order_header_in = wa_header
order_header_inx = wa_headerx
* SIMULATION =
* BEHAVE_WHEN_ERROR = ' '
* INT_NUMBER_ASSIGNMENT = ' '
logic_switch = wa_sdls
* NO_STATUS_BUF_INIT = ' '
TABLES
return = lt_return
order_item_in = lt_item
order_item_inx = lt_itemx
* partners = lt_partner
partnerchanges = lt_partnerc
* PARTNERADDRESSES =
* ORDER_CFGS_REF =
* ORDER_CFGS_INST =
* ORDER_CFGS_PART_OF =
* ORDER_CFGS_VALUE =
* ORDER_CFGS_BLOB =
* ORDER_CFGS_VK =
* ORDER_CFGS_REFINST =
schedule_lines = lt_schdl
schedule_linesx = lt_schdlx
order_text = lt_text
* ORDER_KEYS =
conditions_in = lt_cond
conditions_inx = lt_condx
* EXTENSIONIN =
. * 处理错误消息:通过判断消息的类型,来判断BAPI是否成功
LOOP AT lt_return INTO wa_return.
CLEAR ls_msg.
ls_msg-class = 'BUS'.
ls_msg-msgtyp = wa_return-type.
ls_msg-msgno = wa_return-number.
ls_msg-msgtxt = wa_return-message.
APPEND ls_msg TO tp_message. IF wa_return-type EQ 'E' OR
wa_return-type = 'A' OR
wa_return = 'X'.
cp_eind = 'X'. "失败
ENDIF. ENDLOOP. IF cp_eind NE 'X'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' .
ENDIF. CHECK cp_eind NE 'X' AND lt_sokey[] IS NOT INITIAL.
* 销售订单自动产生生产订单,对生产订单进行下达
CALL FUNCTION 'Z_RMXPP_PRDORD_RELEASE'
* EXPORTING
* I_WAIT = 3
TABLES
t_sokey = lt_sokey
EXCEPTIONS
no_saleorders =
no_valid_saleorders =
cannot_find_product_orders =
OTHERS =
.
IF sy-subrc <> .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. ENDFORM. "frm_create_salesorder
*&---------------------------------------------------------------------*
*& Form FRM_GET_COND_KEY
*&---------------------------------------------------------------------*
* 读取价格条件记录的Key
*----------------------------------------------------------------------*
* -->P_UP_HEAD_VBELN text
* -->P_LS_COND_POSNR text
* -->P_LS_COND_KSCHL text
* <--P_WA_COND_COND_ST_NO text
* <--P_WA_COND_COND_COUNT text
*----------------------------------------------------------------------*
FORM frm_get_cond_key USING up_vbeln LIKE vbap-vbeln
up_posnr LIKE vbap-posnr
up_kschl LIKE konv-kschl
CHANGING cp_st_no LIKE konv-stunr
cp_count LIKE konv-zaehk.
DATA: lv_knumv LIKE vbak-knumv. " 由于需要多次判断,预先读取聚集表,将订单的所有行读取出来
IF gt_konv[] IS INITIAL.
SELECT SINGLE knumv INTO lv_knumv
FROM vbak
WHERE vbeln = up_vbeln. SELECT
knumv kposn kschl stunr zaehk
INTO CORRESPONDING FIELDS OF TABLE gt_konv
FROM konv
WHERE knumv = lv_knumv.
* AND kposn = up_posnr. SORT gt_konv BY kposn kschl.
ENDIF. CLEAR gwa_konv.
READ TABLE gt_konv INTO gwa_konv
WITH KEY kposn = up_posnr
kschl = up_kschl
BINARY SEARCH.
IF sy-subrc EQ .
cp_st_no = gwa_konv-stunr.
cp_count = gwa_konv-zaehk.
ENDIF. ENDFORM. " FRM_GET_COND_KEY

PP模块

生产计划的BAPI列表::

Routing(工艺路线)

BAPI_ROUTING_CREATE                                                                  创建工艺路线BAPI - ca03

BAPI_ROUTING_EXISTENCE_CHECK                                             检查工艺路线是否存在

Reference operation set:参考操作集

BAPI_REFSETOFOPERATIONS_CREATE                                       创建参考参考工序集

BAPI_REFSETOFOPR_EXISTENCE_CHK                                       检查参考参考工序集

Planned order:(计划订单)

BAPI_PLANNEDORDER_CHANGE                                                   更改计划订单  -md04

BAPI_PLANNEDORDER_CREATE                                                    创建计划订单

BAPI_PLANNEDORDER_DELETE                                                     删除计划订单

BAPI_PLANNEDORDER_EXIST_CHECK                                          检查计划订单是否存在

BAPI_PLANNEDORDER_GET_DETAIL                                             获取计划订单详细信息(计划订单)

BAPI_PLANNEDORDER_GET_DET_LIST                                         获得计划订单信息

Planned Independent Requirement:(计划独立需求)

BAPI_REQUIREMENTS_CHANGE                                                      更改计划独立需求 -md61

BAPI_REQUIREMENTS_CREATE                                                       创建计划独立需求

BAPI_REQUIREMENTS_GETDETAIL                                                  显示计划独立需求

Production order:(生产订单)

BAPI_PRODORD_WM_MAT_STAGING                                             WM材料分期

BAPI_PRODORD_SETUSERSTATUS                                                设置用户状态

BAPI_PRODORD_SET_DEL_INDICATOR                                         设置删除标识

BAPI_PRODORD_SET_DELETION_FLAG                                         设置删除标识

BAPI_PRODORD_SCHEDULE                                                            进行调整

BAPI_PRODORD_REVOKEUSERSTATUS                                        取消用户状态

BAPI_PRODORD_RELEASE                                                               发布

BAPI_PRODORD_GET_LIST                                                               列表抬头订单

BAPI_PRODORD_GET_DETAIL                                                          抬头订单明细

BAPI_PRODORD_EXIST_CHECK                                                       确认检查性

BAPI_PRODORD_CREATE_FROM_REF                                           创建模板

BAPI_PRODORD_CREATE_FROM_PLORD                                     创建带有计划订单

BAPI_PRODORD_CREATE_CAP_REQ                                             产生能力需求

BAPI_PRODORD_CREATE                                                                 创建生产订单

BAPI_PRODORD_COSTING                                                               创建成本估计

BAPI_PRODORD_COMPLETE_TECH                                               完整的技术

BAPI_PRODORD_CLOSE                                                                   关闭订单

BAPI_PRODORD_CHECK_MAT_AVAIL                                             检查物料可用性

BAPI_PRODORD_CHANGE                                                                更改生产订单

Production order confirmation:(生产订单确认)

BAPI_PRODORDCONF_GET_TT_PROP                                           确认计工单

BAPI_PRODORDCONF_GET_TE_PROP                                           确认计工单

BAPI_PRODORDCONF_GETLIST                                                      生产订单确认

BAPI_PRODORDCONF_GETDETAIL                                                 生产订单确认详细信息

BAPI_PRODORDCONF_GET_HDR_PROP                                       确认计划订单

BAPI_PRODORDCONF_EXIST_CHK                                                 检查工单是否存在

BAPI_PRODORDCONF_CREATE_TT                                                确认计划工单

BAPI_PRODORDCONF_CREATE_TE                                                确认计划工单

BAPI_PRODORDCONF_PDC_UPLOAD_TT                                      PP 确认计工单

BAPI_PRODORDCONF_PDC_UPLOAD_TE                                      PP 确认计工单

BAPI_PRODORDCONF_CREATE_HDR                                            输入订单确认

BAPI_PRODORDCONF_CREATE_ACT                                             输入订单激活确认

BAPI_PRODORDCONF_CANCEL                                                      取消生产订单

BDC Download & Upload for production order: 下载和上传的BDC的生产订单

BAPI_RCVPRORDCF_RECEIVEPRODORD                                   PP-PDC: 下载生产订单

BAPI_RCVPRORDCF_RECEIVEWORKC                                        PP-PDC: 下载工作中心

BAPI_RCVPRODCF_REQUEST_CONF                                           PP-PDC: 上传请求

KANBAN: (看板)

BAPI_KANBAN_CHANGE                                                                  更改kanban数据

BAPI_KANBAN_CHANGESTATUS                                                    更改kanban状态

BAPI_KANBAN_CHANGESTATUS1                                                  更改kanban状态1

BAPI_KANBAN_GETLIST                                                                  匹配选择标准KANBAN的测定BAPI_KANBAN_GETLIST_ALL                                                         匹配选择标准KANBAN的测定

BAPI_KANBAN_GETLISTFORSUPPLIE1                                        匹配选择标准KANBAN的测定

BAPI_KANBAN_GETLISTFORSUPPLIER                                        为供应商提供kanban数据

BAPI_KANBAN_SETINPROCESS                                                    为供应商提供kanban数据

KANBAN CONTROL CYCLE: (看板)

BAPI_KANBANCC_ADDEVENTDRKANBAN                                     Create Event-Driven KANBAN for Control Cycle

BAPI_KANBANCC_CHANGE                                                            Change Control Cycle

BAPI_KANBANCC_CREATE                                                             Create Control Cycle

BAPI_KANBANCC_DELETE                                                             Delete Control Cycles

BAPI_KANBANCC_EXISTCHECK                                                    Check Existence of Control Cycle

BAPI_KANBANCC_GETLIST                                                             Determine Kanban Control Cycles with Selection Criteria

BAPI_KANBANCC_GETLIST_ALL                                                     Determine Kanban Control Cycles with Selection Criteria

BAPI_KANBANCC_WITHDRAWQUANTITY                                     Quantity Signal for Kanban Control Cycle

REM Confirmation: ( REM确认)

BAPI_REPMANCONF_CANCEL                                                       处理的重复制造取消

BAPI_REPMANCONF_CREATE_MTO                                             销售订单执行重复制造情况

BAPI_REPMANCONF_CREATE_PLOT                                           执行生产成本

BAPI_REPMANCONF_CREATE_MTS                                            在很多情况下,执行生产成本

BAPI_REPMANCONF_EXIST_CHK                                                检查对象存在

REM Confirmation1:

BAPI_REPMANCONF1_CANCEL                                                    处理的重复制造取消

BAPI_REPMANCONF1_CREATE_MTO                                          销售订单执行重复制造情况

BAPI_REPMANCONF1_CREATE_MTP                                           在很多情况下,执行生产成本

BAPI_REPMANCONF1_CREATE_MTS                                           在很多情况下,执行生产成本

BAPI_REPMANCONF1_EXIST_CHK                                               检查对象存在