SAP_ABAP_MM_PO审批_队列实践SMQ1

news2024/11/25 21:38:06

SAP ABAP 顾问(开发工程师)能力模型-CSDN博客文章浏览阅读1k次。目标:基于对SAP abap 顾问能力模型的梳理,给一年左右经验的abaper 快速成长为三年经验提供超级燃料!https://blog.csdn.net/java_zhong1990/article/details/132469977


一、背景说明

二、代码实现

2.1 队列实现

SMQ1 SMQ2 SMQ3 

2.2 队列执行失败设置定时任务 

待定....

FUNCTION zmm_create_po_core.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(IS_HEAD) TYPE  ZMMS_PO_HEAD
*"     VALUE(IT_ITEM) TYPE  ZMMT_PO_ITEM
*"  EXPORTING
*"     VALUE(E_EBELN) TYPE  EBELN
*"     VALUE(E_STATUS) TYPE  CHAR1
*"     VALUE(E_MESSAGE) TYPE  CHAR100
*"     VALUE(E_BSART) TYPE  BSART
*"----------------------------------------------------------------------


  DATA:
    lw_prps        TYPE prps,
    lw_exheader    TYPE bapi_te_mepoheader,
    lw_exheaderx   TYPE bapi_te_mepoheaderx,
    lw_extensionin TYPE bapiparex,
    lt_extensionin TYPE STANDARD TABLE OF bapiparex,
    lw_textheader  TYPE bapimepotextheader,
    lt_textheader  TYPE STANDARD TABLE OF bapimepotextheader,
    lw_textitem    TYPE  bapimepotext,
    lt_textitem    TYPE  STANDARD TABLE OF bapimepotext,
    l_bsart        TYPE bsart,
    l_knttp        TYPE knttp,
    lw_eban        TYPE eban,
    l_matnr        TYPE matnr,
    l_mtart        TYPE mtart,
    l_lifnr_o      TYPE char10,
    l_text         TYPE char200,
    l_status       TYPE char1,
    l_ebelp        TYPE ebelp,
    l_posid        TYPE ps_posid,
    lw_poaccount   TYPE bapimepoaccount,
    lt_poaccount   TYPE STANDARD TABLE OF bapimepoaccount,
    lw_poaccountx  TYPE bapimepoaccountx,
    lt_poaccountx  TYPE STANDARD TABLE OF bapimepoaccountx,
    l_po           TYPE bapimepoheader-po_number,         "PO号
    lw_poaddr      TYPE bapimepoaddrvendor,
    lw_poheader    TYPE bapimepoheader,                   "采购抬头
    lw_poheaderx   TYPE bapimepoheaderx,                  "采购抬头确认
    lw_poitem      TYPE bapimepoitem,                     "采购行项目
    lt_poitem      TYPE bapimepoitem OCCURS 0,            "采购行项目
    lw_poitemx     TYPE bapimepoitemx,                    "采购行项目确认
    lt_poitemx     TYPE bapimepoitemx OCCURS 0,           "采购行项目确认
    lw_condition   TYPE bapimepocond,                     "行项目定价条件
    lt_condition   TYPE bapimepocond OCCURS 0,            "行项目定价条件
    lw_conditionx  TYPE bapimepocondx,                    "行项目定价条件确认
    lt_conditionx  TYPE bapimepocondx OCCURS 0,           "行项目定价条件确认
    lw_poschedule  TYPE bapimeposchedule,
    lt_poschedule  TYPE bapimeposchedule OCCURS 0,
    lw_poschedulex TYPE bapimeposchedulx,
    lt_poschedulex TYPE bapimeposchedulx OCCURS 0,
    lt_return      TYPE bapiret2 OCCURS 0,                "返回消息
    lw_return      TYPE bapiret2.                         "返回消息
  DATA:l_ktokk LIKE lfa1-ktokk."供应商账户组
*-------------------------------------
* 基本检查
*-------------------------------------
  IF it_item[] IS INITIAL.
    e_status = 'E'.
    e_message = '行项目不能为空!'.
    RETURN.
  ENDIF.
* 确定采购订单类型
  READ TABLE it_item INTO DATA(lw_item) INDEX 1.
  IF lw_item-banfn IS NOT INITIAL.
*   取采购申请的物料
    SELECT SINGLE *
      INTO lw_eban
      FROM eban
     WHERE banfn = lw_item-banfn
       AND bnfpo = lw_item-bnfpo
            .
    l_matnr = lw_eban-matnr.
    l_knttp = lw_eban-knttp.
  ELSE.
    l_matnr = lw_item-matnr.
  ENDIF.
*  IF l_matnr IS INITIAL.
*    e_status  = 'E'.
*    e_message = '无法确定物料!'.
*    RETURN.
*  ENDIF.
  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = l_matnr
    IMPORTING
      output       = l_matnr
    EXCEPTIONS
      length_error = 1
      OTHERS       = 2.
