DATA:
lt_stru_proj_define TYPE TABLE OF bapi_bus2001_new,
wa_stru_proj_define TYPE bapi_bus2001_new,
lt_message TYPE TABLE OF bapiret2,
wa_message TYPE bapiret2.
DATA:
gs_proj_bus2001_chg TYPE bapi_bus2001_chg,
gs_proj_bus2001_upd TYPE bapi_bus2001_upd.
DATA: pro TYPE bapi_bus2001_new-project_definition.
DATA: lt_msgxg TYPE TABLE OF bapiret2,
wa_msgxg TYPE bapiret2.
"返回接口参数
DATA: lo_output TYPE REF TO zun_co_si_un_resp_out,
ls_output TYPE zun_mt_un_resp,
ls_output_hd TYPE zmmi005_dt_mesg_hd,
lt_output_bd TYPE zun_dt_un_resp_msgbd_tab,
ls_output_bd TYPE zun_dt_un_resp_msgbd.
DATA: ls_lx TYPE zpslx,
lt_lx TYPE STANDARD TABLE OF zpslx.
"WBS新增
DATA: ld_project_definition TYPE bapi_bus2001_new-project_definition, "项目定义,要挂在哪个项目上
"定义WBS详情
it_bapi_bus2054_new TYPE STANDARD TABLE OF bapi_bus2054_new,
wa_bapi_bus2054_new TYPE bapi_bus2054_new,
"定义返回参数
it_bapiretwbs TYPE STANDARD TABLE OF bapiret2,
wa_bapiretwbs TYPE bapiret2.
"WBS修改
DATA:
ld_i_project_definition TYPE bapi_bus2001_new-project_definition,
"要更新的WBS信息
wa_e_project_wbs_chg TYPE bapi_bus2054_chg,
lt_e_project_wbs_chg TYPE STANDARD TABLE OF bapi_bus2054_chg,
"要更新那些WBS字段
wa_e_project_wbs_upd TYPE bapi_bus2054_upd,
lt_e_project_wbs_upd TYPE STANDARD TABLE OF bapi_bus2054_upd.
LOOP AT input-mt_ps_xmlx-msgbd INTO DATA(ls_input).
IF ls_input-zflag <> 'D'.
"校验
IF ls_input-pspid IS INITIAL.
"错误反馈
ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid.
ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 工程编号 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-pspid IS NOT INITIAL AND strlen( ls_input-pspid ) <> 11. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '项目定义不符合编码规范'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-zflag IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 工程编号维护标记 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-vbukr IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 公司代码 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-vgsbr IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 业务范围 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-vkokr IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 成本控制范围 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. IF ls_input-werks IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 工厂 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. ELSE. "校验 IF ls_input-pspid IS INITIAL. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = '关键字段 工程编号 不能为空'. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CONTINUE. ENDIF. ENDIF. "写入自建表 ls_lx-pspid = ls_input-pspid. ls_lx-post1 = ls_input-post1. ls_lx-zflag = ls_input-zflag. ls_lx-vbukr = ls_input-vbukr. ls_lx-vgsbr = ls_input-vgsbr. ls_lx-vkokr = ls_input-vkokr. ls_lx-prctr = ls_input-prctr. ls_lx-werks = ls_input-werks.
ls_lx-zsapjsdat = sy-datum .
ls_lx-zsapjstim = sy-uzeit. SELECT SINGLE profidproj INTO ls_lx-profidproj FROM tcj41 WHERE prart = ls_input-pspid+0(2) AND bukrs = ls_input-vbukr. MODIFY zpslx FROM ls_lx. COMMIT WORK. IF ls_input-zflag = 'I'. wa_stru_proj_define-project_definition = ls_input-pspid. "id wa_stru_proj_define-description = ls_input-post1. "描述 wa_stru_proj_define-company_code = ls_input-vbukr. "公司编码 wa_stru_proj_define-business_area = ls_input-vgsbr . "业务范围 wa_stru_proj_define-controlling_area = ls_input-vkokr. "成本控制范围 wa_stru_proj_define-project_profile = ls_lx-profidproj. "参数文件 wa_stru_proj_define-plant = ls_input-werks. "工厂
-
wa_stru_proj_define-profit_ctr = ls_input-prctr . "利润中心
-
wa_stru_proj_define-start = '20221001' . "开始时间
-
wa_stru_proj_define-finish = '20221002' . "结束时间
-
wa_stru_proj_define-responsible_no = '20002006' . "负责人 "第三步,调用创建 CALL FUNCTION 'BAPI_PS_INITIALIZATION'. CALL FUNCTION 'BAPI_BUS2001_CREATE' EXPORTING i_project_definition = wa_stru_proj_define TABLES et_return = lt_message
-
EXTENSIONIN =
-
EXTENSIONOUT = . "第四步,做预提交,判断消息是否有A或者E的,表示是异常 LOOP AT lt_message INTO wa_message WHERE type CA 'AE'. MESSAGE ID wa_message-id TYPE wa_message-type NUMBER wa_message-number INTO wa_message-message WITH wa_message-message_v1 wa_message-message_v2 wa_message-message_v3 wa_message-message_v4. ENDLOOP. "如果loop循环中遍历到A或者E的消息,则subrc是0,执行函数,重新初始化,然后下面check后的subrc,就自动退出主程序了 IF sy-subrc EQ 0. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_message-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_message-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag. COMMIT WORK . ENDIF. "如果subrc是非0,表示未检查到loop循环有A或者E的消息,则执行下面函数来做预提交 CHECK sy-subrc NE 0. CALL FUNCTION 'BAPI_PS_PRECOMMIT' TABLES et_return = lt_message. "第五步,正式提交 LOOP AT lt_message INTO wa_message WHERE type CA 'AE'. MESSAGE ID wa_message-id TYPE wa_message-type NUMBER wa_message-number INTO wa_message-message WITH wa_message-message_v1 wa_message-message_v2 wa_message-message_v3 wa_message-message_v4. ENDLOOP. "同理,如果预提交后,有A或者E的消息则做回滚,否则做正式提交 IF sy-subrc EQ 0. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_message-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
-
IMPORTING
-
return = lt_message . CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_message-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = wa_message.
-
项目定义创建成功
CLEAR:wa_message. READ TABLE lt_message INTO wa_message WITH KEY type = 'S'. MESSAGE ID wa_message-id TYPE wa_message-type NUMBER wa_message-number INTO wa_message-message WITH wa_message-message_v1 wa_message-message_v2 wa_message-message_v3 wa_message-message_v4.
*************************** "创建成功加一层WBS???******************************
"项目定义
ld_project_definition = ls_input-pspid.
"WBS
wa_bapi_bus2054_new-wbs_element = ls_input-pspid. "工作分解结构元素 (WBS 元素)
wa_bapi_bus2054_new-description = ls_input-post1. "PS: 短描述 (第一行文本)
-
wa_bapi_bus2054_new-responsible_no = ''. "负责人编号
-
wa_bapi_bus2054_new-statistical = ''. "统计
-
wa_bapi_bus2054_new-wbs_cctr_posted_actual = ''. "CCtr 过账 APPEND wa_bapi_bus2054_new TO it_bapi_bus2054_new. "第三步:调用函数 CALL FUNCTION 'BAPI_PS_INITIALIZATION'. CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI' EXPORTING i_project_definition = ld_project_definition TABLES it_wbs_element = it_bapi_bus2054_new et_return = it_bapiretwbs. "第四步:判断是否有错误消息 LOOP AT it_bapiretwbs INTO wa_bapiretwbs WHERE type CA 'AE'. MESSAGE ID wa_bapiretwbs-id TYPE wa_bapiretwbs-type NUMBER wa_bapiretwbs-number INTO wa_bapiretwbs-message WITH wa_bapiretwbs-message_v1 wa_bapiretwbs-message_v2 wa_bapiretwbs-message_v3 wa_bapiretwbs-message_v4.
-
WRITE:/ '创建时报错:',wa_bapiret2-message. ENDLOOP. "第四步:如果有错误消息则退出 IF sy-subrc EQ 0. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. ENDIF. CHECK sy-subrc NE 0. "第四步:没有错误消息则执行预提交 CALL FUNCTION 'BAPI_PS_PRECOMMIT' TABLES et_return = it_bapiretwbs. LOOP AT it_bapiretwbs INTO wa_bapiretwbs WHERE type CA 'AE'. MESSAGE ID wa_bapiretwbs-id TYPE wa_bapiretwbs-type NUMBER wa_bapiretwbs-number INTO wa_bapiretwbs-message WITH wa_bapiretwbs-message_v1 wa_bapiretwbs-message_v2 wa_bapiretwbs-message_v3 wa_bapiretwbs-message_v4.
-
WRITE:/ '预提交时报错:',wa_bapiret2-message. ENDLOOP. "第五步:预提交有错误消息则执行回滚 IF sy-subrc EQ 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
-
IMPORTING
-
return = it_bapiretwbs. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. ELSE. "第五步:预提交无错误消息则执行正式提交 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'
-
IMPORTING
-
return = wa_bapiretwbs .
-
WRITE:/ 'WBS创建成功:',wa_bapiretwbs-message.
-
WBS元素创建成功
ENDIF.
wbs结束*****
ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid.
ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. IF wa_bapiretwbs-message IS NOT INITIAL . ls_output_bd-rettxt = wa_message-message && 'WBS:' && wa_bapiretwbs-message. ELSE. ls_output_bd-rettxt = wa_message-message. ENDIF. ls_output_bd-retid = '1'. APPEND ls_output_bd TO lt_output_bd. UPDATE zpslx SET zzt = '1' zfkzt = '1' zfgtxt = wa_message-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ENDIF. ENDIF. IF ls_input-zflag = 'U'.
-
wa_stru_proj_define-controlling_area = ls_input-vkokr. "成本控制范围 gs_proj_bus2001_chg-project_definition = ls_input-pspid. "项目编号 gs_proj_bus2001_chg-description = ls_input-post1. "PS: 短描述 (第一行文本) gs_proj_bus2001_chg-business_area = ls_input-vgsbr . "业务范围 gs_proj_bus2001_chg-company_code = ls_input-vbukr. "项目的公司代码 gs_proj_bus2001_chg-profit_ctr = ls_input-prctr. "利润中心 gs_proj_bus2001_chg-plant = ls_input-werks. "工厂
-
gs_proj_bus2001_chg-responsible_no = p_char11. "负责人编号 - 负责人姓名
-
gs_proj_bus2001_chg-start = p_char8. "开始日期
-
gs_proj_bus2001_chg-finish = p_char9. "完成日期 IF ls_input-post1 IS NOT INITIAL . gs_proj_bus2001_upd-description = 'X'. ENDIF.
-
gs_proj_bus2001_upd-responsible_no = 'X'. IF ls_input-vgsbr IS NOT INITIAL. gs_proj_bus2001_upd-business_area = 'X'. ENDIF. IF ls_input-vbukr IS NOT INITIAL. gs_proj_bus2001_upd-company_code = 'X'. ENDIF. IF gs_proj_bus2001_chg-profit_ctr IS NOT INITIAL. gs_proj_bus2001_upd-profit_ctr = 'X'. ENDIF. IF ls_input-werks IS NOT INITIAL . gs_proj_bus2001_upd-plant = 'X'. ENDIF.
-
gs_proj_bus2001_upd-start = 'X'.
-
gs_proj_bus2001_upd-finish = 'X'. CALL FUNCTION 'BAPI_PS_INITIALIZATION'. CALL FUNCTION 'BAPI_BUS2001_CHANGE' EXPORTING i_project_definition = gs_proj_bus2001_chg i_project_definition_upd = gs_proj_bus2001_upd TABLES et_return = lt_msgxg. LOOP AT lt_msgxg INTO wa_msgxg WHERE type CA 'AE'. MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4. ENDLOOP. IF sy-subrc EQ 0. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_msgxg-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ENDIF. CHECK sy-subrc NE 0. CALL FUNCTION 'BAPI_PS_PRECOMMIT' TABLES et_return = lt_msgxg. LOOP AT lt_msgxg INTO wa_msgxg WHERE type CA 'AE'.
-
ls_return-status = gcon_err.
MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4.
-
APPEND ls_return TO et_return.
ENDLOOP.
IF sy-subrc EQ 0.
"错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_msgxg-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
-
IMPORTING
-
return = lt_msgxg. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. CLEAR:wa_msgxg. READ TABLE lt_msgxg INTO wa_msgxg WITH KEY type = 'S'. MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4.
*************************************由于增加一层wbs,需增加修改wbs
-
it_bapiretwbs TYPE STANDARD TABLE OF bapiret2,
-
wa_bapiretwbs TYPE bapiret2. ld_i_project_definition = ls_input-pspid. . "MOVE-CORRESPONDING wa_e_project_wbs to wa_e_project_wbs_chg."通过查询的WBS拷贝变量 wa_e_project_wbs_chg-wbs_element = ls_input-pspid. . wa_e_project_wbs_chg-description = ls_input-post1."更改描述 "设置更新标志 wa_e_project_wbs_upd-wbs_element = wa_e_project_wbs_chg-wbs_element. wa_e_project_wbs_upd-description = 'X'. APPEND wa_e_project_wbs_chg TO lt_e_project_wbs_chg. APPEND wa_e_project_wbs_upd TO lt_e_project_wbs_upd. "第三步,调用 CALL FUNCTION 'BAPI_PS_INITIALIZATION'. CALL FUNCTION 'BAPI_BUS2054_CHANGE_MULTI' EXPORTING i_project_definition = ld_i_project_definition TABLES it_wbs_element = lt_e_project_wbs_chg it_update_wbs_element = lt_e_project_wbs_upd et_return = it_bapiretwbs
-
EXTENSIONIN =
-
EXTENSIONOUT = . "第四步:判断是否有错误消息 LOOP AT it_bapiretwbs INTO wa_bapiretwbs WHERE type CA 'AE'. MESSAGE ID wa_bapiretwbs-id TYPE wa_bapiretwbs-type NUMBER wa_bapiretwbs-number INTO wa_bapiretwbs-message WITH wa_bapiretwbs-message_v1 wa_bapiretwbs-message_v2 wa_bapiretwbs-message_v3 wa_bapiretwbs-message_v4.
-
WRITE:/ '修改时报错:',wa_bapiret2-message. ENDLOOP. "第四步:如果有错误消息则退出 IF sy-subrc EQ 0. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. ENDIF. CHECK sy-subrc NE 0. "第四步:没有错误消息则执行预提交 CALL FUNCTION 'BAPI_PS_PRECOMMIT' TABLES et_return = it_bapiretwbs. LOOP AT it_bapiretwbs INTO wa_bapiretwbs WHERE type CA 'AE'. MESSAGE ID wa_bapiretwbs-id TYPE wa_bapiretwbs-type NUMBER wa_bapiretwbs-number INTO wa_bapiretwbs-message WITH wa_bapiretwbs-message_v1 wa_bapiretwbs-message_v2 wa_bapiretwbs-message_v3 wa_bapiretwbs-message_v4.
-
WRITE:/ '预提交时报错:',wa_bapiret3-message. ENDLOOP. "第五步:预提交有错误消息则执行回滚 IF sy-subrc EQ 0. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
-
IMPORTING
-
return = it_bapiretwbs. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. ELSE. "第五步:预提交无错误消息则执行正式提交 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X' IMPORTING return = wa_bapiretwbs.
-
WRITE:/ 'WBS修改成功:',wa_bapiret3-message. ENDIF.
修改wbs结束*********8
ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid.
ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. IF wa_bapiretwbs-message IS NOT INITIAL . ls_output_bd-rettxt = wa_message-message && 'WBS:' && wa_bapiretwbs-message. ELSE. ls_output_bd-rettxt = wa_message-message. ENDIF. ls_output_bd-retid = '1'. APPEND ls_output_bd TO lt_output_bd. UPDATE zpslx SET zzt = '1' zfkzt = '1' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ENDIF. ENDIF. IF ls_input-zflag = 'D'. ld_i_project_definition = ls_input-pspid. CALL FUNCTION 'BAPI_PS_INITIALIZATION'. CALL FUNCTION 'BAPI_BUS2001_DELETE' EXPORTING i_project_definition = ld_i_project_definition TABLES et_return = lt_msgxg
-
EXTENSIONIN =
-
EXTENSIONOUT = . LOOP AT lt_msgxg INTO wa_msgxg WHERE type CA 'AE'. MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4. ENDLOOP. IF sy-subrc EQ 0. "错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_msgxg-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ENDIF. CHECK sy-subrc NE 0. CALL FUNCTION 'BAPI_PS_PRECOMMIT' TABLES et_return = lt_msgxg. LOOP AT lt_msgxg INTO wa_msgxg WHERE type CA 'AE'.
-
ls_return-status = gcon_err.
MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4.
-
APPEND ls_return TO et_return.
ENDLOOP.
IF sy-subrc EQ 0.
"错误反馈 ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_msgxg-message. ls_output_bd-retid = '0'. APPEND ls_output_bd TO lt_output_bd. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
-
IMPORTING
-
return = lt_msgxg. CALL FUNCTION 'PS_FLAG_INIT_GLOBAL_FLAGS'. CALL FUNCTION 'PS_FLAG_SET_GLOBAL_FLAGS' EXPORTING i_precommit_ok = 'Y'. UPDATE zpslx SET zzt = '1' zfkzt = '0' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag.. COMMIT WORK. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. CLEAR:wa_msgxg. READ TABLE lt_msgxg INTO wa_msgxg WITH KEY type = 'S'. MESSAGE ID wa_msgxg-id TYPE wa_msgxg-type NUMBER wa_msgxg-number INTO wa_msgxg-message WITH wa_msgxg-message_v1 wa_msgxg-message_v2 wa_msgxg-message_v3 wa_msgxg-message_v4. ls_output_bd-msgid = input-mt_ps_xmlx-msghd-msgid. ls_output_bd-itemid = ls_input-itemid.
-
ls_output_bd-order1 = ls_body-anln1. ls_output_bd-rettxt = wa_msgxg-message. ls_output_bd-retid = '1'. APPEND ls_output_bd TO lt_output_bd. UPDATE zpslx SET zzt = '1' zfkzt = '1' zfgtxt = wa_msgxg-message WHERE pspid = ls_lx-pspid AND zflag = ls_lx-zflag. COMMIT WORK. ENDIF. ENDIF. CLEAR: ls_output_bd ,wa_message.
ENDLOOP.
"反馈头信息
ls_output_hd-msgid = input-mt_ps_xmlx-msghd-msgid.
ls_output_hd-tlgid = input-mt_ps_xmlx-msghd-tlgid.
ls_output_hd-tlgname = input-mt_ps_xmlx-msghd-tlgname.
ls_output_hd-dtsend = sy-datum && sy-uzeit.
ls_output_hd-sender = ‘ERP’.
ls_output_hd-receiver = input-mt_ps_xmlx-msghd-sender.
ls_output-mt_un_resp-msghd = ls_output_hd.
ls_output-mt_un_resp-msgbd = lt_output_bd.
"调用返回接口,同时获取发送数据的xml消息id.
TRY .
CREATE OBJECT lo_output. CALL METHOD lo_output->si_un_resp_out EXPORTING output = ls_output. COMMIT WORK AND WAIT. CALL FUNCTION 'ZFUN_PO_LOG' EXPORTING output1 = ls_output
-
output2 = out. . CATCH cx_ai_system_fault.
ENDTRY.
ENDMETHOD.