The document describes issues where invoice verification documents are created without follow-up accounting or purchase order documents. It provides a correction using report ZREPMIR7 to analyze and repair these incorrect documents by changing their status to "on hold". The report parameters and output are explained. It also addresses how to temporarily cancel purchase order document aggregation if needed to repair invoices.
The document describes issues where invoice verification documents are created without follow-up accounting or purchase order documents. It provides a correction using report ZREPMIR7 to analyze and repair these incorrect documents by changing their status to "on hold". The report parameters and output are explained. It also addresses how to temporarily cancel purchase order document aggregation if needed to repair invoices.
The document describes issues where invoice verification documents are created without follow-up accounting or purchase order documents. It provides a correction using report ZREPMIR7 to analyze and repair these incorrect documents by changing their status to "on hold". The report parameters and output are explained. It also addresses how to temporarily cancel purchase order document aggregation if needed to repair invoices.
The document describes issues where invoice verification documents are created without follow-up accounting or purchase order documents. It provides a correction using report ZREPMIR7 to analyze and repair these incorrect documents by changing their status to "on hold". The report parameters and output are explained. It also addresses how to temporarily cancel purchase order document aggregation if needed to repair invoices.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 19
PROBLEMA:
REGISTRO DE RECEPCIN DE FACTURA CREADO, Y NO SE CRE DOCUMENTO DE FI
CORRECCIN:
SAP Note Header Data Symptom Due to several program errors, the invoice verification documents are sometimes created without follow-up documents in accounting or they are created without an entry in the purchase order history (see the 'Related notes' section). Report ZREPMIR7 determines these incorrect documents. If you set the indicator 'P_UPDATE' to 'X', the report changes the status of the selected incorrect documents to 'on hold'. Afterwards, you can use the standard transactions to either delete or continue processing the changed documents. The report does not process posted documents if you have aggregated purchase order history records. If this is the case, you must cancel the aggregation of the documents in question and then run the report again. Older versions of this report incorrectly tell you that purchase order history records are missing when you aggregate the purchase order history records. This problem has been corrected in the newer versions of the report. The report now tells you when the purchase order history record for a document has been aggregated. Ensure that your system contains the latest version of the report. If you cannot repair an invoice document because the purchase order history is aggregated, you must cancel the aggregation temporarily. To do this, proceed as follows: Call transaction ME87 -> Make your entries -> Choose "Execute" (F8) -> Select the aggregated record -> Choose "Edit" -> Choose "Save disaggregation". If several documents are aggregated, use the report Z_EKBEAUFL from Note 574494 to speed up this process. Once you have repaired the incoming invoice, you can aggregate the purchase order history again. Other Terms MIR7, RBSTAT, ME809, ME_UPDATE_INVOICE, MIR4, ME87, RM06EKBE Reason and Prerequisites Solution Create report ZREPMIR7 in the relevant system (see the correction instructions). Using the report: 1. Description of the report parameters: a) SO_BELNR: Accrual/deferral according to document number during the search for incorrect documents b) SO_GJAHR: Accrual/deferral according to the fiscal year during the search for incorrect documents c) P_UPDATE: Initial value: Display mode, no update. Value 'X': Status of incorrect documents is changed to 'on hold'. d) P_USER (for Release 4.6B only): Initial value: Display mode, no update. Entry of 'SAPSUPP' (together with P_UPDATE = X): Status of incorrect documents is changed to 'on hold'. 2. Description of the report's output columns: a) BELNR: Document number of the incorrect document b) GJAHR: Fiscal year of the incorrect document c) RBSTAT: Document status of the incorrect document (5: Posted, A: Parked, B: Parked as complete) d) No PO: Purchase order history is missing e) No FI: Accounting is not updated ('Follow-up documents'). 382797 - MIRO: Analysis and repair for missing follow-up documents Version 34 Validity: 26.03.2014 - active Language English Released On 26.03.2014 11:04:20 Release Status Released for Customer Component MM-IV-LIV Logistics Invoice Verification Priority Correction with low priority Category Help for error analysis f) No ML: Purchase order history ML currencies missing g) BLOCKED: Entry exists in table RBKP_BLOCKED h) DOC SUM: Aggregated purchase order history record i) ML active: Material ledger is active 3. Notes about using the report: a) First start the report with the parameter SO_BELNR as initial and with the fiscal years in which incorrect documents exist. In Release 4.6C, indicator P_UPDATE remains initial. In release 4.6B, the fields P_UPDATE and P_USER remain blank. b) If you then want to set the status of the documents to 'on hold', start the report for each affected fiscal year with the document numbers of the incorrect documents from these fiscal years. Set the indicator P_UPDATE to 'X' (Release 4.6C) or set the indicator P_UPDATE to 'X' and the indicator P_USER to 'SAPSUPP' (Release 4.6B). We recommend that you save the list that is generated in a text document. You can then change, delete or post each document with the function 'Other document'. Note: The report can be used for posting only as of Release 4.6C. In Release 4.6B, documents that have been corrected with report ZREPMIR7 can no longer be posted. These documents must be deleted and entered again with transaction MR2M (menu: "Document -> Delete"). Validity Correction Instructions References This document refers to: SAP Notes This document is referenced by: Software Component From Rel. To Rel. And Subsequent SAP_APPL 46B 46B 46C 46C 470 470 500 500 600 600 602 602 603 603 604 604 605 605 606 606 616 616 617 617 Correction Instructions Software Component Valid from Valid to Number SAP_APPL 46B 46B 426925 SAP_APPL 46C 617 286072 781498 MIR4: Missing follow-on documents 765668 Problems during the post of documents 762943 MIRO: FI documents are missing with posted MM documents 743744 MIRO/MR1M: FI follow-on documents or MM documents missing 574494 Explosion the aggregated purchase order history via report 456920 Upload sales order: Problems with reply to CRM 456075 Addition to Note 444125 444125 CUXC: Error messages provided with exceptions 381287 Individual purchase order: No FI document for vendor invoice 369909 Error message RW100 when creating vendor invoice 352400 MIR4: Update termination when you save or post SAP Notes (10) 381287 Individual purchase order: No FI document for vendor invoice 369909 Error message RW100 when creating vendor invoice 352400 MIR4: Update termination when you save or post 444125 CUXC: Error messages provided with exceptions 456920 Upload sales order: Problems with reply to CRM 456075 Addition to Note 444125 762943 MIRO: FI documents are missing with posted MM documents 765668 Problems during the post of documents 743744 MIRO/MR1M: FI follow-on documents or MM documents missing 781498 MIR4: Missing follow-on documents REPORTE ZREPMIR7:
REPORT ZREPMIR7 Delta001 Print Context Block Delete Block Insert Block *&---------------------------------------------------------------------* *& * *& Report ZREPMIR7 * *& * *&---------------------------------------------------------------------* *& * *& * *& * *&---------------------------------------------------------------------* * Change history * 15.02.01: Version 0, Responsible: KlMe -> EnGe, note 382797 * 12.12.02: Version 1, Changed by : SvSi, add document summarization * 02.04.03: Version 2, Changed by : EnGe, insert c_rbstat_rele_pa * 13.01.04: Version 3, Changed by : SvSi, no PO check for zerolines * 07.12.04: Version 4, Changed by : InTo, add case RBKP_BLOCKED * 10.11.07: Version 5, Changed by : InTo, delete MLBE/MLBECR if ML is * active * 04.07.08: Version 6, Changed by : InTo, added posting date as * selection criteria * 21.09.09: Version 7, Changed by : PhGr, added c_rbstat_rele_pa REPORT zrepmir7. TABLES: rbkp. SELECT-OPTIONS: so_belnr FOR rbkp-belnr, so_gjahr FOR rbkp-gjahr, so_bukrs FOR rbkp-bukrs, so_budat FOR rbkp-budat. IF sy-saprl GE '46C'. PARAMETERS: p_update TYPE c. TYPES: BEGIN OF header, belnr TYPE belnr_d, gjahr TYPE gjahr, rbstat TYPE rbstat, x_no_po TYPE c, " no PO history x_no_fi TYPE c, " no FI follow-on docs x_ml_active TYPE c, x_no_po_ml TYPE c, " no PO history ML side Display source for correction Page 1 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 x_blocked_found TYPE c, x_doc_sum TYPE c, text(40) TYPE c, END OF header. TYPES: trbkp TYPE TABLE OF rbkp, trseg TYPE TABLE OF rseg. DATA: BEGIN OF t_bwkey OCCURS 0, bwkey TYPE bwkey, END OF t_bwkey. DATA: tab_rbkp TYPE TABLE OF rbkp, tab_rbkp_blocked TYPE TABLE OF rbkp_blocked, tab_rbkp_blocked_delete TYPE TABLE OF rbkp_blocked, tab_rseg TYPE TABLE OF rseg, tab_rbco TYPE TABLE OF rbco, tab_ekbe TYPE TABLE OF ekbe, tab_ekbz TYPE TABLE OF ekbz, tab_bkpf TYPE TABLE OF bkpf, tab_header TYPE TABLE OF header, tab_ekbeh TYPE TABLE OF ekbeh, tab_ekbzh TYPE TABLE OF ekbzh, tab_mlwere TYPE TABLE OF mlwere, tab_mlbe TYPE TABLE OF mlbe, tab_mlbe_delete TYPE TABLE OF mlbe, tab_mlbecr TYPE TABLE OF mlbecr, tab_mlbecr_delete TYPE TABLE OF mlbecr. DATA: s_rbkp TYPE rbkp, s_rbkp_blocked TYPE rbkp_blocked, s_rbkpb TYPE rbkpb, s_rseg TYPE rseg, s_rbco TYPE rbco, s_ekbe TYPE ekbe, s_ekbz TYPE ekbz, s_bkpf TYPE bkpf, s_header TYPE header, s_ekbeh TYPE ekbeh, s_ekbzh TYPE ekbzh, s_mlwere TYPE mlwere, s_mlbe TYPE mlbe, s_mlbecr TYPE mlbecr. DATA: f_lines_rbkp TYPE i, f_lines_rseg TYPE i, f_lines_delete TYPE i, f_lines_mlwere TYPE i, f_mlbe_delete TYPE i, f_mlbecr_delete TYPE i, f_awkey TYPE awkey, f_new_rbstat TYPE rbstat, f_no_po_item_expected TYPE c, f_do_not_check TYPE c. DATA: c_ivtyp_dialog TYPE ivtyp VALUE ' ', c_rbstat_parked TYPE rbstat VALUE 'A', c_rbstat_comple TYPE rbstat VALUE 'B', Display source for correction Page 2 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 c_rbstat_saved_pa TYPE rbstat VALUE 'C', c_rbstat_saved_po TYPE rbstat VALUE 'D', c_rbstat_rele_pa TYPE rbstat VALUE 'E', c_rbstat_posted TYPE rbstat VALUE '5', c_vgabe_parked TYPE vgabe VALUE 'P', c_bewtp_parked TYPE bewtp VALUE 'T', c_koart_initial TYPE koart VALUE ' ', c_awtyp_rmrp TYPE awtyp VALUE 'RMRP'. * -- Selection --------- SELECT * FROM rbkp INTO TABLE tab_rbkp WHERE belnr IN so_belnr AND gjahr IN so_gjahr AND bukrs IN so_bukrs AND budat IN so_budat AND ( rbstat = c_rbstat_posted OR rbstat = c_rbstat_rele_pa OR rbstat = c_rbstat_parked OR rbstat = c_rbstat_comple ). DESCRIBE TABLE tab_rbkp LINES f_lines_rbkp. IF sy-subrc = 0. SELECT * FROM rseg INTO TABLE tab_rseg FOR ALL ENTRIES IN tab_rbkp WHERE ( gjahr = tab_rbkp-gjahr AND belnr = tab_rbkp-belnr ). ENDIF. DESCRIBE TABLE tab_rseg LINES f_lines_rseg. IF sy-subrc = 0. SELECT * FROM rbco INTO TABLE tab_rbco FOR ALL ENTRIES IN tab_rseg WHERE ( gjahr = tab_rseg-gjahr AND belnr = tab_rseg-belnr AND koart = c_koart_initial ). SELECT * FROM rbkp_blocked INTO TABLE tab_rbkp_blocked FOR ALL ENTRIES IN tab_rbkp WHERE belnr = tab_rbkp-belnr AND gjahr = tab_rbkp-gjahr. SELECT * FROM ekbe INTO TABLE tab_ekbe FOR ALL ENTRIES IN tab_rseg WHERE ( ebeln = tab_rseg-ebeln AND ebelp = tab_rseg-ebelp AND gjahr = tab_rseg-gjahr AND belnr = tab_rseg-belnr ). SELECT * FROM ekbz INTO TABLE tab_ekbz FOR ALL ENTRIES IN tab_rseg WHERE ( ebeln = tab_rseg-ebeln AND ebelp = tab_rseg-ebelp AND gjahr = tab_rseg-gjahr AND belnr = tab_rseg-belnr ). SELECT * FROM ekbeh INTO TABLE tab_ekbeh Display source for correction Page 3 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 FOR ALL ENTRIES IN tab_rseg WHERE ( ebeln = tab_rseg-ebeln AND ebelp = tab_rseg-ebelp AND gjahr = tab_rseg-gjahr AND belnr = tab_rseg-belnr ). SELECT * FROM ekbzh INTO TABLE tab_ekbzh FOR ALL ENTRIES IN tab_rseg WHERE ( ebeln = tab_rseg-ebeln AND ebelp = tab_rseg-ebelp AND gjahr = tab_rseg-gjahr AND belnr = tab_rseg-belnr ). * ML aktiv? SELECT * FROM t001k INTO CORRESPONDING FIELDS OF TABLE t_bwkey FOR ALL ENTRIES IN tab_rseg WHERE bwkey = tab_rseg-bwkey AND mlbwa = 'X'. IF NOT t_bwkey[] IS INITIAL. SELECT * FROM mlwere INTO TABLE tab_mlwere FOR ALL ENTRIES IN tab_rseg WHERE ( ebeln = tab_rseg-ebeln AND ebelp = tab_rseg-ebelp ). IF sy-subrc = 0. SELECT * FROM mlbe INTO TABLE tab_mlbe FOR ALL ENTRIES IN tab_mlwere WHERE mlvnr = tab_mlwere-mlvnr. SELECT * FROM mlbecr INTO TABLE tab_mlbecr FOR ALL ENTRIES IN tab_mlwere WHERE mlvnr = tab_mlwere-mlvnr. ENDIF. ENDIF. ENDIF. * For better performance: sort all tables SORT tab_rbkp_blocked BY gjahr belnr. SORT tab_rseg BY gjahr belnr. SORT tab_ekbe BY gjahr belnr buzei. SORT tab_ekbz BY gjahr belnr. SORT tab_ekbeh BY gjahr belnr. SORT tab_ekbzh BY gjahr belnr. SORT t_bwkey. * sort tab_rbco by belnr gjahr buzei. * -- Checks ------------- * Check: follow-on documents missing? LOOP AT tab_rbkp INTO s_rbkp. CLEAR s_header. READ TABLE tab_rseg INTO s_rseg WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. Display source for correction Page 4 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 CHECK sy-subrc = 0. * do not check PO history for posted documents with zerolines IF s_rseg-menge = 0 AND s_rseg-wrbtr = 0 AND s_rbkp-rbstat = c_rbstat_posted. f_do_not_check = 'X'. ENDIF. IF f_do_not_check EQ space. * 1. PO summarization existing? READ TABLE tab_ekbeh INTO s_ekbeh WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. IF sy-subrc EQ 0. * ... Document summarization in EKBEH MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_doc_sum = 'X'. ELSE. READ TABLE tab_ekbzh INTO s_ekbzh WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. IF sy-subrc EQ 0. * ... Document summarization in EKBZH MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_doc_sum = 'X'. ENDIF. ENDIF. * 2. PO history existing? IF s_header-x_doc_sum IS INITIAL. CLEAR s_ekbe. CLEAR s_ekbz. * Is there at least one EKBE/EKBZ entry for this invoice? * Normally it is enough to check one entry: update is done * for all entries or for none entry READ TABLE tab_ekbe INTO s_ekbe WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. IF sy-subrc NE 0. READ TABLE tab_ekbz INTO s_ekbz WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. IF sy-subrc NE 0. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_po = 'X'. ENDIF. ENDIF. ENDIF. * 3. EKBE/EKBZ exist: PO history of ML existing? PERFORM existence_ml_po_history. ENDIF. CLEAR f_do_not_check. Display source for correction Page 5 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 * 4. Check FI Document (only if there are real PO items) LOOP AT tab_rseg INTO s_rseg WHERE gjahr = s_rbkp-gjahr AND belnr = s_rbkp-belnr AND wrbtr NE 0. EXIT. ENDLOOP. IF sy-subrc NE 0. CLEAR s_header. ELSE. MOVE: s_rbkp-belnr TO f_awkey(10), s_rbkp-gjahr TO f_awkey+10(4). SELECT SINGLE * FROM bkpf INTO s_bkpf WHERE awtyp = 'RMRP ' AND awkey = f_awkey. IF sy-subrc <> 0. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_fi = 'X'. ENDIF. ENDIF. * 5. Entry in RBKP_BLOCKED existing? IF s_header-x_no_fi = 'X'. READ TABLE tab_rbkp_blocked INTO s_rbkp_blocked WITH KEY gjahr = s_rbkp-gjahr belnr = s_rbkp-belnr BINARY SEARCH. IF sy-subrc = 0. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_blocked_found = 'X'. ENDIF. ENDIF. IF NOT s_header IS INITIAL. APPEND s_header TO tab_header. ENDIF. ENDLOOP. * ML active? IF NOT t_bwkey[] IS INITIAL. LOOP AT tab_header INTO s_header. READ TABLE tab_rseg INTO s_rseg WITH KEY belnr = s_header-belnr gjahr = s_header-gjahr. * ML active for this plant? READ TABLE t_bwkey WITH KEY bwkey = s_rseg-werks BINARY SEARCH. IF sy-subrc = 0. s_header-x_ml_active = 'X'. MODIFY tab_header FROM s_header. ENDIF. ENDLOOP. ENDIF. Display source for correction Page 6 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 * Update IF p_update = 'X'. LOOP AT tab_header INTO s_header. CASE s_header-x_no_po. WHEN 'X'. CASE s_header-x_no_fi. WHEN 'X'. * PO history not existing, Acc. follow-on not existing * > Set status to Hold (C or D) IF s_header-rbstat = c_rbstat_parked OR s_header-rbstat = c_rbstat_comple OR s_header-rbstat = c_rbstat_rele_pa. . f_new_rbstat = c_rbstat_saved_pa. ELSEIF s_header-rbstat = c_rbstat_posted. f_new_rbstat = c_rbstat_saved_po. ENDIF. * > Create RBKPB-record if old status is 'Posted' PERFORM rbkpb_create USING s_header f_new_rbstat tab_rbkp tab_rseg CHANGING s_rbkpb s_header-text. IF NOT s_header-text IS INITIAL. MODIFY tab_header FROM s_header. EXIT. ENDIF. UPDATE rbkp SET rbstat = f_new_rbstat ivtyp = c_ivtyp_dialog WHERE belnr = s_header-belnr AND gjahr = s_header-gjahr. IF sy-subrc NE 0. s_header-text = 'Error when updating RBKP'. MODIFY tab_header FROM s_header. EXIT. ENDIF. IF f_new_rbstat = c_rbstat_saved_po. INSERT INTO rbkpb VALUES s_rbkpb. IF sy-subrc NE 0. s_header-text = 'Error when inserting RBKPB'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. * > Invoice blocking reason has to be deleted, otherwise * short dump occurs REFRESH tab_rbkp_blocked_delete. READ TABLE tab_rbkp_blocked INTO s_rbkp_blocked WITH KEY gjahr = s_header-gjahr belnr = s_header-belnr BINARY SEARCH. IF sy-subrc = 0. APPEND s_rbkp_blocked TO tab_rbkp_blocked_delete. ENDIF. DESCRIBE TABLE tab_rbkp_blocked_delete LINES f_lines_delete. Display source for correction Page 7 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 IF f_lines_delete > 0. DELETE rbkp_blocked FROM TABLE tab_rbkp_blocked_delete. IF sy-subrc NE 0. s_header-text = 'Error when deleting RBKP_BLOCKED'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. CONCATENATE '... updated, new status ' f_new_rbstat INTO s_header-text. MODIFY tab_header FROM s_header. WHEN OTHERS. * PO history not existing, Acc. follow-on existing * > Recreate EKBE or EKBZ - only for parked documents IF s_header-rbstat = c_rbstat_parked OR s_header-rbstat = c_rbstat_rele_pa OR s_header-rbstat = c_rbstat_comple. READ TABLE tab_rbkp INTO s_rbkp WITH KEY belnr = s_header-belnr gjahr = s_header-gjahr. LOOP AT tab_rseg INTO s_rseg WHERE belnr = s_header-belnr AND gjahr = s_header-gjahr. CLEAR: s_ekbe, s_ekbz. IF s_rseg-exkbe = 'X'. MOVE-CORRESPONDING s_rbkp TO s_ekbe. MOVE-CORRESPONDING s_rseg TO s_ekbe. s_ekbe-ernam = s_rbkp-usnam. s_ekbe-vgabe = c_vgabe_parked. s_ekbe-bewtp = c_bewtp_parked. IF s_rseg-knttp IS INITIAL. INSERT INTO ekbe VALUES s_ekbe. ELSE. LOOP AT tab_rbco INTO s_rbco WHERE belnr = s_rseg-belnr AND gjahr = s_rseg-gjahr AND buzei = s_rseg-buzei. MOVE-CORRESPONDING s_rbco TO s_ekbe. INSERT INTO ekbe VALUES s_ekbe. ENDLOOP. ENDIF. ELSE. MOVE-CORRESPONDING s_rbkp TO s_ekbz. MOVE-CORRESPONDING s_rseg TO s_ekbz. s_ekbz-vgabe = c_vgabe_parked. s_ekbz-bewtp = c_bewtp_parked. INSERT INTO ekbz VALUES s_ekbz. ENDIF. ENDLOOP. s_header-text = '... updated'. MODIFY tab_header FROM s_header. ENDIF. Display source for correction Page 8 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 ENDCASE. WHEN OTHERS. CASE s_header-x_no_fi. WHEN 'X'. * PO history existing, Acc. follow-on not existing * > Set status to Hold (C or D) if * there is no document summarization IF s_header-x_doc_sum IS INITIAL. "EKBE/EKBZ exists IF s_header-rbstat = c_rbstat_parked OR s_header-rbstat = c_rbstat_comple OR s_header-rbstat = c_rbstat_rele_pa. f_new_rbstat = c_rbstat_saved_pa. ELSEIF s_header-rbstat = c_rbstat_posted. f_new_rbstat = c_rbstat_saved_po. ENDIF. * > Create RBKPB-record if old status is 'Posted' PERFORM rbkpb_create USING s_header f_new_rbstat tab_rbkp tab_rseg CHANGING s_rbkpb s_header-text. IF NOT s_header-text IS INITIAL. MODIFY tab_header FROM s_header. EXIT. ENDIF. UPDATE rbkp SET rbstat = f_new_rbstat ivtyp = c_ivtyp_dialog WHERE belnr = s_header-belnr AND gjahr = s_header-gjahr. IF sy-subrc NE 0. s_header-text = 'Error when updating RBKP'. MODIFY tab_header FROM s_header. EXIT. ENDIF. IF f_new_rbstat = c_rbstat_saved_po. INSERT INTO rbkpb VALUES s_rbkpb. IF sy-subrc NE 0. s_header-text = 'Error when inserting RBKPB'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. * > Invoice blocking reason has to be deleted, otherwise * short dump occurs REFRESH tab_rbkp_blocked_delete. READ TABLE tab_rbkp_blocked INTO s_rbkp_blocked WITH KEY gjahr = s_header-gjahr belnr = s_header-belnr BINARY SEARCH. IF sy-subrc = 0. APPEND s_rbkp_blocked TO tab_rbkp_blocked_delete. ENDIF. DESCRIBE TABLE tab_rbkp_blocked_delete LINES f_lines_delete. Display source for correction Page 9 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 IF f_lines_delete > 0. DELETE rbkp_blocked FROM TABLE tab_rbkp_blocked_delete. IF sy-subrc NE 0. s_header-text = 'Error when deleting RBKP_BLOCKED'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. * > Delete MLBE/MLBECR IF s_header-x_ml_active = 'X'. IF s_header-x_no_po_ml = ' '. PERFORM ml_po_history_delete. IF NOT s_header-text IS INITIAL. EXIT. ENDIF. ENDIF. ENDIF. * > Delete EKBE/EKBZ LOOP AT tab_rseg INTO s_rseg WHERE belnr = s_header-belnr AND gjahr = s_header-gjahr. IF s_rseg-exkbe = 'X'. DELETE FROM ekbe WHERE ebeln = s_rseg-ebeln AND ebelp = s_rseg-ebelp AND belnr = s_rseg-belnr AND gjahr = s_rseg-gjahr AND buzei = s_rseg-buzei. IF sy-subrc NE 0. s_header-text = 'Error when deleting EKBE'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ELSEIF s_rseg-xekbz = 'X'. DELETE FROM ekbz WHERE ebeln = s_rseg-ebeln AND ebelp = s_rseg-ebelp AND belnr = s_rseg-belnr AND gjahr = s_rseg-gjahr AND buzei = s_rseg-buzei. IF sy-subrc NE 0. s_header-text = 'Error when deleting EKBZ'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. ENDLOOP. IF NOT s_header-text IS INITIAL. MODIFY tab_header FROM s_header. EXIT. ENDIF. CONCATENATE '... updated, new status ' f_new_rbstat INTO s_header-text. MODIFY tab_header FROM s_header. ENDIF. Display source for correction Page 10 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 WHEN OTHERS. * PO history existing, Acc. follow-on existing > no update ENDCASE. ENDCASE. ENDLOOP. ENDIF. * Log output WRITE: / 'BELNR GJAHR RBSTAT No PO No FI No ML BLOCKED ', 'DOC sum ML active'. SORT tab_header BY gjahr belnr. LOOP AT tab_header INTO s_header. WRITE: / s_header-belnr, s_header-gjahr, ' ', s_header-rbstat, ' ', s_header-x_no_po, ' ', s_header-x_no_fi, ' ', s_header-x_no_po_ml, ' ', s_header-x_blocked_found, ' ', s_header-x_doc_sum, ' ', s_header-x_ml_active, ' ', s_header-text. ENDLOOP. IF p_update = ' '. READ TABLE tab_header INTO s_header WITH KEY x_no_fi = 'X'. IF sy-subrc = 0. WRITE: /, /, / 'Attention: ', / 'This report checks only missing FI documents, not other', 'accounting follow-on documents. If there is a missing ', 'FI document please check if there are other Accounting', 'follow-on documents. If you find one please do not run ', 'this report in update mode for this invoice.'. ENDIF. ENDIF. ELSE. WRITE: 'This report is only for R/3 Release above 4.6B'. EXIT. ENDIF. *&---------------------------------------------------------------------* *& Form rbkpb_create *----------------------------------------------------------------------* * text * *----------------------------------------------------------------------* FORM rbkpb_create USING i_header TYPE header Display source for correction Page 11 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 i_new_rbstat TYPE rbstat ti_rbkp TYPE trbkp ti_rseg TYPE trseg CHANGING e_rbkpb TYPE rbkpb e_text TYPE text40. DATA: s_rbkp TYPE rbkp, s_rseg TYPE rseg. CHECK i_header-rbstat = c_rbstat_posted. CLEAR e_rbkpb. READ TABLE ti_rbkp INTO s_rbkp WITH KEY belnr = s_header-belnr gjahr = s_header-gjahr. IF sy-subrc NE 0. s_header-text = 'Error when creating RBKPB record'. MODIFY tab_header FROM s_header. EXIT. ENDIF. MOVE-CORRESPONDING s_header TO e_rbkpb. LOOP AT tab_rseg INTO s_rseg WHERE belnr = s_rbkp-belnr AND gjahr = s_rbkp-gjahr. IF ( s_rbkp-xrech = 'X' AND s_rseg-shkzg = 'S' ) OR ( s_rbkp-xrech = space AND s_rseg-shkzg = 'H' ). e_rbkpb-rpzieln = e_rbkpb-rpzieln + s_rseg-wrbtr. ELSE. e_rbkpb-rpzieln = e_rbkpb-rpzieln - s_rseg-wrbtr. ENDIF. IF s_rseg-exkbe = 'X'. e_rbkpb-xware = 'X'. ELSEIF s_rseg-xekbz = 'X'. e_rbkpb-xbnk = 'X'. ENDIF. ENDLOOP. e_rbkpb-rbstat = i_new_rbstat. e_rbkpb-anzrpo = 1. e_rbkpb-xkorrekt = 'X'. e_rbkpb-xzuordli = 'X'. e_rbkpb-xzuordrt = 'X'. e_rbkpb-xrechl = 'S'. e_rbkpb-xrechr = 'H'. ENDFORM. " rbkpb_create *&---------------------------------------------------------------------* *& Form existence_ml_po_history *&---------------------------------------------------------------------* * Does an entry in MLBE and MLBECR exist for this one found * EKBE/EKBZ entry? *----------------------------------------------------------------------* FORM existence_ml_po_history. * ML active for this plant? READ TABLE t_bwkey WITH KEY bwkey = s_rseg-werks BINARY SEARCH. IF sy-subrc = 0. CLEAR s_mlwere. Display source for correction Page 12 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 IF s_header-x_no_po = ' ' AND "ZEKKN can be taken from EKBE/EKBZ s_header-x_doc_sum = ' '. * .. no check for parked invoices; they don't have an entry in ML IF NOT s_ekbe IS INITIAL AND s_ekbe-vgabe NE 'P'. READ TABLE tab_mlwere INTO s_mlwere WITH KEY ebeln = s_ekbe-ebeln ebelp = s_ekbe-ebelp zekkn = s_ekbe-zekkn stunr = ' ' zaehk = ' '. IF sy-subrc = 0. READ TABLE tab_mlbe INTO s_mlbe WITH KEY mlvnr = s_mlwere-mlvnr gjahr = s_ekbe-gjahr belnr = s_ekbe-belnr buzei = s_ekbe-buzei. IF sy-subrc NE 0. READ TABLE tab_mlbecr INTO s_mlbecr WITH KEY mlvnr = s_mlwere-mlvnr gjahr = s_ekbe-gjahr belnr = s_ekbe-belnr buzei = s_ekbe-buzei. IF sy-subrc NE 0. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_po_ml = 'X'. ENDIF. ENDIF. ELSE. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_po_ml = 'X'. ENDIF. ELSEIF NOT s_ekbz IS INITIAL. READ TABLE tab_mlwere INTO s_mlwere WITH KEY ebeln = s_ekbz-ebeln ebelp = s_ekbz-ebelp stunr = s_ekbz-stunr zaehk = s_ekbz-zaehk. IF sy-subrc = 0. READ TABLE tab_mlbe INTO s_mlbe WITH KEY mlvnr = s_mlwere-mlvnr gjahr = s_ekbz-gjahr belnr = s_ekbz-belnr buzei = s_ekbz-buzei. IF sy-subrc NE 0. READ TABLE tab_mlbecr INTO s_mlbecr WITH KEY mlvnr = s_mlwere-mlvnr gjahr = s_ekbz-gjahr belnr = s_ekbz-belnr buzei = s_ekbz-buzei. IF sy-subrc NE 0. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_po_ml = 'X'. ENDIF. ENDIF. ELSE. MOVE-CORRESPONDING s_rbkp TO s_header. s_header-x_no_po_ml = 'X'. ENDIF. Display source for correction Page 13 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 ENDIF. ENDIF. ENDIF. ENDFORM. " existence_ml_po_history *&---------------------------------------------------------------------* *& Form ml_po_history_delete *&---------------------------------------------------------------------* * Deletes MLBE and MLBECR. *----------------------------------------------------------------------* FORM ml_po_history_delete. REFRESH tab_mlbe_delete. REFRESH tab_mlbecr_delete. LOOP AT tab_rseg INTO s_rseg WHERE belnr = s_header-belnr AND gjahr = s_header-gjahr. CLEAR s_ekbe. IF s_rseg-exkbe = 'X'. LOOP AT tab_ekbe INTO s_ekbe WHERE ebeln = s_rseg-ebeln AND ebelp = s_rseg-ebelp AND ( vgabe = '2' OR vgabe = '3' ) AND gjahr = s_rseg-gjahr AND belnr = s_rseg-belnr AND buzei = s_rseg-buzei. READ TABLE tab_mlwere INTO s_mlwere WITH KEY ebeln = s_ekbe-ebeln ebelp = s_ekbe-ebelp zekkn = s_ekbe-zekkn stunr = ' ' zaehk = ' '. IF sy-subrc = 0. READ TABLE tab_mlbe INTO s_mlbe WITH KEY mlvnr = s_mlwere-mlvnr vgabe = s_ekbe-vgabe gjahr = s_ekbe-gjahr belnr = s_ekbe-belnr buzei = s_ekbe-buzei. IF sy-subrc = 0. APPEND s_mlbe TO tab_mlbe_delete. ENDIF. CLEAR s_mlbecr. LOOP AT tab_mlbecr INTO s_mlbecr WHERE mlvnr = s_mlwere-mlvnr AND vgabe = s_ekbe-vgabe AND gjahr = s_ekbe-gjahr AND belnr = s_ekbe-belnr AND buzei = s_ekbe-buzei. APPEND s_mlbecr TO tab_mlbecr_delete. ENDLOOP. ENDIF. ENDLOOP. ELSEIF s_rseg-xekbz = 'X'. LOOP AT tab_ekbz INTO s_ekbz Display source for correction Page 14 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 WHERE ebeln = s_rseg-ebeln AND ebelp = s_rseg-ebelp AND ( vgabe = '2' OR vgabe = '3' ) AND gjahr = s_rseg-gjahr AND belnr = s_rseg-belnr AND buzei = s_rseg-buzei. READ TABLE tab_mlwere INTO s_mlwere WITH KEY ebeln = s_ekbz-ebeln ebelp = s_ekbz-ebelp stunr = s_ekbz-stunr zaehk = s_ekbz-zaehk. IF sy-subrc = 0. READ TABLE tab_mlbe INTO s_mlbe WITH KEY mlvnr = s_mlwere-mlvnr vgabe = s_ekbz-vgabe gjahr = s_ekbz-gjahr belnr = s_ekbz-belnr buzei = s_ekbz-buzei. IF sy-subrc = 0. APPEND s_mlbe TO tab_mlbe_delete. ENDIF. CLEAR s_mlbecr. LOOP AT tab_mlbecr INTO s_mlbecr WHERE mlvnr = s_mlwere-mlvnr AND vgabe = s_ekbz-vgabe AND gjahr = s_ekbz-gjahr AND belnr = s_ekbz-belnr AND buzei = s_ekbz-buzei. APPEND s_mlbecr TO tab_mlbecr_delete. ENDLOOP. ENDIF. ENDLOOP. ENDIF. ENDLOOP. DESCRIBE TABLE tab_mlbe_delete LINES f_mlbe_delete. DESCRIBE TABLE tab_mlbecr_delete LINES f_mlbecr_delete. IF f_mlbe_delete > 0. DELETE mlbe FROM TABLE tab_mlbe_delete. IF sy-subrc NE 0. s_header-text = 'Error when deleting MLBE'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. IF f_mlbecr_delete > 0. DELETE mlbecr FROM TABLE tab_mlbecr_delete. IF sy-subrc NE 0. s_header-text = 'Error when deleting MLBECR'. MODIFY tab_header FROM s_header. EXIT. ENDIF. ENDIF. Display source for correction Page 15 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014 ENDFORM. " ml_po_history_delete Print Display source for correction Page 16 of 16 https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/corr_instr/correction... 29/04/2014