* 取物料类型
  SELECT SINGLE mtart
    INTO l_mtart
    FROM mara
   WHERE matnr = l_matnr
      .
  l_lifnr_o = |{ is_head-lifnr ALPHA = IN }|.
  SELECT SINGLE ktokk
INTO l_ktokk
FROM lfa1
WHERE lifnr = l_lifnr_o.
  l_lifnr_o = |{ is_head-lifnr ALPHA = OUT }|.


* 确定订单类型
  IF is_head-oaxjlx = 'Z'.
    l_bsart = 'A01'.
  ELSEIF lw_eban-pstyp = '3'.
    l_bsart = 'A04'.
  ELSEIF (   l_mtart = 'A100'
      OR l_mtart = 'A110' "MODIFY BY LIQUAN 2021.10.26 鲁文慧确认
      OR l_mtart = 'A120'
      OR l_mtart = 'A130'
      OR l_mtart = 'A140'
      OR l_mtart = 'A150'
      OR l_mtart = 'A200'
      OR l_mtart = 'A300'
      OR l_mtart = 'A310'
      OR l_mtart = 'A320'
      OR l_mtart = 'A330'
      OR l_mtart = 'A340'
      OR l_mtart = 'A350'
      OR l_mtart = 'A400'
      OR l_mtart = 'AL00'
"*******Added by zhong on 14.08.2023 15:55:34
      OR l_mtart = 'A160'
      OR l_mtart = 'A170'

    )
*  AND l_lifnr_o CP '1*'.
    AND l_ktokk <> 'A002' AND l_ktokk <> ''.
    l_bsart = 'NB'.
  ELSEIF (   l_mtart = 'A100'
      OR l_mtart = 'A110' "MODIFY BY LIQUAN 2021.10.26 鲁文慧确认
      OR l_mtart = 'A120'
      OR l_mtart = 'A130'
      OR l_mtart = 'A140'
      OR l_mtart = 'A150'
      OR l_mtart = 'A200'
      OR l_mtart = 'A300'
      OR l_mtart = 'A310'
      OR l_mtart = 'A320'
      OR l_mtart = 'A330'
      OR l_mtart = 'A340'
      OR l_mtart = 'AL00'
"*******Added by zhong on 14.08.2023 15:55:43
      OR l_mtart = 'A160'
      OR l_mtart = 'A170'


    )
    AND l_ktokk = 'A002' .
    l_bsart = 'A01'.
  ELSEIF lw_item-matnr IS NOT INITIAL AND lw_item-posid IS NOT INITIAL AND l_mtart = 'A350'.
    l_bsart = 'NB'.
  ELSEIF ( ( l_mtart = 'A350' AND ( lw_item-matnr IS INITIAL OR lw_item-posid IS INITIAL ) )
 OR l_mtart = 'A400'
 OR l_mtart = 'A700' ).
    l_bsart = 'A02'.
  ELSEIF lw_item-matnr IS INITIAL AND lw_item-gdzcbj = 'X' .
    l_bsart = 'A06'.
  ELSEIF lw_item-matnr IS INITIAL.
    l_bsart ='A03'.
  ENDIF.
  IF l_bsart IS INITIAL.
    e_status = 'E'.
    e_message = '无法确定凭证类型'.
    RETURN.
  ENDIF.

  "增加非祥瑞 选择祥瑞物料组 限制 2022-02-23
  DATA:l_flag TYPE n.
  l_flag = 0.
  IF is_head-bukrs <> 2030.
    LOOP AT it_item ASSIGNING FIELD-SYMBOL(<fs>).
      IF <fs>-matkl = '8099001' OR <fs>-matkl = '8099002' OR <fs>-matkl = '8099003'.
        l_flag = 1.
      ENDIF.
    ENDLOOP.
    IF l_flag = 1.
      e_status = 'E'.
      e_message = '物料组选择错误'.
      RETURN.
    ENDIF.
  ENDIF.

  "增加判断祥瑞工厂收货未评估未勾选
  l_flag = 0.
  IF is_head-bukrs = 2030 OR is_head-bukrs = 3020.
    LOOP AT it_item ASSIGNING FIELD-SYMBOL(<its>).
      IF ( <its>-werks = 2031 OR <its>-werks = 3021 ) AND ( <its>-matkl = '8099001' OR <its>-matkl = '8099002' OR <its>-matkl = '8099003' ).
        IF <its>-weunb IS INITIAL.
          l_flag = 1.
        ENDIF.
      ENDIF.
    ENDLOOP.
    IF l_flag = 1.
      e_status = 'E'.
      e_message = '收货未评估未勾选'.
      RETURN.
    ENDIF.
  ENDIF.

