Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Message M8 321 Document contains same order item more than once

Hi,

i process incoming invoices by means of bapi_incominginvoice_create/park

The source data is a file.

The problem arises when i process the file containing the same order item several times

in different invoices.

when the code does:

  PERFORM importing_data_check       TABLES    itemdata
                                               accountingdata
                                               taxdata
                                               withtaxdata
                                               vendoritemsplitdata
                                               glaccountdata
                                               materialdata
                                     USING     headerdata
                                               addressdata
                                               c_rbstat_posted
                                     CHANGING  return[]
                                               f_subrc.

precisely in:

*----- Prefetch PO items ---------------------------------------------*
  LOOP AT t_itemdata INTO s_itemdata.
*----- Check double PO/Item ------------------------------------------*
    f_loop_doublecheck = f_loop_doublecheck + 1.
    LOOP AT t_itemdata FROM f_loop_doublecheck
                       WHERE po_number    = s_itemdata-po_number
                        AND  po_item      = s_itemdata-po_item
                        AND  REF_DOC_YEAR = s_itemdata-REF_DOC_YEAR
                        AND  REF_DOC      = s_itemdata-REF_DOC
                        AND  REF_DOC_IT   = s_itemdata-REF_DOC_IT
                        AND  SHEET_NO     = s_itemdata-SHEET_NO
                        AND  SHEET_ITEM   = s_itemdata-SHEET_ITEM
                        AND  COND_TYPE    = s_itemdata-COND_TYPE
                        AND  COND_ST_NO   = s_itemdata-COND_ST_NO
                        AND  COND_COUNT   = s_itemdata-COND_COUNT
                        AND  FREIGHT_VEN  = s_itemdata-FREIGHT_VEN
                        AND  VALUATION_TYPE = s_itemdata-VALUATION_TYPE.

        e_subrc = 8.
        PERFORM bapireturn_fill USING  'M8'
                                       'E'
                                       '321'
                                       s_itemdata-po_number
                                       s_itemdata-po_item
                                       space
                                       space
                              CHANGING te_return.
        EXIT.

    ENDLOOP.
    IF e_subrc = 8.
      EXIT.
    ENDIF.

i get this message M8 321.

Can i process several invoices containning the same order item in the same execution of the file?

if so, how?

warning: i´ve already read this solution

(belonging to Ram Manohar Tiwari, here http://www.rmtiwari.com )

*   The following coding is to solve the problem
*   mentioned in OSS Note 518338.
*   Same PO item within several invoice items.
SORT I_ITEM BY PO_NUMBER PO_ITEM.
LOOP AT I_ITEM.

  ON CHANGE OF I_ITEM-PO_NUMBER OR I_ITEM-PO_ITEM.
    W_COUNTER = 1.
    LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
                     AND PO_ITEM   = I_ITEM-PO_ITEM.

      IF W_COUNTER EQ 1.
        I_ACCOUNTINGDATA-SERIAL_NO = '01'.
        I_ACCOUNTINGDATA-XUNPL     = ' '.
      ELSE.
        I_ACCOUNTINGDATA-SERIAL_NO = ' '.
        I_ACCOUNTINGDATA-XUNPL     = 'X'.
      ENDIF.
      MODIFY I_ACCOUNTINGDATA
       TRANSPORTING SERIAL_NO XUNPL
      WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
      W_COUNTER = W_COUNTER + 1.
    ENDLOOP.

*     To solve the repetition of PO item in subsequent invoices.
  ELSEIF SY-TABIX EQ 1.
    W_COUNTER = 1.
    LOOP AT I_ITEM WHERE PO_NUMBER = I_ITEM-PO_NUMBER
                     AND PO_ITEM   = I_ITEM-PO_ITEM.

      IF W_COUNTER EQ 1.
        I_ACCOUNTINGDATA-SERIAL_NO = '01'.
        I_ACCOUNTINGDATA-XUNPL     = ' '.
      ELSE.
        I_ACCOUNTINGDATA-SERIAL_NO = ' '.
        I_ACCOUNTINGDATA-XUNPL     = 'X'.
      ENDIF.
      MODIFY I_ACCOUNTINGDATA
       TRANSPORTING SERIAL_NO XUNPL
      WHERE INVOICE_DOC_ITEM = I_ITEM-INVOICE_DOC_ITEM.
      W_COUNTER = W_COUNTER + 1.
    ENDLOOP.

  ENDON.
ENDLOOP.
*   Changes over for  OSS Note 518338.

in this OSS Note 518338 it says:

Solution

Fill the tables as described in the documentation for the BAPI. If you want

to post unplanned account assignments for the invoice, fill field

'Unplanned account assignment from invoice verification' (XUNPL) in table

ACCOUNTINGDATA instead of field 'Serial number of account assignment'

(SERIAL_NO).

The question is that i do not have unplanned account assignment.

Any hint or suggestion would be greatly appreciated

Best regards.

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question