on 07-02-2010 10:06 AM
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.
Pablo,
I'd suggest registering a message on OSS. The error message and the rest of the code is there for a reason though, at least in theory, in terms of entering multiple invoices there is no reason why it should not be possible to process different invoices for the same PO item. Perhaps there's an issue with this via BAPI that isn't obvious.
I did note the comment line says Prefetch PO items, which tends to imply it considers all PO items are considered to be for a single invoice ??
Regards,
Nick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Check note 103051 or 661864
thanks
G. Lakshmipathi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This is what i guess it´s happening:
- In our system we have Goods Receipt.
- By functional specification if an invoice of the file contains errors, then the invoice is "Held" in sap.
- When we process the file, the first document contains errors and then it is held in sap.
- When the turn comes for the next document (containing the same ordem item) to be processed,
the logic of the program proposes the same reference and so message M8 321 is raised.
Here i have some doubts:
1.- is the logic of the program correct?
that is, no invoice should be processed until the problem with the first one is solved?
2.- if an invoice is held, what happens with Goods receipt?
when does the system assign a GR to an invoice ?
is it when it is saved as complete or when posted ?
3.- How can i deal with this GR assignment to invoices?
Best regards
Edited by: Pablo Casamayor on Jul 19, 2010 9:44 AM
Hi!
In your BAPI programs, you can not fill 2 or more invoice's items
with same reference data into the BAPI interface table ITEMDATA.
In your input data for BAPI with multi acc.assignment you should fill
only one entry in ITEMDATA for given PO and more entries in
ACCOUNTINGDATA, each for a different SERIAL_NO.
When you use multiple account assignment in BAPI_INCOMINGINVOICE_CREATE
then you have to fill the SERIAL_NO manually in the interface of bapi.
Serial_No should contain 01,02 so on depending upon number of account
assingnments the PO item has it. You can see the PO in transaction ME23N
and then fill SERIAL_NO in the BAPI.
Otherwise it can cause others problems in GR/IR account in the FI DOC
and PO history, as well as in the further invoice processes reference to
the PO/item (ex. MR8M, MR11, or create another new MM-invoice DOCs).
For more information on this please review the following attached notes:
972627 BAPI: Message M8 321 is displayed for no reason
512282 BAPIs: Service-based invoice verification.
Please check also the following information:
After applying the note 661864 the standard system doesn't support
several invoice items reference to same PO/item and GR/item in the
BAPI process anymore. Mainly this note was developed to avoid short
dump. Now the message M8321 is issued.
As you create MM-invoice using on-line transactions (ex MIRO), automatic
processes (ERS, EDI) or BAPI as well, system will create or accept
the invoice item in this way:
Each item for a different reference data (EBELN,EBELP,LFGJA,LFBNR,LFPOS
for normal PO, as well as PACKNO and INTROW for service PO):
EBELN: PO's No.
EBELP: PO's item No.
LFGJA: original GR's year,
LFBNR: original GR's No.
LFPOS: original GR's item No.
If the PO is with indicator 'GR based-IV'='X', the reference data (LFGJA
LFBNR and LFPOS) must not be space. It means, you can't create an
invoice reference to the PO before posting of the corresponding GR DOC,
and one invoice item must be reference only to one GR DOC/item.
Otherwise if the PO is with 'GR based-IV' = ' ', the reference data
(LFGJA,LFBNR and LFPOS) are always space, you can create an invoice
reference to the PO before the GR DOC or without GR DOC, or one invoice
item can be reference to more GR DOC/items.
And the concept is valid for the PO with 'GR based-IV' or without it.
Best regards
Erika
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.