*-------------------------------------
* bapi字段处理
*-------------------------------------

***************抬头***************
  lw_poheader-doc_type  = l_bsart      .                 "凭证类型
  lw_poheader-vendor    = |{ is_head-lifnr ALPHA = IN }|."供应商帐户号
  lw_poheader-purch_org = is_head-ekorg.                 "采购组织
  lw_poheader-pur_group = is_head-ekgrp.                 "采购组
  lw_poheader-comp_code = is_head-bukrs.                 "公司代码
  lw_poheader-doc_date  = sy-datum     .                 "采购凭证日期
  lw_poheader-pmnttrms  = is_head-zterm.                 "收付条件代码
  lw_poheader-currency  = is_head-waers.                 "货币
*————确认————
  lw_poheaderx-doc_type  = 'X'.                          "凭证类型
  lw_poheaderx-vendor    = 'X'.                          "供应商帐户号
  lw_poheaderx-purch_org = 'X'.                          "采购组织
  lw_poheaderx-pur_group = 'X'.                          "采购组
  lw_poheaderx-comp_code = 'X'.                          "公司代码
  IF lw_poheader-doc_date IS NOT INITIAL OR lw_poheader-doc_date <> ''.
    lw_poheaderx-doc_date  = 'X'.                          "采购凭证日期
  ENDIF.
  IF lw_poheader-pmnttrms IS NOT INITIAL.
    lw_poheaderx-pmnttrms  = 'X'.                          "收付条件代码
  ENDIF.
  IF lw_poheader-currency IS NOT INITIAL.
    lw_poheaderx-currency  = 'X'.                          "货币
  ENDIF.
  IF lw_poheader-vendor  = '0000900000'.
    lw_poaddr-name    = is_head-name1.
    lw_poaddr-country = 'CN'.
    lw_poaddr-city    = is_head-city1.
    lw_poaddr-po_box  = '未知'.
    lw_poaddr-street  = is_head-street.
    lw_poaddr-postl_cod1  = is_head-post_code1.

  ENDIF.

  IF is_head-oauser IS NOT INITIAL.
    lw_exheader-zuser = is_head-oauser.

    lw_extensionin-structure  = 'BAPI_TE_MEPOHEADER'.
    lw_extensionin-valuepart1 = lw_exheader..
    APPEND lw_extensionin TO lt_extensionin.

    lw_exheaderx-zuser = 'X'.

    lw_extensionin-structure  = 'BAPI_TE_MEPOHEADERX'.
    lw_extensionin-valuepart1 = lw_exheaderx.
    APPEND lw_extensionin TO lt_extensionin.
  ENDIF.
*————抬头文本————
  IF is_head-bktxt IS NOT INITIAL.
    CLEAR lw_textheader.
    lw_textheader-text_id      = 'F01'.
    lw_textheader-text_form    = '/'.
    lw_textheader-text_line    = is_head-bktxt+0(132).
    APPEND lw_textheader TO lt_textheader.
    IF is_head-bktxt+132(132) IS NOT INITIAL.
      CLEAR lw_textheader.
      lw_textheader-text_id      = 'F01'.
      lw_textheader-text_form    = '/'.
      lw_textheader-text_line    = is_head-bktxt+132(132).
      APPEND lw_textheader TO lt_textheader.
    ENDIF.
  ENDIF.
***************行项目*************
  LOOP AT it_item INTO lw_item.
    l_ebelp = l_ebelp + 10.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        input        = lw_item-matnr
      IMPORTING
        output       = lw_item-matnr
      EXCEPTIONS
        length_error = 1
        OTHERS       = 2.
    IF sy-subrc <> 0.
* Implement suitable error handling here
    ENDIF.

    IF lw_item-posid IS NOT INITIAL.
      SELECT SINGLE *
        INTO lw_prps
        FROM prps
       WHERE posid = lw_item-posid.
      IF sy-subrc <> 0.
        e_status = 'E'.
        e_message = 'WBS元素' && lw_item-posid && '不存在'.
        RETURN.
      ENDIF.
    ENDIF.
    CLEAR l_knttp.
    IF lw_item-kostl IS NOT INITIAL.
      l_knttp = 'K'.
    ELSEIF lw_item-aufnr IS NOT INITIAL.
      l_knttp = 'F'.
    ELSEIF lw_item-posid IS NOT INITIAL
        AND lw_item-matnr IS NOT INITIAL.
      l_knttp = 'Q'.
    ELSEIF lw_item-posid IS NOT INITIAL
        AND lw_item-matnr IS INITIAL.
      l_knttp = 'P'.
    ELSEIF lw_item-gdzcbj IS NOT INITIAL
        OR ( lw_item-anln1 IS NOT INITIAL AND lw_item-anln2 IS NOT INITIAL ).
      l_knttp = 'A'.
