關於通過報表來分析GR收貨時M7064消息錯誤的具體原因的說明
作者:袁雲飛(AlbertYuan)- 微信號yuanalbert
以下內容均爲原創,希望對初學者有一些輔助作用,本人主要從事MM/QM/WM的相關工作,不專業處請多多指點,十足乾貨,碼字不易,且行且珍惜,你們的關注就是我努力的動力,轉載請引用出處,感激不盡;
小夥伴們可能常常在使用MIGO收貨的時候你遇到系統提示“M7064 "Document & & & does not contain any selectable items”,但系統並沒有給你提供具體是由於PO何種原因造成;
所以我們可以利用一個報表去檢查PO/SA具體的不能執行收貨的詳細原因,這其實是一個SAP提供給我們的一個輔助程序,如果小夥伴們需要使用或研究,可以直接拷貝我貼出的代碼,創建自己的報表程序即可使用,非常方便;我分析完該程序後,總結出這個程序檢查如下的一些內容,換句話說這些內容就是決定是否能被GR的前提條件:所以小夥伴們如果嫌麻煩可以直接使用這個報表去查詢,可以直接交給用戶進行自查,或者自己通過這幾個前提條件去具體分析;
下面是系統提報M7064錯誤消息的13個需要去檢查的條件:
- 檢查憑證的類別,F表示PO,L表示計劃協議SA;
- 檢查PO/SA是否標記了刪除
- 檢查PO/SA是否被凍結;
- 檢查PO/SA是否已經被完全審批下達成功;
- 檢查PO是否處於HOLD狀態;
- 檢查是否PO/SA已經完成了收貨記賬了;
- 檢查是否PO是一個外部服務訂單;
- PO是否是一個BLANKET訂單;
- 是否是一個文本項目訂單;
- 是否是一個具備統計行項目的訂單;
- 是否PO/SA的GR指示器被選中;
- 檢查是否確認控制鍵被激活,而且確認confirmation還沒有完成所需步驟;
- 檢查是否SA存在有效的計劃交貨行數據;
下面是該報表的源代碼,需要的小夥伴拷貝創建自己的一個Report即可使用;
*&---------------------------------------------------------------------*
*& Report ZCHECKPO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
*$*$----------------------------------------------------------------$*$*
*$ Correction Inst. 0120031469 0000419871 $*
*$--------------------------------------------------------------------$*
*$ Valid for : $*
*$ Software Component SAP_APPL SAP Application $*
*$ Release 470 All Support Package Levels $*
*$ Release 500 All Support Package Levels $*
*$ Release 600 All Support Package Levels $*
*$--------------------------------------------------------------------$*
*$ Changes/Objects Not Contained in Standard SAP System $*
*$*$----------------------------------------------------------------$*$*
*&--------------------------------------------------------------------*
*& Object REPS ZCHECKPO
*& Object Header PROG ZCHECKPO
*&--------------------------------------------------------------------*
*& REPORT ZCHECKPO
*&--------------------------------------------------------------------*
*>>>> START OF INSERTION <<<<
REPORT ZCHECKPO.
*&---------------------------------------------------------------------*
*& Global declarations
*&---------------------------------------------------------------------*
*Variables which include the messages
CONSTANTS:
info1(100) TYPE C VALUE
'This document category is not supported.',
info2(100) TYPE C VALUE
'The purchase order item is deleted.',
info2_1(100) TYPE C VALUE
'The scheduling agreement is deleted.',
info3(100) TYPE C VALUE
'The purchase order is blocked.',
info3_1(100) TYPE C VALUE
'The scheduling agreement is blocked.',
info4(100) TYPE C VALUE
'The purchase order is not released.',
info4_1(100) TYPE C VALUE
'The scheduling agreement is not released.',
info5(100) TYPE C VALUE
'The purchase order is put on hold.',
info6(100) TYPE C VALUE
'The goods receipt was already posted.',
info7(100) TYPE C VALUE
'The item category is purchase order for external service.',
info7_1(100) TYPE C VALUE
'The item category in the scheduling agreement is not correct.',
info8(100) TYPE C VALUE
'The item category is blanket purchase order.',
info8_1(100) TYPE C VALUE
'The item category in the scheduling agreement is not correct.',
info9(100) TYPE C VALUE
'The item category is text item.',
info10(100) TYPE C VALUE
'The purchase order contains a statistic item.',
info10_1(100) TYPE C VALUE
'The scheduling agreement contains a statistic item.',
info11(100) TYPE C VALUE
'The goods receipt indicator in the purchase order is not set.',
info11_1(100) TYPE C VALUE
'The goods receipt indicator in the scheduling agreement is not set.',
info12(100) TYPE C VALUE 'The confirmation control is active but the confirmed quantity is smaller than the GR quantity.',
info13(100) TYPE C VALUE
'The delivery date of this scheduling agreement is not today.',
info14(100) TYPE C VALUE
'The purchase order (item) is OK.',
info14_1(100) TYPE C VALUE
'The scheduling agreement (item) is OK.'.
*Creation of an internal structure for the later display
TYPES: BEGIN OF struc1,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
MESSAGE(100) TYPE C,
eindt TYPE eket-eindt,
etenr TYPE eket-etenr,
l_menge_ekbe TYPE ekbe-menge,
l_menge_ekbe1 TYPE ekbe-menge,
l_menge_ekes1 TYPE ekes-menge,
END OF struc1.
*Creation of internal tables, workareas and variables
DATA: ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
it_out TYPE STANDARD TABLE OF struc1,
wa_out LIKE LINE OF it_out,
lt_ekpo TYPE TABLE OF ekpo WITH NON-UNIQUE KEY ebeln ebelp,
wa_ekpo LIKE LINE OF lt_ekpo,
lt_ekko TYPE TABLE OF ekko WITH NON-UNIQUE KEY ebeln,
wa_ekko LIKE LINE OF lt_ekko,
lt_ekbe TYPE TABLE OF ekbe,
wa_ekbe LIKE LINE OF lt_ekbe,
lt_eket TYPE STANDARD TABLE OF eket,
wa_eket LIKE LINE OF lt_eket,
lt_ekes TYPE STANDARD TABLE OF ekes,
wa_ekes LIKE LINE OF lt_ekes,
lt_t163g TYPE TABLE OF t163g,
wa_t163g LIKE LINE OF lt_t163g,
l_ebeln1 TYPE ekpo-ebeln,
l_ebelp1 TYPE ekpo-ebelp,
l_ebeln2 TYPE ekpo-ebeln,
l_ebelp2 TYPE ekpo-ebelp,
l_ebeln3 TYPE ekpo-ebeln,
l_ebelp3 TYPE ekpo-ebelp,
l_ekbe_menge TYPE ekbe-menge,
l_ekes_menge TYPE ekes-menge.
*&---------------------------------------------------------------------*
*& Initialization and selection
*&
*&---------------------------------------------------------------------*
INITIALIZATION.
*Build a selection-screen for purchase order numbers
SELECT-OPTIONS document FOR ebeln OBLIGATORY.
SELECT-OPTIONS item FOR ebelp.
AT SELECTION-SCREEN.
*Select the relevant fields from the table EKPO
SELECT * FROM ekpo
INTO TABLE lt_ekpo
WHERE ebeln IN document
AND ebelp IN item.
*Exception
IF sy-subrc NE 0.
MESSAGE s019(06) WITH document.
* Beleg & ist nicht vorhanden
EXIT.
ENDIF.
*&---------------------------------------------------------------------*
*& Start of selection
*&
*&---------------------------------------------------------------------*
START-OF-SELECTION.
LOOP AT lt_ekpo INTO wa_ekpo.
*Select the relevant fields from the table EKKO
SELECT * FROM ekko INTO TABLE lt_ekko
WHERE ebeln = wa_ekpo-ebeln.
*Select the relevant fields from the table T163G
SELECT * FROM t163g INTO TABLE lt_t163g.
LOOP AT lt_ekko INTO wa_ekko.
*&---------------------------------------------------------------------*
*& Testing
*&
*&---------------------------------------------------------------------*
*For later output
wa_out-ebeln = wa_ekpo-ebeln.
wa_out-ebelp = wa_ekpo-ebelp.
*1.Test: Is the document type correct?
IF wa_ekko-bstyp <> 'F' AND wa_ekko-bstyp <> 'L'.
wa_out-MESSAGE = info1.
APPEND wa_out TO it_out.
CONTINUE.
ENDIF.
*2.Test: Is the purchase order/scheduling agreement item deleted?
CASE wa_ekpo-loekz.
WHEN 'L'.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info2. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info2_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
*3.Test: Is the purchase order/scheduling agreement blocked?
WHEN 'S'.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info3. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info3_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
ENDCASE.
*4.Test: Is the purchase order/scheduling agreement released?
IF NOT wa_ekko-frgrl IS INITIAL.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info4. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info4_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
*5.Test: Is the purchase order held?
IF NOT wa_ekko-MEMORY IS INITIAL.
wa_out-MESSAGE = info5.
APPEND wa_out TO it_out.
ENDIF.
*6.Test: Was the goods receipt already posted?
*Select the relevant fields from the table EKBE into the workarea
SELECT * FROM ekbe INTO TABLE lt_ekbe
WHERE ebeln = wa_ekpo-ebeln
AND vgabe = '1'.
CLEAR l_ekbe_menge.
LOOP AT lt_ekbe INTO wa_ekbe
WHERE ebeln = wa_ekpo-ebeln
AND ebelp = wa_ekpo-ebelp.
IF wa_ekbe-shkzg = 'H'.
l_ekbe_menge = l_ekbe_menge - wa_ekbe-menge.
ELSE.
l_ekbe_menge = l_ekbe_menge + wa_ekbe-menge.
ENDIF.
ENDLOOP.
*Test for output of the GR quantity
IF NOT lt_ekbe IS INITIAL.
IF wa_ekbe-menge <= l_ekbe_menge.
wa_out-MESSAGE = info6.
wa_out-l_menge_ekbe = l_ekbe_menge.
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
*7.Test: Is the item category a purchase order/scheduling agreement for
*external service?
IF wa_ekpo-pstyp <> 0.
IF wa_ekpo-pstyp = 9.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info7. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info7_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
*8.Test: Is the item category a blanket purchase order/scheduling
*agreement?
ELSEIF wa_ekpo-pstyp = 1.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info8. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info8_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
*9.Test: Is the item category a text item?
ELSEIF wa_ekpo-pstyp = 6.
wa_out-MESSAGE = info9.
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
*10.Test: Does the purchase order/scheduling agreement contain a
*statistic item?
IF NOT wa_ekpo-stapo IS INITIAL.
IF wa_ekpo-loekz IS INITIAL.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info10. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info10_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
ENDIF.
*11.Test: Is the goods receipt indicator in the purchase
*order/scheduling agreement set?
IF wa_ekpo-pstyp = 6.
ELSE.
IF wa_ekpo-wepos IS INITIAL.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info11. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info11_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
ENDIF.
*12.Test: Is there any confirmation available?
IF NOT wa_ekpo-bstae IS INITIAL.
LOOP AT lt_t163g INTO wa_t163g
WHERE bstae = wa_ekpo-bstae.
*Test if the GR-relevant and the GR assignment indicators are set
IF NOT wa_t163g-werel IS INITIAL AND
NOT wa_t163g-wezuo IS INITIAL.
*Select the relevant fields from the table EKES into the workarea
SELECT * FROM ekes INTO TABLE lt_ekes
WHERE ebeln = wa_ekpo-ebeln
AND ebelp = wa_ekpo-ebelp.
CLEAR l_ekes_menge.
LOOP AT lt_ekes INTO wa_ekes.
l_ekes_menge = l_ekes_menge + wa_ekes-menge.
ENDLOOP.
*Test for output if the confirmed quantity is smaller than or equal the
*GR quantity
IF l_ekes_menge <= wa_ekbe-menge.
wa_out-MESSAGE = info12.
wa_out-l_menge_ekbe1 = wa_ekbe-menge.
wa_out-l_menge_ekes1 = l_ekes_menge.
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
*13.Test: Are there any scheduling agreement delivery schedule lines?
*Select the relevant fields from the table EKET into the workarea
SELECT * FROM eket INTO TABLE lt_eket
WHERE ebeln = wa_ekpo-ebeln.
*Source data
LOOP AT lt_eket INTO wa_eket
WHERE ebeln = wa_out-ebeln
AND ebelp = wa_out-ebelp.
IF wa_ekko-bstyp = 'L'.
*Test if the date of the several delivery schedule lines is today
IF wa_eket-eindt <> sy-datum.
wa_out-eindt = wa_eket-eindt.
wa_out-etenr = wa_eket-etenr.
wa_out-MESSAGE = info13.
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
ENDLOOP.
*The purchase order/scheduling agreement is ok
IF wa_out-MESSAGE IS INITIAL.
IF wa_ekko-bstyp = 'F'.
wa_out-MESSAGE = info14. "purchase order
APPEND wa_out TO it_out.
ELSE.
wa_out-MESSAGE = info14_1. "scheduling agreement
APPEND wa_out TO it_out.
ENDIF.
ENDIF.
*Clear the workareas before the next purchase order is selected
CLEAR: wa_ekpo,
wa_ekko,
wa_eket,
wa_ekes,
wa_ekbe,
wa_out,
wa_t163g.
ENDLOOP.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Display the result
*&---------------------------------------------------------------------*
*Sort the internal table
SORT it_out BY ebeln ebelp.
*Test for availability
IF sy-subrc = 4.
MESSAGE s019(06) WITH document-low.
* Beleg & ist nicht vorhanden
ENDIF.
* Tests for output
IF sy-subrc = 0.
LOOP AT it_out INTO wa_out.
IF wa_out-ebeln = l_ebeln1
OR l_ebeln1 IS INITIAL.
ELSE.
ULINE.
ENDIF.
IF wa_out-ebelp = l_ebelp1
OR l_ebelp1 IS INITIAL.
ENDIF.
IF NOT wa_out-eindt IS INITIAL.
WRITE: / wa_out-ebeln COLOR 1,
/ wa_out-ebelp COLOR 3,
/ wa_out-MESSAGE,
/ 'Delivery schedule line: ', wa_out-etenr COLOR 7, ' ',
'Delivery date: ', wa_out-eindt COLOR 7,
/.
ELSEIF wa_out-MESSAGE = info6 AND wa_out-l_menge_ekbe <> 0.
WRITE: / wa_out-ebeln COLOR 1,
/ wa_out-ebelp COLOR 3,
/ wa_out-MESSAGE,
/ 'GR quantity = ', wa_out-l_menge_ekbe,
/.
ELSEIF wa_out-MESSAGE = info12 AND wa_out-l_menge_ekes1 <> 0
AND wa_out-l_menge_ekbe <> 0.
WRITE: / wa_out-ebeln COLOR 1,
/ wa_out-ebelp COLOR 3,
/ wa_out-MESSAGE,
/ 'Confirmed quantity = ', wa_out-l_menge_ekes1,
/ 'GR quantity = ', wa_out-l_menge_ekbe,
/.
ELSE.
WRITE: / wa_out-ebeln COLOR 1,
/ wa_out-ebelp COLOR 3,
/ wa_out-MESSAGE,
/.
ENDIF.
HIDE: wa_out-ebeln,
wa_out-ebelp. .
l_ebeln1 = wa_out-ebeln.
l_ebelp1 = wa_out-ebelp.
CLEAR: wa_out.
ENDLOOP.
ULINE.
ENDIF.
*>>>> END OF INSERTION <<<<<<
...
*&--------------------------------------------------------------------*
以上爲本章全部內容,希望對小夥伴們有所幫助;