采购订单历史删除

Introduction: For deleting PO History we can use a BAPI 'BAPI_PO_DELETE_HISTORY'. EKBE is the PO history table, the entries that are to be changed must be transferred to the BAPI structure BAPIEKBE. Function module MAP2E_EKBE_TO_BAPIEKBE is available for getting data into BAPI structure BAPIEKBE. Below is the code that takes list of purchase orders from selection screen to be processed for history deletion. *&-----------------------------------------------------------------------* *& Report : ZMPMM038 *& DATE : 28th Jan 2009 * *& AUTHOR : Krishna Chauhan (Sparta Consulting) * *& DEVELOPMENT : Deleting PO History * *&----------------------------------------------------------------------* REPORT ZMPMM038 NO STANDARD PAGE HEADING LINE-SIZE 140 MESSAGE-ID zm. *------Tables--------------------------------------------------------------* TABLES: ekbe. "History per Purchasing Document *******Data Declaration***************************************************** DATA: it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE, it_phist LIKE bapiekbe OCCURS 0 WITH HEADER LINE, wa_phist LIKE LINE OF it_phist, it_tref LIKE csl_tr_exs OCCURS 0 WITH HEADER LINE, w_po LIKE bapiekko-po_number, it_ekbe LIKE ekbe OCCURS 0 WITH HEADER LINE, wa_ekbe LIKE LINE OF it_ekbe. ****Selection screen definition******************************** SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. SELECT-OPTIONS : s_docno FOR ekbe-ebeln OBLIGATORY. SELECTION-SCREEN END OF BLOCK b1. ******Start of Selection**************************************** START-OF-SELECTION. *Pick the data and process it for deleteing PO History. PERFORM process_data. *&---------------------------------------------------------------------* *& Form process_data *&---------------------------------------------------------------------* FORM process_data . CLEAR it_ekbe. REFRESH it_ekbe. SELECT * FROM ekbe INTO TABLE it_ekbe WHERE ebeln IN s_docno. check sy-subrc eq 0. SORT it_ekbe BY ebeln. LOOP AT it_ekbe INTO wa_ekbe. CLEAR: w_po, wa_phist, it_return, it_tref. w_po = wa_ekbe-ebeln. *---fun mod to get 'bapiekbe' for passing it to BAPI history deetel CALL FUNCTION 'MAP2E_EKBE_TO_BAPIEKBE' EXPORTING ekbe = wa_ekbe CHANGING bapiekbe = wa_phist EXCEPTIONS error_converting_curr_amount = 1 OTHERS = 2. APPEND wa_phist TO it_phist. CLEAR it_phist. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. AT END OF ebeln. CALL FUNCTION 'BAPI_PO_DELETE_HISTORY' EXPORTING purchaseorder = w_po TABLES return = it_return poitemhistory = it_phist tokenreference = it_tref. IF sy-subrc = 0. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. ENDIF. " IF sy-subrc = 0. *---clear it_phist to Transfer Structure for PO History REFRESH it_phist. ENDAT. ENDLOOP. ENDFORM. " process_data Output can be checked in ME23N transaction, after execution of the prog it will not show any PO History for the respective PO. Entries will also be deleted from EKBE table. output:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值