*    ELSE.
*      l_knttp = 'L'.
    ENDIF.
    lw_poitem-po_item     = l_ebelp.                     "行项目编号
    lw_poitem-material    = lw_item-matnr.               "物料编码
    lw_poitem-matl_group  = lw_item-matkl.               "物料组
    lw_poitem-short_text  = lw_item-txz01.
    lw_poitem-plant       = lw_item-werks.               "工厂
    lw_poitem-stge_loc    = lw_item-lgort.               "库存地点
    lw_poitem-quantity    = lw_item-menge.               "数量
    "lw_poitem-plan_del = lw_item-eindt."交货日期
    IF lw_item-menge IS INITIAL AND lw_eban-menge IS NOT INITIAL.
      lw_poitem-quantity   = lw_eban-menge.
    ENDIF.
    IF  lw_item-meins IS NOT INITIAL.
      CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'
        EXPORTING
          input          = lw_item-meins
*         LANGUAGE       = SY-LANGU
        IMPORTING
          output         = lw_item-meins
        EXCEPTIONS
          unit_not_found = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.
    ENDIF.

    lw_poitem-po_unit     = lw_item-meins.               "单位
    IF lw_item-meins IS INITIAL AND lw_eban-menge IS NOT INITIAL.
      lw_poitem-po_unit     = lw_eban-meins.
    ENDIF.

    lw_poitem-preq_no        = lw_item-banfn.               "采购申请编号
    lw_poitem-preq_item      = lw_item-bnfpo.               "采购申请行项目
    lw_poitem-tax_code       = lw_item-mwskz.               "税码
    lw_poitem-acctasscat     = l_knttp.                     "科目分配类别
    lw_poitem-item_cat       = lw_eban-pstyp.               "项目类别
*    IF  lw_item-kostl IS NOT INITIAL.
*      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*        EXPORTING
*          input  = lw_item-kostl
*        IMPORTING
*          output = lw_poitem-costcenter.
*
*    ENDIF.
    lw_poitem-costcenter     = lw_item-kostl.               "成本中心
    lw_poitem-over_dlv_tol   = lw_item-uebto.               "
    lw_poitem-under_dlv_tol  = lw_item-untto.               "
    lw_poitem-gr_non_val     = lw_item-weunb.               "
    lw_poitem-gr_basediv     = 'X'.               "
    APPEND lw_poitem TO lt_poitem.
*  ————确认————
    lw_poitemx-po_item    = l_ebelp.                     "行项目编号
    IF lw_poitem-material IS NOT INITIAL.
      lw_poitemx-material   = 'X'.                         "物料编码
    ENDIF.
    IF lw_poitem-short_text IS NOT INITIAL.
      lw_poitemx-short_text = 'X'.
    ENDIF.
    IF lw_poitem-plant IS NOT INITIAL.
      lw_poitemx-plant      = 'X'.                         "工厂
    ENDIF.
    IF lw_poitem-stge_loc IS NOT INITIAL.
      lw_poitemx-stge_loc   = 'X'.                         "库存地点
    ENDIF.
    IF lw_poitem-quantity IS NOT INITIAL.
      lw_poitemx-quantity   = 'X'.                         "数量
    ENDIF.
    IF lw_poitem-po_unit IS NOT INITIAL.
      lw_poitemx-po_unit    = 'X'.                         "单位
    ENDIF.
    IF lw_poitem-preq_no IS NOT INITIAL.
      lw_poitemx-preq_no    = 'X'.                         "采购申请编号
    ENDIF.
    IF lw_poitem-preq_item IS NOT INITIAL.
      lw_poitemx-preq_item  = 'X'.        "采购申请行项目
    ENDIF.
    IF lw_poitem-tax_code IS NOT INITIAL.
      lw_poitemx-tax_code   = 'X'.                         "税码
    ENDIF.
    IF lw_poitem-acctasscat IS NOT INITIAL.
      lw_poitemx-acctasscat = 'X'.                         "科目分配类别
    ENDIF.
    IF lw_poitem-item_cat IS NOT INITIAL.
      lw_poitemx-item_cat   = 'X'.                         "项目类别
    ENDIF.
    IF lw_poitem-costcenter IS NOT INITIAL.
      lw_poitemx-costcenter = 'X'.                         "成本中心
    ENDIF.

    IF lw_poitem-matl_group  IS NOT INITIAL.
      lw_poitemx-matl_group = 'X'.
    ENDIF.
    IF lw_poitem-over_dlv_tol IS  NOT INITIAL.
      lw_poitemx-over_dlv_tol    = 'X'.
    ENDIF.
    IF lw_poitem-under_dlv_tol IS NOT INITIAL.
      lw_poitemx-under_dlv_tol   = 'X'.
    ENDIF.
    IF lw_poitem-gr_non_val IS NOT INITIAL.
      lw_poitemx-gr_non_val      = 'X'.
    ENDIF.
    IF lw_poitem-gr_basediv IS NOT INITIAL.
      lw_poitemx-gr_basediv      = 'X'.
    ENDIF.
    APPEND lw_poitemx TO lt_poitemx.

