METHOD zsd_ii_si_sales_order_cre_in~si_sales_order_cre_in.
*** **** INSERT IMPLEMENTATION HERE **** ***
DATA:
input_hd TYPE zmmi005_dt_mesg_hd,
input_body TYPE zsd_dt_sales_order_req_msg_tab,
input_body_item TYPE zsd_dt_sales_order_req_msgbd,
gt_hxm TYPE STANDARD TABLE OF zsd_dt_sales_order_req_ite_tab,
wa_hxm TYPE zsd_dt_sales_order_req_items,
gt_tx TYPE STANDARD TABLE OF zsd_dt_sales_order_req_cha_tab,
wa_tx TYPE zsd_dt_sales_order_req_charact,
gt_jg TYPE STANDARD TABLE OF zsd_dt_sales_order_req_pri_tab,
wa_jg TYPE zsd_dt_sales_order_req_pri_dat.
"response结构
DATA:
output_hd TYPE zmmi005_dt_mesg_hd,
output_body TYPE zsd_dt_sales_order_res_msg_tab,
output_body_item TYPE zsd_dt_sales_order_res_msgbd,
ogt_data TYPE zsd_dt_sales_order_res_dat_tab,
owa_data TYPE zsd_dt_sales_order_res_data,
ogt_item TYPE zsd_dt_sales_order_res_ite_tab,
owa_item TYPE zsd_dt_sales_order_res_item.
*创建销售订单bapi定义
-
data for bapi use
DATA: ls_create_header TYPE bapisdhd1, "抬头数据
lt_create_header TYPE TABLE OF bapisdhd1,ls_create_header_x TYPE bapisdhd1x, lt_create_header_x TYPE TABLE OF bapisdhd1x, ls_bapiflag_x TYPE bapiflag, ls_create_item TYPE bapisditm, "项目数据 lt_create_item TYPE TABLE OF bapisditm, ls_create_schedules TYPE bapischdl, lt_create_schedules TYPE TABLE OF bapischdl, ls_create_item_x TYPE bapisditmx, lt_create_item_x TYPE TABLE OF bapisditmx, ls_create_schedules_x TYPE bapischdlx, lt_create_schedules_x TYPE TABLE OF bapischdlx, ls_create_character TYPE bapicuval, "特性值 lt_create_character TYPE TABLE OF bapicuval, ls_create_conditions_in TYPE bapicond, "定价类型 ls_create_conditions_in2 TYPE bapicond, lt_create_conditions_in TYPE TABLE OF bapicond, ls_create_conditions_inx TYPE bapicondx, lt_create_conditions_inx TYPE TABLE OF bapicondx, ls_create_partner TYPE bapiparnr, "合作伙伴 lt_create_partner TYPE TABLE OF bapiparnr, ls_create_text TYPE bapisdtext, "文本 lt_create_text TYPE TABLE OF bapisdtext, ls_create_return TYPE bapiret2, lt_create_return TYPE TABLE OF bapiret2, ls_create_stat TYPE bapicucfg, lt_create_stat TYPE TABLE OF bapicucfg, ls_create_cfgsinst TYPE bapicuins, lt_create_cfgsinst TYPE TABLE OF bapicuins, ls_create_part_of TYPE bapicuprt, lt_create_part_of TYPE TABLE OF bapicuprt, ls_create_cfgsrefinst TYPE bapicuref, lt_create_cfgsrefinst TYPE TABLE OF bapicuref, ls_partneradchange TYPE bapiparnrc, lt_partneradchange TYPE TABLE OF bapiparnrc, ls_creat_part TYPE bapicuprt, lt_creat_part TYPE TABLE OF bapicuprt, ls_create_vk TYPE bapicuvk, lt_create_vk TYPE TABLE OF bapicuvk, l_create_vbeln TYPE bapivbeln-vbeln, "销售凭证号 ls_logic_switch TYPE bapisdls.
"修改bapi
DATA:ls_change_header TYPE bapisdh1, "抬头数据
lt_change_header TYPE TABLE OF bapisdh1,ls_change_header_x TYPE bapisdh1x, lt_change_header_x TYPE TABLE OF bapisdh1x.
"抬头文本
DATA: thead TYPE thead.
DATA it_line1 TYPE TABLE OF tline.
DATA:wa_line LIKE LINE OF it_line1.
DATA:your_text(512) TYPE c.
DATA: tt_vbeln TYPE vbeln."返回结构定义
TYPES: BEGIN OF ret_body,
vbeln TYPE vbeln, " 订单
posnr TYPE posnr, "行项目
netwr TYPE netwr, "净价值
mwsbp TYPE mwsbp, "税额kschl TYPE kschl, "条件类型 vtext TYPE vtext, "描述 kbetr TYPE kbetr. "条件金额
TYPES: END OF ret_body.
DATA : gt_ret TYPE STANDARD TABLE OF ret_body,
wa_ret TYPE ret_body.DATA : wa_ret_copy TYPE ret_body.
DATA l_vbeln TYPE vbeln. "记录删除订单号
DATA: ret_msg TYPE string, "记录错误信息
l_tabix TYPE sy-tabix,
num TYPE i. "统计内表条目数"拒绝原因
DATA: i_head TYPE bapisdh1,
i_headx TYPE bapisdh1x,
i_ret TYPE STANDARD TABLE OF bapiret2,
i_ret_wa TYPE bapiret2,
i_itm TYPE STANDARD TABLE OF bapisditm,
i_itm_wa TYPE bapisditm,
i_itmx_wa TYPE bapisditmx,
i_itmx TYPE STANDARD TABLE OF bapisditmx,t_schedule1 TYPE TABLE OF bapischdl, t_conditions TYPE TABLE OF bapicond.
"传老MES
DATA:mes_vbeln TYPE vbeln.
"卸货点修改20220426
DATA:lt_xvbadr TYPE TABLE OF sadrvb,
lt_xvbpa TYPE TABLE OF vbpavb,
lt_yvbadr TYPE TABLE OF sadrvb,
lt_yvbpa TYPE TABLE OF vbpavb."log
DATA: ls_output TYPE zun_mt_un_resp,
lw_output TYPE zun_dt_un_resp_msgbd."删除生产订单20220524
DATA:ls_pos_return TYPE bapiret2,
ls_aufnr TYPE bapi_order_key,
lt_aufnr TYPE TABLE OF bapi_order_key,
ls_detail TYPE bapi_order_return,
lt_detail TYPE TABLE OF bapi_order_return.
DATA: l_aufnr TYPE aufnr.
DATA: l_flag TYPE c.
" header和body
input_hd = input-mt_sales_order_req-msghd.
input_body = input-mt_sales_order_req-msgbd.
"反馈头信息
output_hd-msgid = input_hd-msgid.
output_hd-tlgid = input_hd-tlgid.
output_hd-tlgname = input_hd-tlgname.
output_hd-dtsend = sy-datum && sy-uzeit.
output_hd-sender = 'ERP'.
output_hd-receiver = input_hd-sender.
output-mt_sales_order_res-msghd = output_hd.
"校验是否有生产订单,是否生产
LOOP AT input_body INTO input_body_item.
l_vbeln = input_body_item-vbeln.
l_vbeln = |{ l_vbeln ALPHA = IN }|. "防止不带前0
LOOP AT input_body_item-items INTO wa_hxm.
"20220523新增校验行是否存在生产订单
IF wa_hxm-cancle_flg = 'D'.
SELECT SINGLE aufnr INTO l_aufnr FROM afpo WHERE kdauf = l_vbeln AND kdpos = wa_hxm-posnr.
IF sy-subrc = 0.
ls_aufnr-order_number = l_aufnr.
APPEND ls_aufnr TO lt_aufnr.
CALL FUNCTION 'BAPI_PRODORD_SET_DELETION_FLAG'
IMPORTING
return = ls_pos_return
TABLES
orders = lt_aufnr
detail_return = lt_detail.
LOOP AT lt_detail INTO ls_detail .
IF ls_detail-type = 'I'.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
"删除订单是否已生产
l_flag = 'X'.
output_body_item-vbeln = input_body_item-vbeln.
output_body_item-code = 'E'.
output_body_item-contract_no = input_body_item-contract_no.
output_body_item-msg = wa_hxm-posnr && '对应的生产订单' && l_aufnr && '已生产'.
APPEND output_body_item TO output_body.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
"有生产直接退出,不检查其他行。20220602
IF l_flag = 'X'.
EXIT.
ENDIF.
ENDLOOP.
ENDLOOP.
IF output_body IS INITIAL .
LOOP AT input_body INTO input_body_item.
l_vbeln = input_body_item-vbeln.
l_vbeln = |{ l_vbeln ALPHA = IN }|. "防止不带前0
IF input_body_item-cancle_flg = 'D'.
ls_change_header_x-updateflag = 'D'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = l_vbeln
order_header_inx = ls_change_header_x
TABLES
return = lt_create_return.
LOOP AT lt_create_return INTO ls_create_return WHERE type = 'E' OR type = 'A'.
CONCATENATE ret_msg ls_create_return-message INTO ret_msg SEPARATED BY '/'.
ENDLOOP.
IF ret_msg IS INITIAL .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
output_body_item-code = 'S'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
output_body_item-code = 'E'.
output_body_item-msg = ret_msg.
ENDIF.
"反馈体
output_body_item-contract_no = input_body_item-contract_no.
output_body_item-vbeln = input_body_item-vbeln.
APPEND output_body_item TO output_body.
-
IF l_tabix EQ num.
-
output-mt_pur_order_res-msgbd = output_body.
-
ENDIF. CLEAR: input_body_item,l_vbeln,output_body_item. CONTINUE. ENDIF.
删除订单结束***************
ls_create_header-doc_type = input_body_item-auart."销售凭证类型
ls_create_header-sales_org = input_body_item-vkorg."销售组织
ls_create_header-division = input_body_item-spart."产品组
ls_create_header-distr_chan = input_body_item-vtweg."分销渠道
ls_create_header-sales_off = input_body_item-vkbur."销售办公室
ls_create_header-sales_grp = input_body_item-vkgrp."销售组
ls_create_header-rec_point = input_body_item-empst."收货点
ls_create_header-doc_date = input_body_item-audat. "凭证日期
ls_create_header-price_date = input_body_item-prsdt."定价日期
ls_create_header-req_date_h = input_body_item-edatu."交货期
ls_create_header-created_by = input_body_item-ernam."创建人
ls_create_header-purch_no_c = input_body_item-bstkd."参考号
ls_create_header-ship_type = input_body_item-vsart."装运类型
ls_create_header-ord_reason = input_body_item-augru.
IF input_body_item-kunnr1 IS NOT INITIAL. "售达方
ls_create_partner-partn_role = 'AG'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = input_body_item-kunnr1
IMPORTING
output = ls_create_partner-partn_numb.
ls_create_partner-itm_number = '000000'.
APPEND ls_create_partner TO lt_create_partner.
CLEAR ls_create_partner.
ENDIF.
IF input_body_item-kunnr2 IS NOT INITIAL. "送达方
ls_create_partner-partn_role = 'WE'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = input_body_item-kunnr2
IMPORTING
output = ls_create_partner-partn_numb.
ls_create_partner-unload_pt = input_body_item-ablad. "卸货点
ls_create_partner-itm_number = '000000'.
APPEND ls_create_partner TO lt_create_partner.
CLEAR ls_create_partner.
IF input_body_item-cancle_flg = 'U'.
"修改
ls_partneradchange-document = l_vbeln.
ls_partneradchange-itm_number = '000000'.
ls_partneradchange-updateflag = 'U'.
ls_partneradchange-partn_role = 'WE'.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = input_body_item-kunnr2
IMPORTING
output = ls_partneradchange-p_numb_new.
-
ls_partneradchange-unload_pt = input_body_item-ablad. "卸货点 APPEND ls_partneradchange TO lt_partneradchange. CLEAR ls_partneradchange. ENDIF. ENDIF. "修改销售订单头信息 IF input_body_item-cancle_flg = 'U'. MOVE-CORRESPONDING ls_create_header TO ls_change_header. ls_change_header_x-updateflag = 'U'. ls_change_header_x-sales_org = 'X'."销售组织 ls_change_header_x-division = 'X'."产品组 ls_change_header_x-distr_chan = 'X'."分销渠道 ls_change_header_x-sales_off = 'X'."销售办公室 ls_change_header_x-sales_grp = 'X'."销售组 ls_change_header_x-rec_point = 'X'."收货点 ls_change_header_x-doc_date = 'X'. "凭证日期 ls_change_header_x-price_date = 'X'."定价日期 ls_change_header_x-req_date_h = 'X'."交货期 ls_change_header_x-purch_no_c = 'X'."参考号 ls_change_header_x-ship_type = 'X'."装运类型 ls_change_header_x-ord_reason = 'X'. ENDIF. CLEAR:ls_create_item. "行项目 SORT input_body_item-items BY posnr. LOOP AT input_body_item-items INTO wa_hxm.
-
"20220523新增校验行是否存在生产订单, 前期定义不满足现在需求 提前校验。
-
DATA: l_aufnr TYPE aufnr.
-
IF wa_hxm-cancle_flg = 'D'.
-
SELECT SINGLE aufnr INTO l_aufnr FROM afpo WHERE kdauf = l_vbeln AND kdpos = wa_hxm-posnr.
-
IF sy-subrc = 0.
-
ls_aufnr-order_number = l_aufnr.
-
APPEND ls_aufnr TO lt_aufnr.
-
CALL FUNCTION 'BAPI_PRODORD_SET_DELETION_FLAG'
-
IMPORTING
-
return = ls_pos_return
-
TABLES
-
orders = lt_aufnr
-
detail_return = lt_detail.
-
LOOP AT lt_detail INTO ls_detail .
-
IF ls_detail-type = 'I'.
-
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
-
EXPORTING
-
wait = 'X'.
-
ELSE.
-
DATA: str TYPE string.
-
CONCATENATE str ls_detail-message INTO str SEPARATED BY '/'.
-
ENDIF.
-
ENDLOOP.
-
ENDIF.
-
ENDIF. "行项目bapi CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT' EXPORTING input = wa_hxm-matnr IMPORTING output = wa_hxm-matnr. ls_create_item-itm_number = wa_hxm-posnr. " 行项目 ls_create_item-material = wa_hxm-matnr. "物料号 ls_create_item-batch = wa_hxm-charg. "批号 IF input_body_item-auart = 'ZDX1' OR input_body_item-auart = 'ZDX7' OR input_body_item-auart = 'ZJX1' OR input_body_item-auart = 'ZJX7' . ls_create_item-target_qty = wa_hxm-kwmeng. ENDIF. ls_create_item-bus_transt = wa_hxm-zyl-yl1. "业务事务类型 "新增带拒绝原因,先建单子后写原因。20220501 IF wa_hxm-abgru IS NOT INITIAL AND input_body_item-cancle_flg = 'I'. i_itm_wa-itm_number = wa_hxm-posnr. i_itm_wa-reason_rej = wa_hxm-abgru. i_itmx_wa-updateflag = 'U'. i_itmx_wa-itm_number = wa_hxm-posnr. i_itmx_wa-reason_rej = 'X'. APPEND i_itm_wa TO i_itm. APPEND i_itmx_wa TO i_itmx. ENDIF. "老单子新增行新增带拒绝原因,先建单子后写原因。20220507 IF wa_hxm-abgru IS NOT INITIAL AND input_body_item-cancle_flg = 'U' AND wa_hxm-cancle_flg = 'I'. i_itm_wa-itm_number = wa_hxm-posnr. i_itm_wa-reason_rej = wa_hxm-abgru. i_itmx_wa-updateflag = 'U'. i_itmx_wa-itm_number = wa_hxm-posnr. i_itmx_wa-reason_rej = 'X'. APPEND i_itm_wa TO i_itm. APPEND i_itmx_wa TO i_itmx. l_create_vbeln = l_vbeln. ENDIF. "清除拒绝原因。20220501 IF wa_hxm-cancle_flg = 'U'. IF wa_hxm-abgru IS INITIAL. ls_create_item-reason_rej = ''. ls_create_item_x-reason_rej = 'X'. ELSE. ls_create_item-reason_rej = wa_hxm-abgru. ls_create_item_x-reason_rej = 'X'. ENDIF. ENDIF. ls_create_item_x-itm_number = wa_hxm-posnr. " 行项目 ls_create_item_x-material = 'X'. "物料号 ls_create_item_x-batch = 'X'. ls_create_item_x-bus_transt = 'X'. IF ls_create_item-target_qty IS NOT INITIAL . ls_create_item_x-target_qty = 'X'. ENDIF. ls_create_item_x-updateflag = wa_hxm-cancle_flg. "交货计划行 IF wa_hxm-cancle_flg <> 'D' . IF input_body_item-auart <> 'ZDX1' AND input_body_item-auart <> 'ZDX7' AND input_body_item-auart <> 'ZJX1' AND input_body_item-auart <> 'ZJX7' . "删除不写计划行. ls_create_schedules-itm_number = wa_hxm-posnr. ls_create_schedules-req_date = wa_hxm-edatu . "计划行日期 ls_create_schedules-req_qty = wa_hxm-kwmeng. "订单数量 一会看下 ls_create_schedules-sched_line = 0001."计划行,需要查询以前的计 ls_create_schedules_x-itm_number = wa_hxm-posnr. "修改拒绝原因不允许输入数量 IF wa_hxm-kwmeng IS NOT INITIAL. ls_create_schedules_x-req_qty = 'X'. ENDIF. ls_create_schedules_x-updateflag = wa_hxm-cancle_flg. ls_create_schedules_x-sched_line = 0001."计划行,需要查询以前的计 APPEND: ls_create_schedules TO lt_create_schedules, ls_create_schedules_x TO lt_create_schedules_x. ENDIF. ENDIF.
"特性
LOOP AT wa_hxm-character INTO wa_tx.
ls_create_character-config_id = ls_create_item-itm_number.
ls_create_character-inst_id = ls_create_item-itm_number.
ls_create_character-charc = wa_tx-atnam.
IF wa_tx-atflv IS NOT INITIAL.
ls_create_character-value = wa_tx-atflv.
ls_create_character-value_to = wa_tx-atflb.
ls_create_character-valcode = wa_tx-atcod.
ELSE.
ls_create_character-value = wa_tx-atwrt.
ENDIF.
APPEND ls_create_character TO lt_create_character.
CLEAR ls_create_character.
ENDLOOP.
IF lt_create_character IS NOT INITIAL.
"配置参数
ls_create_stat-posex = ls_create_item-itm_number.
ls_create_stat-config_id = ls_create_item-itm_number.
ls_create_stat-root_id = ls_create_item-itm_number.
ls_create_item-po_itm_no = ls_create_stat-posex.
ls_create_item_x-po_itm_no = 'X'.
APPEND ls_create_stat TO lt_create_stat.
CLEAR:ls_create_stat.
ls_create_cfgsinst-config_id = ls_create_item-itm_number.
ls_create_cfgsinst-inst_id = ls_create_item-itm_number.
ls_create_cfgsinst-obj_type = 'MARA'.
ls_create_cfgsinst-class_type = '300'.
APPEND ls_create_cfgsinst TO lt_create_cfgsinst.
CLEAR: ls_create_cfgsinst.
ENDIF.
LOOP AT wa_hxm-pri_data INTO wa_jg.
***********"取价格条件的计数器,考虑后期多价格
IF input_body_item-cancle_flg = ‘U’.
SELECT kposn, stunr, zaehk ,kschl
INTO TABLE @DATA(lt_konv)
FROM vbak
INNER JOIN konv
ON vbak~knumv = konv~knumv
WHERE vbak~vbeln = @l_vbeln.
-
SORT lt_konv BY kposn stunr zaehk. READ TABLE lt_konv INTO DATA(ls_knv) WITH KEY kposn = wa_hxm-posnr kschl = wa_jg-kschl . IF sy-subrc = 0. ls_create_conditions_in-cond_st_no = ls_knv-stunr. ls_create_conditions_in-cond_count = ls_knv-zaehk. ls_create_conditions_inx-cond_st_no = ls_knv-stunr. ls_create_conditions_inx-cond_count = ls_knv-zaehk. ENDIF. ENDIF.
***********"取价格条件的计数器
-
"条件价格 ls_create_conditions_in-itm_number = wa_hxm-posnr. ls_create_conditions_in-cond_value = wa_jg-kbetr1. "价格( 条件金额或百分数 ) ls_create_conditions_in-cond_type = wa_jg-kschl. "条件类型 ls_create_conditions_in-currency = 'RMB'. ls_create_conditions_inx-itm_number = wa_hxm-posnr. ls_create_conditions_inx-cond_value = 'X'. "价格( 条件金额或百分数 ) ls_create_conditions_inx-cond_type = wa_jg-kschl. "条件类型 ls_create_conditions_inx-currency = 'X'. ls_create_conditions_inx-updateflag = wa_hxm-cancle_flg. APPEND:ls_create_conditions_in TO lt_create_conditions_in, ls_create_conditions_inx TO lt_create_conditions_inx. CLEAR: ls_create_conditions_in, ls_create_conditions_inx. ENDLOOP. APPEND: ls_create_item_x TO lt_create_item_x, ls_create_item TO lt_create_item.
-
ls_create_schedules TO lt_create_schedules,
-
ls_create_schedules_x TO lt_create_schedules_x.
-
ls_create_conditions_in TO lt_create_conditions_in,
-
ls_create_conditions_inx TO lt_create_conditions_inx. CLEAR: ls_create_item_x,ls_create_item,ls_create_schedules, ls_create_schedules_x, ls_create_conditions_in, ls_create_conditions_inx. ENDLOOP. LOOP AT input_body_item-items TRANSPORTING NO FIELDS WHERE abgru <> '' AND cancle_flg = 'I'. "特批订单,不检查信贷 EXIT. ENDLOOP. IF sy-subrc = 0. t_conditions = lt_create_conditions_in. t_schedule1 = lt_create_schedules. REFRESH: lt_create_conditions_in,lt_create_schedules. ENDIF. "新增 IF input_body_item-cancle_flg = 'I'.
-
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
-
EXPORTING
-
order_header_in = ls_create_header
-
logic_switch = ls_logic_switch
-
IMPORTING
-
salesdocument = l_create_vbeln
-
TABLES
-
return = lt_create_return
-
order_items_in = lt_create_item
-
order_partners = lt_create_partner
-
order_schedules_in = lt_create_schedules
-
order_conditions_in = lt_create_conditions_in
-
order_cfgs_ref = lt_create_stat
-
order_cfgs_inst = lt_create_cfgsinst
-
order_cfgs_value = lt_create_character. CALL FUNCTION 'SD_SALESDOCUMENT_CREATE' EXPORTING sales_header_in = ls_create_header
-
sales_header_inx = ls_create_header_x logic_switch = ls_logic_switch IMPORTING salesdocument_ex = l_create_vbeln TABLES return = lt_create_return sales_items_in = lt_create_item
-
sales_items_inx = lt_create_item_x sales_partners = lt_create_partner sales_schedules_in = lt_create_schedules sales_schedules_inx = lt_create_schedules_x sales_conditions_in = lt_create_conditions_in
-
sales_conditions_inx = lt_create_conditions_inx sales_cfgs_ref = lt_create_stat sales_cfgs_inst = lt_create_cfgsinst sales_cfgs_value = lt_create_character. ENDIF. "修改 IF input_body_item-cancle_flg = 'U'. CALL FUNCTION 'BAPI_SALESORDER_CHANGE' EXPORTING salesdocument = l_vbeln order_header_in = ls_change_header order_header_inx = ls_change_header_x
-
SIMULATION =
-
BEHAVE_WHEN_ERROR = ' '
-
INT_NUMBER_ASSIGNMENT = ' ' logic_switch = ls_logic_switch
-
NO_STATUS_BUF_INIT = ' ' TABLES return = lt_create_return order_item_in = lt_create_item order_item_inx = lt_create_item_x
-
partners = lt_create_partner partnerchanges = lt_partneradchange
-
PARTNERADDRESSES = order_cfgs_ref = lt_create_stat order_cfgs_inst = lt_create_cfgsinst
-
ORDER_CFGS_PART_OF = order_cfgs_value = lt_create_character
-
ORDER_CFGS_BLOB =
-
ORDER_CFGS_VK =
-
ORDER_CFGS_REFINST = schedule_lines = lt_create_schedules schedule_linesx = lt_create_schedules_x
-
ORDER_TEXT =
-
ORDER_KEYS = conditions_in = lt_create_conditions_in conditions_inx = lt_create_conditions_inx
-
EXTENSIONIN =
-
EXTENSIONEX =
-
NFMETALLITMS = . ENDIF. LOOP AT lt_create_return INTO ls_create_return WHERE type = 'E' OR type = 'A'. CONCATENATE ret_msg ls_create_return-message INTO ret_msg SEPARATED BY '/'. ENDLOOP. IF ret_msg IS INITIAL . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'.
修改卸货点20220426cy*****
IF input_body_item-cancle_flg = ‘U’ ."AND input_body_item-ablad is NOT INITIAL. w为空?
CALL FUNCTION ‘SD_PARTNER_READ’
EXPORTING
f_vbeln = l_vbeln
-
OBJECT = 'VBPA'
-
NO_MASTER_ADRESS = ' '
-
IV_NO_INIT = ' '
-
IV_PARVW =
-
IV_POSNR = TABLES i_xvbadr = lt_xvbadr i_xvbpa = lt_xvbpa i_yvbadr = lt_yvbadr i_yvbpa = lt_yvbpa
-
I_XVBPA2 =
-
I_YVBPA2 = . LOOP AT lt_xvbpa ASSIGNING FIELD-SYMBOL(<fs>) WHERE vbeln = l_vbeln AND parvw = 'WE'. <fs>-ablad = input_body_item-ablad. "卸货点 <fs>-updkz = 'U'.
-
<fs>-kunnr = l_kunnr. ENDLOOP. CALL FUNCTION 'SD_PARTNER_UPDATE' EXPORTING f_vbeln = l_vbeln
-
OBJECT = 'VBPA' TABLES i_xvbadr = lt_xvbadr i_xvbpa = lt_xvbpa i_yvbadr = lt_yvbadr i_yvbpa = lt_yvbpa
-
I_XVBPA2 =
-
I_YVBPA2 = . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF.
修改卸货点20220426cy*
"销售订单行项目拒绝原因 。
IF i_itm[] IS NOT INITIAL.
CLEAR i_ret_wa.
i_head-sd_doc_cat = 'C'.
i_headx-updateflag = 'U'.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = l_create_vbeln
order_header_in = i_head
order_header_inx = i_headx
-
logic_switch = l_switch
-
behave_when_error = 'P' TABLES return = i_ret order_item_in = i_itm order_item_inx = i_itmx schedule_lines = t_schedule1
-
schedule_linesx = t_schedulex conditions_in = t_conditions.
-
conditions_inx = t_conditionsx. . LOOP AT i_ret INTO i_ret_wa WHERE type = 'E' OR type = 'A'. CONCATENATE ret_msg i_ret_wa-message INTO ret_msg SEPARATED BY '/'. ENDLOOP. IF ret_msg IS INITIAL . CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ELSE. output_body_item-vbeln = input_body_item-vbeln. output_body_item-code = 'E'. "反馈体 output_body_item-contract_no = input_body_item-contract_no. output_body_item-msg = ret_msg. APPEND output_body_item TO output_body. EXIT. ENDIF. ENDIF.
*********************新增需求销售组织2001,产品组08”时订单传老MES一份20220420。
CASE input_body_item-cancle_flg.
WHEN 'U'.
mes_vbeln = l_vbeln.
WHEN 'I'.
mes_vbeln = l_create_vbeln.
WHEN OTHERS.
ENDCASE.
IF mes_vbeln IS NOT INITIAL AND ( input_body_item-vkorg = '2105' OR input_body_item-vkorg = '2106').
SUBMIT zsdi_sodown WITH s_vbeln = mes_vbeln
AND RETURN .
CLEAR mes_vbeln.
ENDIF.
新增需求销售组织2001,产品组08”时订单传老MES一份20220420***********
"查询反馈信息
SELECT a~vbeln
a~netwr
b~posnr
b~mwsbp
c~kschl
-
c~vtext c~kbetr INTO CORRESPONDING FIELDS OF TABLE gt_ret FROM vbak AS a INNER JOIN vbap AS b ON a~vbeln = b~vbeln INNER JOIN konv AS c ON a~knumv = c~knumv WHERE ( a~vbeln = l_create_vbeln OR a~vbeln = l_vbeln ) AND b~posnr = c~kposn. SORT gt_ret BY vbeln posnr. "组装反馈结构 LOOP AT gt_ret INTO wa_ret. owa_item-kschl = wa_ret-kschl. "条件类型 owa_item-kbetr = wa_ret-kbetr. "金额 SELECT SINGLE vtext INTO owa_item-vtext FROM t685t WHERE spras = '1' AND kschl = owa_item-kschl. APPEND owa_item TO ogt_item. CLEAR: owa_item. wa_ret_copy = wa_ret. "at end of 把数据变* 需要复制 AT END OF posnr. owa_data-posnr = wa_ret_copy-posnr. owa_data-netwr = wa_ret_copy-netwr. owa_data-mwsbp = wa_ret_copy-mwsbp. owa_data-item = ogt_item. APPEND owa_data TO ogt_data. CLEAR: owa_data,ogt_item . ENDAT. CLEAR: wa_ret,wa_ret_copy. ENDLOOP. "抬头文本 IF input_body_item-cancle_flg = 'U' OR input_body_item-cancle_flg = 'I'. IF input_body_item-cancle_flg = 'I'. tt_vbeln = l_create_vbeln. ELSE. tt_vbeln = input_body_item-vbeln. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = tt_vbeln IMPORTING output = tt_vbeln. ENDIF. your_text = input_body_item-ztext . wa_line-tdline = your_text. APPEND wa_line TO it_line1. thead-tdobject = 'VBBK'. thead-tdid = '0002'. thead-tdspras = sy-langu. thead-tdname = tt_vbeln. CALL FUNCTION 'SAVE_TEXT' EXPORTING header = thead savemode_direct = 'X' TABLES lines = it_line1 EXCEPTIONS id = 1 language = 2 name = 3 object = 4 OTHERS = 5. IF sy-subrc = 0. COMMIT WORK. ENDIF. ENDIF. "成功反馈体 IF input_body_item-cancle_flg = 'U'. output_body_item-vbeln = input_body_item-vbeln. ELSE. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT' EXPORTING input = l_create_vbeln IMPORTING output = l_create_vbeln. output_body_item-vbeln = l_create_vbeln. ENDIF. output_body_item-code = 'S'. output_body_item-data = ogt_data. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. output_body_item-vbeln = input_body_item-vbeln. output_body_item-code = 'E'. ENDIF. "反馈体 output_body_item-contract_no = input_body_item-contract_no. output_body_item-msg = ret_msg. APPEND output_body_item TO output_body. CLEAR: ls_create_header, ls_create_header_x,l_create_vbeln,lt_create_return,lt_create_item,lt_create_item_x,lt_create_partner, lt_create_schedules,lt_create_schedules_x,lt_create_conditions_in,lt_create_conditions_inx,lt_create_stat,lt_create_cfgsinst,lt_create_character,lt_create_text, ls_change_header,ls_change_header_x ,l_vbeln. ENDLOOP.
ENDIF.
output-mt_sales_order_res-msgbd = output_body.
ls_output-mt_un_resp-msghd = input-mt_sales_order_req-msghd.
LOOP AT output_body INTO DATA(log) .
lw_output-itemid = log-contract_no.
lw_output-order1 = log-vbeln.
lw_output-retid = log-code.
lw_output-rettxt = log-msg.
APPEND lw_output TO ls_output-mt_un_resp-msgbd.
CLEAR:lw_output.
ENDLOOP.
CALL FUNCTION ‘ZFUN_PO_LOG’
EXPORTING
output1 = ls_output. -
output2 = out.
ENDMETHOD.