2021-09-18

詹书杰 | Zhan Shu Jie
流程与信息技术部 | BP&IT
发件人: Li Dun LiDun@catl.com
发送时间: 2021年9月18日 11:50
收件人: Zhan ShuJie(BP&IT) ZhanSJ@catl.com
主题: 代码内容

FUNCTION zoa_statu_change_new.
*"----------------------------------------------------------------------
"“本地接口:
*” IMPORTING
*" VALUE(I_ZAPPRREC) TYPE ZAPPRREC
*" EXPORTING
*" VALUE(E_ZACK) TYPE ZZACKNOW
*"----------------------------------------------------------------------
&-----------------------------------------------------------------
*& 程序名 : ZOA_STATU_CHANGE *
&-----------------------------------------------------------------
*& 抬头 : 提供给OA的RFC用于更新审批节点 *
*& 模块 : CA *
*& 作者 : XXXXX *
*& 业务顾问 : XXXXX *
*& 创建日期 : XXXX-XX-XX *
*& 程序类型 : RFC接口 *
CRM系统CR3K
CRM系统CR3K

*& 消息类 : *
*& 描述 : *
*& *
&----------------------------------------------------------------------------------------
*& 修改记录 : *
&----------------------------------------------------------------------------------------
*& 日期 修改人 请求号 业务顾问 修改内容 *
*& 2020-11-12 Jacky.Li EC3K908153 柳熊凯 OA流程改造:采购订单审批流程改造V1.0
&----------------------------------------------------------------------------------------
DATA:c_zapprrec TYPE zapprrec,"审核记录表
lw_zapprrec TYPE zapprrec.
DATA:ls_oaflow TYPE zoaflow_append,
c_zapprrec_h TYPE zapprrec_h."审核记录历史
DATA:e_fag TYPE char1,
e_msg TYPE string.
DATA:lv_guid TYPE guid_32.
e_zack-zzintty = ‘IDSTAT’.
e_zack-zzcdate = sy-datum.
e_zack-zzctime = sy-uzeit.
e_zack-zzkeyf1 = i_zapprrec-flow_inst_id.
CONDENSE e_zack-zzkeyf1.
CONCATENATE ‘OA流程实例ID:’ e_zack-zzkeyf1 INTO e_zack-zzkeyf1.
e_zack-zzatri1 = ‘OA更新审批结点’.
e_zack-direct = ‘2’."进站

IF i_zapprrec-apprdate IS INITIAL.
GET TIME.
i_zapprrec-apprdate = sy-datum.
i_zapprrec-apprtime = sy-uzeit.
ENDIF.
DO.
SELECT SINGLE *
INTO c_zapprrec
FROM zapprrec
WHERE flow_inst_id = i_zapprrec-flow_inst_id.
IF c_zapprrec IS NOT INITIAL.
EXIT.
ENDIF.
"评估查询表10000次大概在3秒钟,如果真没找到就退出
IF sy-index >= 10000.
EXIT.
ENDIF.
ENDDO.

"更新审批记录表相关信息
PERFORM frm_update_zapprrec USING i_zapprrec
CHANGING c_zapprrec.

BEGIN OF ADD EC3K911240
"更新审批接口回传对应的自定义表数据
PERFORM frm_update_custome_table USING i_zapprrec
c_zapprrec.
END OF ADD EC3K911240