*  ************账户设置************
    IF lw_item-posid IS NOT INITIAL
    OR lw_item-aufnr IS NOT INITIAL
    OR lw_item-anln1 IS NOT INITIAL
    OR lw_item-kostl IS NOT INITIAL.
      CLEAR lw_poaccount.
      lw_poaccount-po_item     = l_ebelp.
      lw_poaccount-orderid     = lw_item-aufnr.

      lw_poaccount-wbs_element = lw_item-posid.
      lw_poaccount-asset_no    = lw_item-anln1.
      lw_poaccount-sub_number  = lw_item-anln2.
      lw_poaccount-costcenter  = lw_item-kostl.
      APPEND lw_poaccount  TO lt_poaccount .

      CLEAR lw_poaccountx.
      lw_poaccountx-po_item     = l_ebelp.
      IF lw_poaccount-orderid IS NOT INITIAL.
        lw_poaccountx-orderid     = 'X'.
      ENDIF.

      IF lw_poaccount-wbs_element IS NOT INITIAL.
        lw_poaccountx-wbs_element = 'X'.
      ENDIF.
      IF lw_poaccount-asset_no IS NOT INITIAL.
        lw_poaccountx-asset_no    = 'X'.
      ENDIF.
      IF lw_poaccount-sub_number IS NOT INITIAL.
        lw_poaccountx-sub_number  = 'X'.
      ENDIF.
      IF lw_poaccount-costcenter IS NOT INITIAL.
        lw_poaccountx-costcenter  = 'X'.
      ENDIF.
      APPEND lw_poaccountx TO lt_poaccountx.
    ENDIF.
*  ************定价条件************
    IF lw_item-netpr IS INITIAL AND lw_eban-preis IS NOT INITIAL.
      lw_item-netpr = lw_eban-preis.
      lw_item-peinh = lw_eban-peinh.
    ENDIF.
    IF lw_item-peinh IS INITIAL.
      lw_item-peinh = '1'.
    ENDIF.
    IF lw_item-netpr IS NOT INITIAL.
      lw_condition-itm_number  = l_ebelp.                   "行项目号
      lw_condition-cond_type   = 'PBXX'.                 "条件类型
      lw_condition-cond_value  = lw_item-netpr.               "金额
      lw_condition-cond_p_unt  = lw_item-peinh.
      lw_condition-currency    = 'CNY'.                  "货币
      lw_condition-change_id   = 'I'.
      APPEND lw_condition TO lt_condition.

*————确认————
      lw_conditionx-itm_number  = l_ebelp.                   "行项目号
      lw_conditionx-cond_type   = 'X'.                    "条件类型
      lw_conditionx-cond_value  = 'X'.                    "金额
      lw_conditionx-cond_p_unt  = 'X'.                    "金额
      lw_conditionx-currency    = 'X'.                    "货币
      lw_conditionX-change_id   = 'X'.
      APPEND lw_conditionx TO lt_conditionx.
    ENDIF.
*————行项目文本————
    IF lw_item-sgtxt IS NOT INITIAL.
      CLEAR lw_textitem.
      lw_textitem-po_item      = l_ebelp.
      lw_textitem-text_id      = 'F01'.
      lw_textitem-text_form    = '/'.
      lw_textitem-text_line    = lw_item-sgtxt+0(132).
      APPEND lw_textitem TO lt_textitem.
      IF lw_item-sgtxt+132(132) IS NOT INITIAL.
        CLEAR lw_textitem.
        lw_textitem-po_item      = l_ebelp.
        lw_textitem-text_id      = 'F01'.
        lw_textitem-text_form    = '/'.
        lw_textitem-text_line    = lw_item-sgtxt+132(132).
        APPEND lw_textitem TO lt_textitem.
      ENDIF.
    ENDIF.
    "add by gxx 2022-02-16
    lw_poschedule-po_item = l_ebelp.
    lw_poschedule-delivery_date = lw_item-eindt."交货日期
    APPEND lw_poschedule TO lt_poschedule.

    lw_poschedulex-po_item = l_ebelp.
    lw_poschedulex-po_itemx = 'X'.
    lw_poschedulex-delivery_date = 'X'.
    APPEND lw_poschedulex TO lt_poschedulex.


  ENDLOOP.
  SET UPDATE TASK LOCAL .
  CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
      poheader         = lw_poheader
      poheaderx        = lw_poheaderx
      poaddrvendor     = lw_poaddr
