PO RELEASE 采购订单审核(支持多级审核)
*&--------------------------------------------------------------*
*& FUNCTION:ZRFC_MM_ME21N
*& Module?????????????????? : Function Group?????? MEWF
*$??????????????????????????? Short Text?????????? 發放采購訂單
*&??????????????????????????? Function Group?????? ZGRFC_MM
*&??????????????????????????? Maraco?????????????? MC_CONDITION_INSERT
*&??????????????????????????? Short Text?????????? 采購訂單審核功能RFC接口函數
*&--------------------------------------------------------------*
*& Created????????????????? : Gary.C (2008.07.29) From Hanhe Information Technoligy CD. LTD.
*& Modified???????????????? : Name??? (Date)?????? From
* Intention??????????????? : 1. User could use this function to Release purchase order.
*???????????????????????????? 2. This function Could build multilevel release.
*&--------------------------------------------------------------*
FUNCTION zrfc_mm_po_release.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*"???? VALUE(IP_PO_NUMBER) LIKE EKKO-EBELN
*"???? VALUE(COMMIT_AND_WORK) TYPE CHAR1 DEFAULT 'X'
*" EXPORTING
*"???? VALUE(EP_SUBRC) LIKE SY-SUBRC
*"???? VALUE(EP_MSG) TYPE CHAR255
*" TABLES
*"????? IT_PO_REL_CODE STRUCTURE ZRFC_ME21N_REL_CODE OPTIONAL
*"????? ET_LOG STRUCTURE BAPIRET2 OPTIONAL
*"----------------------------------------------------------------------
**&---------------------------------Global Variant-----------------------------*
DATA gc_frggr LIKE ekko-frggr.???????????????????????????????????? "Release Group
DATA gc_frgsx LIKE ekko-frgsx.????????????????????????????????????? "Release Strategy
DATA gc_frgke LIKE ekko-frgke.????????????????????????????????????? "Release Status.
DATA: gt_t16fs LIKE t16fs OCCURS 0 WITH HEADER LINE.
DATA: gc_new_status LIKE bapimmpara-rel_status.
DATA: gc_indicator_new LIKE bapimmpara-po_rel_ind.
DATA: gt_log LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: gc_no_commit LIKE bapimmpara-selection.
IF commit_and_work = 'X'.
??? gc_no_commit = ''.
ELSE.
??? gc_no_commit = 'X'.
ENDIF.
**&---------------------------------Check Input-----------------------------*
SELECT SINGLE ekko~frgke INTO gc_frgke FROM ekko WHERE ekko~ebeln = ip_po_number.
IF gc_frgke = 'R'.
??? ep_subrc = -1.
??? CONCATENATE: ip_po_number '已經通過審核' INTO ep_msg.
??? EXIT.
ENDIF.
SELECT SINGLE ekko~frggr ekko~frgsx INTO (gc_frggr,gc_frgsx) FROM ekko WHERE ekko~ebeln = ip_po_number.
**&---------------------------------Po Release-----------------------------*
IF ( gc_frggr IS NOT INITIAL ) AND ( gc_frgsx IS NOT INITIAL ).
??? REFRESH gt_t16fs.
??? CLEAR gt_t16fs.
??? SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_t16fs FROM t16fs WHERE t16fs~frggr = gc_frggr AND t16fs~frgsx = gc_frgsx.
ELSE.
??? ep_subrc = -1.
??? ep_msg ='未找到對應審批策略,請檢查輸入'.
??? EXIT.
ENDIF.
IF gt_t16fs[] IS NOT INITIAL.
??? REFRESH it_po_rel_code.
??? CLEAR it_po_rel_code.
??? LOOP AT gt_t16fs.
????? IF gt_t16fs-frgc1 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc1.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc2 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc2.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc3 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc3.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc4 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc4.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc5 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc5.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc6 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc6.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc7 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc7.
??????? APPEND it_po_rel_code.
????? ENDIF.
????? IF gt_t16fs-frgc8 IS NOT INITIAL.
??????? it_po_rel_code-rel_code = gt_t16fs-frgc8.
??????? APPEND it_po_rel_code.
????? ENDIF.
??? ENDLOOP.
ELSE.
??? ep_subrc = -1.
??? ep_msg = '未找到對應審批策略,請檢查輸入'.
??? EXIT.
ENDIF.
IF it_po_rel_code[] IS NOT INITIAL.
??? LOOP AT it_po_rel_code.
????? CLEAR gc_new_status.
????? CLEAR gc_indicator_new.
????? CALL FUNCTION 'BAPI_PO_RELEASE'
??????? EXPORTING
????????? purchaseorder??????????????? = ip_po_number
????????? po_rel_code????????????????? = it_po_rel_code-rel_code
????????? use_exceptions?????????????? = 'X'
?????????? no_commit??????????????????? = gc_no_commit
?? IMPORTING
???? rel_status_new?????????????? = gc_new_status
???? rel_indicator_new??????????? = gc_indicator_new
*?????????? ret_code???????????????????? =
?? TABLES
???? return?????????????????????? = gt_log.
????? .
????? IF sy-subrc = 0.
??????? et_log-type = 'S'.
??????? CONCATENATE: '采購訂單通過審核碼' it_po_rel_code-rel_code '的審核成功!' '返回采購訂單審批狀態為:' gc_new_status ' 審批標識為:'
?????????????? gc_indicator_new INTO et_log-message.
??????? APPEND et_log.
??????? IF NOT gt_log[] IS INITIAL.
????????? et_log-type = gt_log-type.
????????? et_log-message = gt_log-message.
????????? APPEND et_log.
??????? ENDIF.
????? ENDIF.
??? ENDLOOP.
ELSE.
??? ep_subrc = -1.
??? ep_msg = '未找到對應審批策略,請檢查輸入'.
??? EXIT.
ENDIF.
READ TABLE et_log WITH KEY type = 'E'.
IF sy-subrc = 0.
??? ep_msg = 'po審核存在錯誤,請查看錯誤日志'.
??? ep_subrc = -1.
??? EXIT.
ELSE.
??? ep_msg = 'PO已審核成功,請查看日志'.
??? ep_subrc = 0.
ENDIF.
ENDFUNCTION.
總結
以上是生活随笔為你收集整理的PO RELEASE 采购订单审核(支持多级审核)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 怎样取SAP中的业务对象状态
- 下一篇: SAP-HR三大结构