IF c_zapprrec IS INITIAL. "没有发起ID
e_zack-zzprofg = ‘E’.
e_zack-zzcomen = text-v21.
ELSE.
CALL FUNCTION ‘ENQUEUE_EZAPPRREC’
EXPORTING
mode_zapprrec = ‘E’
mandt = sy-mandt
flow_inst_id = i_zapprrec-flow_inst_id
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc <> 0.
e_zack-zzprofg = ‘E’.
e_zack-zzcomen = text-v22.
ELSE.

  IF c_zapprrec-apprstat2 = '2'.  "流程已经结束
    "财务需求,中间步骤漏了需要补传
    IF i_zapprrec-apprstat2 = '2'.
      e_zack-zzprofg = 'E'.
      e_zack-zzcomen = text-v23.
    ELSE.
      e_zack-zzprofg = 'S'.
      e_zack-zzcomen = '该流程已经结束,补传记录成功'.
      e_zack-zzatri2 = c_zapprrec-flowid.
      e_zack-zzatri3 = c_zapprrec-mainkey.
      e_zack-zzatri4 = c_zapprrec-addkey.
      e_zack-zzatri5 = i_zapprrec-apprstat2.
      e_zack-zzatri6 = i_zapprrec-apprstat.
      CONDENSE: e_zack-zzatri2,
                e_zack-zzatri3,
                e_zack-zzatri4,
                e_zack-zzatri5,
                e_zack-zzatri6.
      CONCATENATE 'FlowId:'            e_zack-zzatri2 INTO e_zack-zzatri2.
      CONCATENATE '审核表Mainkey:'     e_zack-zzatri3 INTO e_zack-zzatri3.
      CONCATENATE '审核表Addkey:'      e_zack-zzatri4 INTO e_zack-zzatri4.
      CONCATENATE '流程状态更新为:'   '不更新' INTO e_zack-zzatri5.
      CONCATENATE '当前步骤审批意见:' '不更新' INTO e_zack-zzatri6.
      c_zapprrec_h-flow_inst_id = i_zapprrec-flow_inst_id.
      c_zapprrec_h-apprdate = i_zapprrec-apprdate.
      c_zapprrec_h-apprtime = i_zapprrec-apprtime.
      c_zapprrec_h-currstep = i_zapprrec-currstep.
      c_zapprrec_h-apprname = i_zapprrec-apprname.
      c_zapprrec_h-appr_pernr = i_zapprrec-appr_pernr.
      c_zapprrec_h-apprcomt = i_zapprrec-apprcomt.
      c_zapprrec_h-nextstep = i_zapprrec-nextstep.
      c_zapprrec_h-next_apprname = i_zapprrec-next_apprname.
      c_zapprrec_h-next_apprpernr = i_zapprrec-next_apprpernr.
      c_zapprrec_h-apprstat = i_zapprrec-apprstat.
      c_zapprrec_h-apprstat2 = i_zapprrec-apprstat2.
      c_zapprrec_h-attr1 = i_zapprrec-attr1.
      c_zapprrec_h-attr2 = i_zapprrec-attr2.
      c_zapprrec_h-attr3 = i_zapprrec-attr3.
      c_zapprrec_h-attr4 = i_zapprrec-attr4.
      MODIFY zapprrec_h FROM c_zapprrec_h.
    ENDIF.
  ELSE."正常情况
    e_zack-zzprofg = 'S'.
    e_zack-zzcomen = '更新成功'.
    e_zack-zzatri2 = c_zapprrec-flowid.
    e_zack-zzatri3 = c_zapprrec-mainkey.
    e_zack-zzatri4 = c_zapprrec-addkey.
    e_zack-zzatri5 = i_zapprrec-apprstat2.
    e_zack-zzatri6 = i_zapprrec-apprstat.
    CONDENSE: e_zack-zzatri2,
              e_zack-zzatri3,
              e_zack-zzatri4,
              e_zack-zzatri5,
              e_zack-zzatri6.
    CONCATENATE 'FlowId:'            e_zack-zzatri2 INTO e_zack-zzatri2.
    CONCATENATE '审核表Mainkey:'     e_zack-zzatri3 INTO e_zack-zzatri3.
    CONCATENATE '审核表Addkey:'      e_zack-zzatri4 INTO e_zack-zzatri4.
    CONCATENATE '流程状态更新为:'   e_zack-zzatri5 INTO e_zack-zzatri5.
    CONCATENATE '当前步骤审批意见:' e_zack-zzatri6 INTO e_zack-zzatri6.

    c_zapprrec-apprdate = i_zapprrec-apprdate."审核日期
    c_zapprrec-apprtime = i_zapprrec-apprtime."审核时间
    c_zapprrec-apprname = i_zapprrec-apprname."审核人
    c_zapprrec-appr_pernr = i_zapprrec-appr_pernr."审核人工号
    c_zapprrec-apprcomt = i_zapprrec-apprcomt."审核意见
    c_zapprrec-currstep = i_zapprrec-currstep."当前步骤
    c_zapprrec-nextstep = i_zapprrec-nextstep."下一步骤说明
    c_zapprrec-next_apprname = i_zapprrec-next_apprname."下一审核人
    c_zapprrec-next_apprpernr = i_zapprrec-next_apprpernr."下一审核人工号
    c_zapprrec-apprstat = i_zapprrec-apprstat."审核状态
    c_zapprrec-apprstat2 = i_zapprrec-apprstat2."审核状态
    c_zapprrec-attr1 = i_zapprrec-attr1.
    c_zapprrec-attr2 = i_zapprrec-attr2.
    c_zapprrec-attr3 = i_zapprrec-attr3.
    c_zapprrec-attr4 = i_zapprrec-attr4.
    c_zapprrec-url = i_zapprrec-url."URL

    c_zapprrec_h-flow_inst_id = i_zapprrec-flow_inst_id.
    c_zapprrec_h-apprdate = i_zapprrec-apprdate.
    c_zapprrec_h-apprtime = i_zapprrec-apprtime.
    c_zapprrec_h-currstep = i_zapprrec-currstep.
    c_zapprrec_h-apprname = i_zapprrec-apprname.
    c_zapprrec_h-appr_pernr = i_zapprrec-appr_pernr.
    c_zapprrec_h-apprcomt = i_zapprrec-apprcomt.
    c_zapprrec_h-nextstep = i_zapprrec-nextstep.
    c_zapprrec_h-next_apprname = i_zapprrec-next_apprname.
    c_zapprrec_h-next_apprpernr = i_zapprrec-next_apprpernr.
    c_zapprrec_h-apprstat = i_zapprrec-apprstat.
    c_zapprrec_h-apprstat2 = i_zapprrec-apprstat2.
    c_zapprrec_h-attr1 = i_zapprrec-attr1.
    c_zapprrec_h-attr2 = i_zapprrec-attr2.
    c_zapprrec_h-attr3 = i_zapprrec-attr3.
    c_zapprrec_h-attr4 = i_zapprrec-attr4.
    MODIFY zapprrec_h FROM c_zapprrec_h.
    COMMIT WORK AND WAIT .
    IF i_zapprrec-apprstat2 = '2'."流程已结束
      SELECT SINGLE *
        INTO ls_oaflow
        FROM zoaflow_append
       WHERE flowid = c_zapprrec-flowid.
      IF ls_oaflow-fun_name <> '' AND ls_oaflow-rfc_name <> ''.

        IF ls_oaflow-oawait EQ space.
          "如果没有选择异步执行的函数还是原来的走同步的逻辑
          CALL FUNCTION ls_oaflow-fun_name DESTINATION ls_oaflow-rfc_name
            EXPORTING
              i_zapprrec = c_zapprrec
            IMPORTING
              e_fag      = e_fag
              e_msg      = e_msg.
          IF e_fag = 'E'.
            e_zack-zzprofg = 'E'.
            CONCATENATE text-v24 e_msg INTO e_zack-zzcomen.
          ENDIF.
        ELSEIF ls_oaflow-oawait EQ 'X'.
          "如果选择异步执行的函数走异步远程调用逻辑
          CLEAR:lv_guid.
          CALL FUNCTION 'GUID_CREATE'
            IMPORTING
              ev_guid_32 = lv_guid.

          CALL FUNCTION 'ZOA_STATU_CHANGE_ASY' STARTING NEW TASK lv_guid
            EXPORTING
              ls_oaflow  = ls_oaflow
              i_zapprrec = c_zapprrec.

        ENDIF.
      ELSEIF ls_oaflow-fun_name <> '' AND ls_oaflow-rfc_name = ''.

        IF ls_oaflow-oawait EQ space.
          "如果没有选择异步执行的函数还是原来的走同步的逻辑
          CALL FUNCTION ls_oaflow-fun_name
            EXPORTING
              i_zapprrec = c_zapprrec
            IMPORTING
              e_fag      = e_fag
              e_msg      = e_msg.
          IF e_fag = 'E'.
            e_zack-zzprofg = 'E'.
            CONCATENATE text-v24 e_msg INTO e_zack-zzcomen.
          ENDIF.
        ELSEIF ls_oaflow-oawait EQ 'X'.
          "如果选择异步执行的函数走异步调用逻辑
          CLEAR:lv_guid.
          CALL FUNCTION 'GUID_CREATE'
            IMPORTING
              ev_guid_32 = lv_guid.
          CALL FUNCTION 'ZOA_STATU_CHANGE_ASY' STARTING NEW TASK lv_guid
            EXPORTING
              ls_oaflow  = ls_oaflow
              i_zapprrec = c_zapprrec.
        ENDIF.
      ELSE.
        e_zack-zzprofg = 'E'.
        e_zack-zzcomen = text-v25.
      ENDIF.

      IF e_zack-zzprofg = 'E'.
        c_zapprrec-apprstat2 = '1'.
        c_zapprrec-nextstep  = text-v26.
      ENDIF.
    ENDIF.

    MODIFY zapprrec   FROM c_zapprrec.

  ENDIF.

  CALL FUNCTION 'DEQUEUE_EZAPPRREC'
    EXPORTING
      mode_zapprrec = 'E'
      mandt         = sy-mandt
      flow_inst_id  = i_zapprrec-flow_inst_id
    EXCEPTIONS
      OTHERS        = 1.

ENDIF.

ENDIF.
e_zack-zzkeyf5 = c_zapprrec-mainkey.
e_zack-zzatri7 = i_zapprrec-flow_inst_id.

CALL FUNCTION ‘ZIF_ACKNOWLEDGEMENT’
EXPORTING
i_acknow = e_zack
IMPORTING
e_acknow = e_zack
EXCEPTIONS
no_interface_type = 1
OTHERS = 2.

COMMIT WORK.

ENDFUNCTION.
李敦 | Jacky Li
流程与信息技术部 | BP&IT
Cell: +86-150 6089 7759
E-mail: LiDun@CATL.com
Web Site: https://www.catl.com
宁德时代新能源科技股份有限公司
福建省宁德市蕉城区漳湾镇新港路2号,352100

上一篇:彻底理解confidence interval和credible interval


下一篇:C++ 11 实现定时器