*     TESTRUN          = 'X'
*     MEMORY_UNCOMPLETE            =
*     MEMORY_COMPLETE  =
*     POEXPIMPHEADER   =
*     POEXPIMPHEADERX  =
*     VERSIONS         =
*     NO_MESSAGING     =
*     NO_MESSAGE_REQ   =
*     NO_AUTHORITY     =
*     NO_PRICE_FROM_PO =
*     PARK_COMPLETE    =
*     PARK_UNCOMPLETE  =
    IMPORTING
      exppurchaseorder = l_po
*     EXPHEADER        =
*     EXPPOEXPIMPHEADER            =
    TABLES
      return           = lt_return
      poitem           = lt_poitem
      poitemx          = lt_poitemx
*     POADDRDELIVERY   =
      poschedule       = lt_poschedule
      poschedulex      = lt_poschedulex
      poaccount        = lt_poaccount
*     POACCOUNTPROFITSEGMENT       =
      poaccountx       = lt_poaccountx
*     POCONDHEADER     =
*     POCONDHEADERX    =
      pocond           = lt_condition
      pocondx          = lt_conditionx
*     POLIMITS         =
*     POCONTRACTLIMITS =
*     POSERVICES       =
*     POSRVACCESSVALUES            =
*     POSERVICESTEXT   =
      extensionin      = lt_extensionin
*     EXTENSIONOUT     =
*     POEXPIMPITEM     =
*     POEXPIMPITEMX    =
      potextheader     = lt_textheader
      potextitem       = lt_textitem
*     ALLVERSIONS      =
*     POPARTNER        =
*     POCOMPONENTS     =
*     POCOMPONENTSX    =
*     POSHIPPING       =
*     POSHIPPINGX      =
*     POSHIPPINGEXP    =
*     SERIALNUMBER     =
*     SERIALNUMBERX    =
*     INVPLANHEADER    =
*     INVPLANHEADERX   =
*     INVPLANITEM      =
*     INVPLANITEMX     =
    .

* 结果处理
* 状态判定
  CLEAR l_text.
  LOOP AT lt_return INTO lw_return .
    IF lw_return-type = 'E'
    OR lw_return-type = 'A' .
      l_status = 'E'.
    ELSE.
      CONTINUE.
    ENDIF.
    IF l_text IS INITIAL.
      l_text = lw_return-message.
    ELSE.
      CONCATENATE l_text lw_return-message INTO l_text SEPARATED BY '//'.
    ENDIF.
  ENDLOOP.

******  ADD 20230106  状态判断里面加入判断单号为空时
  IF l_po IS INITIAL.
    l_status = 'E'.
    CONCATENATE '创建失败' l_text lw_return-message INTO l_text SEPARATED BY '//'.
  ENDIF.
******
* 结果处理
  IF l_status = 'E' .
    e_status  = 'E'.
    e_message = l_text.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    RETURN.
  ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait = 'X'.
    e_ebeln = l_po.
    e_status = 'S'.
    e_bsart = l_bsart.
  ENDIF.

* 产生队列,后台进行自动审批
  DATA l_qname TYPE trfcqout-qname.
  l_qname = 'PO_SP_' && l_po.
  CONDENSE l_qname NO-GAPS.
  CALL FUNCTION 'TRFC_SET_QUEUE_NAME'
    EXPORTING
      qname              = l_qname
      nosend             = ' '
      trfc_if_sysfail    = ' '
      call_event         = ' '
    EXCEPTIONS
      invalid_queue_name = 1
      OTHERS             = 2.
  CALL FUNCTION 'ZMM_PO_APPROVAL_AUTO'
    IN BACKGROUND TASK
    AS SEPARATE UNIT
    DESTINATION 'NONE'
    EXPORTING
      i_ebeln = l_po.
  COMMIT WORK  .


ENDFUNCTION.
FUNCTION zmm_po_approval_auto.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(I_EBELN) TYPE  EBELN
*"----------------------------------------------------------------------

*{   INSERT         DS4K900045                                        1
  DATA:
    lw_ekko   TYPE ekko,
    lt_return TYPE STANDARD TABLE OF bapireturn,
    lw_return TYPE bapireturn.

* 1.检查采购订单是否存在
  IF i_ebeln IS NOT INITIAL.
    SELECT SINGLE *
      INTO lw_ekko
      FROM ekko
     WHERE ebeln = i_ebeln.
    IF sy-subrc <> 0.
      MESSAGE e001(zrsm).
    ENDIF.
  ENDIF.
  CHECK lw_ekko-frgke <> 'R'.
* 审批通过P1
  IF lw_ekko-frgke = 'B'.
    CALL FUNCTION 'BAPI_PO_RELEASE'
      EXPORTING
        purchaseorder          = i_ebeln
        po_rel_code            = 'P1'
      TABLES
        return                 = lt_return
      EXCEPTIONS
        authority_check_fail   = 1
        document_not_found     = 2
        enqueue_fail           = 3
        prerequisite_fail      = 4
        release_already_posted = 5
        responsibility_fail    = 6
        OTHERS                 = 7.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid
            TYPE 'E'
          NUMBER sy-msgno
            WITH sy-msgv1
                 sy-msgv2
                 sy-msgv3
                 sy-msgv4.
    ENDIF.
    WAIT UP TO 1 SECONDS.
  ENDIF.
* 审批通过P2
  CALL FUNCTION 'BAPI_PO_RELEASE'
    EXPORTING
      purchaseorder          = i_ebeln
      po_rel_code            = 'P2'
    TABLES
      return                 = lt_return
    EXCEPTIONS
      authority_check_fail   = 1
      document_not_found     = 2
      enqueue_fail           = 3
      prerequisite_fail      = 4
      release_already_posted = 5
      responsibility_fail    = 6
      OTHERS                 = 7.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid
          TYPE 'E'
        NUMBER sy-msgno
          WITH sy-msgv1
               sy-msgv2
               sy-msgv3
               sy-msgv4.
  ENDIF.






*}   INSERT




ENDFUNCTION.

三、案例说明

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1587926.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Python - 深度学习系列32 - glm2接口部署实践

说明 前阵子&#xff0c;已经对glm2的接口部署做了镜像化。本次的目的是&#xff1a; 1 测试在隔了一阵子&#xff08;忘记&#xff09;的情况下&#xff0c;快速部署时是否有障碍&#xff0c;是不是足够方便2 在算网机环境下&#xff0c;能否快速的实现部署。仅考虑文件方式…

策略模式【行为模式C++】

1.概述 策略模式是一种行为设计模式&#xff0c; 它能让你定义一系列算法&#xff0c; 并将每种算法分别放入独立的类中&#xff0c; 以使算法的对象能够相互替换。 策略模式通常应用于需要多种算法进行操作的场景&#xff0c;如排序、搜索、数据压缩等。在这些情况下&#x…

D-LinkNAS 远程命令执行漏洞(CVE-2024-3273)RCE漏

声明&#xff1a; 本文仅用于技术交流&#xff0c;请勿用于非法用途 由于传播、利用此文所提供的信息而造成的任何直接或者间接的后果及损失&#xff0c;均由使用者本人负责&#xff0c;文章作者不为此承担任何责任。 简介 D-LinkNAS是由D-Link公司制造的网络附加存储设备。…

有趣的css - 动态雷达扫描

大家好&#xff0c;我是 Just&#xff0c;这里是「设计师工作日常」&#xff0c;今天分享的是使用 css 实现一个动态的雷达扫描&#xff0c;快学起来吧&#xff01; 《有趣的css》系列最新实例通过公众号「设计师工作日常」发布。 目录 整体效果核心代码html 代码css 部分代码…

产品推荐 | 瑞苏盈科基于立体帧捕捉和视频处理应用的火星Mars EB1开发板

01 产品概述 火星Mars EB1底板是为火星Mars系列FPGA和SoC核心板设计的通用底板&#xff0c;非常适用于立体帧捕捉和视频处理应用&#xff0c;可以为构建基于FPGA的定制化硬件系统提供一个良好的基础和开端。 02 核心亮点 ■ 与所有火星Mars系列FPGA和SoC核心板兼容 ■ 适用…

2024mathorcup数学建模C题思路分析-物流网络分拣中心货量预测及人员排班

# 1 赛题 C 题 物流网络分拣中心货量预测及人员排班 电商物流网络在订单履约中由多个环节组成&#xff0c;图 ’ 是一个简化的物流 网络示意图。其中&#xff0c;分拣中心作为网络的中间环节&#xff0c;需要将包裹按照不同 流向进行分拣并发往下一个场地&#xff0c;最终使包裹…

FME学习之旅---day23

我们付出一些成本&#xff0c;时间的或者其他&#xff0c;最终总能收获一些什么。 教程&#xff1a;地理数据库入门 FME 支持读取和写入不同的地理数据库格式;这包括文件地理数据库、个人地理数据库和 ArcSDE 地理数据库。支持矢量和栅格数据类型。在本教程中&#xff0c;我们…

Understanding Flink

Flink 下载&#xff1a; mkdir ~/flink && cd ~/flinkwget --no-check-certificate https://archive.apache.org/dist/flink/flink-1.15.3/flink-1.15.3-bin-scala_2.12.tgz wget --no-check-certificate https://repo1.maven.org/maven2/com/ververica/flink-sql-co…

PHP+MySQL组合开发 易企秀H5场景源码系统 带完整的安装代码包以及搭建教程

在数字化时代&#xff0c;企业对于宣传与推广的需求日益增长&#xff0c;而H5页面作为一种轻量级、跨平台的宣传方式&#xff0c;深受企业青睐。为了满足企业对于H5页面制作的需求&#xff0c;我们基于PHPMySQL组合开发了一套易企秀H5场景源码系统&#xff0c;并提供了完整的安…

PTA(题目集一 题目 代码 C++ 注解)

目录 题目一&#xff1a; 代码&#xff1a; 题目二&#xff1a; 代码&#xff1a; 题目三&#xff1a; 代码&#xff1a; 题目四&#xff1a; 代码&#xff1a; 题目五&#xff1a; 代码&#xff1a; 题目六&#xff1a; 代码&#xff1a; 题目七&#xff1a; 代…

VM虚拟机Linux系统Redhat7.4版本进行网络配置

日常中自己搭建的虚拟机一般用到两种网络方式&#xff0c;第一种是仅主机模式、还有一种是NAT模式。 1、仅主机模式&#xff1a;可以和自己本地电脑&#xff0c;或者虚拟机和虚拟机之间进行网络通信&#xff0c;相当于一个局域网&#xff0c;是不能连接外网的。 2、NAT模式&a…

Leetcode刷题之消失的数字(C语言版)

Leetcode刷题之消失的数字&#xff08;C语言版&#xff09; 一、题目描述二、题目解析 一、题目描述 数组nums包含从0到n的所有整数&#xff0c;但其中缺了一个。请编写代码找出那个缺失的整数。你有办法在O(n)时间内完成吗&#xff1f; 注意&#xff1a;本题相对书上原题稍作…

BIM信息如何整合到可视化大屏中,告诉你步骤。

BIM&#xff08;Building Information Modeling&#xff09;是一种数字化建筑信息模型技术&#xff0c;可以将建筑物的设计、施工和运营过程进行集成和管理。将BIM整合到可视化大屏中可以提供更直观、全面的建筑信息展示和分析。 BIM&#xff08;建筑信息模型&#xff09;可以通…

SFP光模块和媒体转换器的区别

SFP光模块和媒体转换器都是光电转换设备。它们是否可以互换使用&#xff1f;它们之间有什么区别&#xff1f; SFP光模块与媒体转换器&#xff1a;它们是什么&#xff1f; SFP模块是一种可热插拔的光模块&#xff0c;用于连接网络交换机。它可以将电信号转换为光信号&#xff…

Doris 内网安装部署,基于 CentOS 7

实测 CentOS 7.6 和 7.9都可用&#xff0c;CentOS安装包为&#xff1a;标准安装盘DVD版&#xff0c;如果系统安装的是精简版&#xff0c;需要挂载DVD版或者自行下载依赖。 参考文档 快速开始 - Apache Doris Doris 下载地址&#xff1a;2.1.1 ( Latest ) -> x64 ( avx2 )…

spring.rabbitmq.listener.simple.default-requeue-rejected = false 和放入死信队列的区别

目录 一、场景 二、使用 spring.rabbitmq.listener.simple.default-requeue-rejected false 2.1 特点 三、 放入死信队列 四、两种区别 一、场景 当我们使用RabbitMq的时候&#xff0c;我们如果业务中有异常&#xff0c;很有可能造成死循环&#xff0c;因为 在RabbitMQ和…

TSINGSEE青犀边缘计算AI智能分析网关V4客流统计算法的配置步骤及使用

TSINGSEE青犀AI智能分析网关V4内置了近40种AI算法模型&#xff0c;支持对接入的视频图像进行人、车、物、行为、烟火等实时检测分析&#xff0c;上报识别结果&#xff0c;并能进行语音告警播放。硬件支持RTSP、GB28181协议、以及厂家私有协议接入&#xff0c;可兼容市面上常见的…

Netty学习——实战篇1 BIO、NIO入门demo 备注

1 BIO 实战代码 Slf4j public class BIOServer {public static void main(String[] args) throws IOException {//1 创建线程池ExecutorService threadPool Executors.newCachedThreadPool();//2 创建ServerSocketServerSocket serverSocket new ServerSocket(8000);log.in…

java下载网络上的文件、图片保存到本地 FileUtils

java下载网络上的文件、图片保存到本地 FileUtils 1. 引入FileUtils依赖2. 实现代码3. 输出结果 1. 引入FileUtils依赖 <!--FileUtils依赖--> <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> <dependency><groupId>commons-io&l…

(Java)数据结构——图(第九节)AOV网以及拓扑排序

前言 本博客是博主用于复习数据结构以及算法的博客&#xff0c;如果疏忽出现错误&#xff0c;还望各位指正。 AOV网 先前我们了解了有向无环图DAG的概念。 所有的工程或者某种流程可以分为若干个小的工程或者阶段&#xff0c;这些小的工程或者阶段就称为活动。若以图中的顶…