2015 Jan 27 11:00 AM
Hello,
I am using BAPI BAPI_INCOMINGINVOICE_CREATE in a Z FM to create Invoice. This is working correctly. But we need to show the Financial Document associated in BKPF. If I run the FM directly, it does not return the FI doc, but if I do it in debug, it works well. I tried putting a WAIT command of a few seconds an it also worked, but this is not a solution.
I tried the COMMIT and BAPI COMMIT with the WAIT option, but also with no success.
Any ideias?
Yhank you
2015 Jan 27 11:26 AM
Hi Mario ,
Can you post your code including commit work.
It's a miracle for wait statement is not working?.
Regards,
Krishna
2015 Jan 27 11:36 AM
*-- Criar Nota de Crédito
CALL FUNCTION 'ZBAPI_INCOMINGINVOICE_CREATE'
EXPORTING
headerdata = ls_header
IMPORTING
invoicedocnumber = l_inv_doc_no
fiscalyear = l_fisc_year
TABLES
itemdata = it_items
return = lt_return1.
APPEND LINES OF lt_return1 TO return.
*-- Verifica se aconteceram erros na Criação da Nota de Crédito
LOOP AT lt_return1 INTO ls_return WHERE type EQ 'E'. ENDLOOP.
IF sy-subrc NE 0.
CHECK l_inv_doc_no IS NOT INITIAL.
COMMIT WORK AND WAIT. " Tried this and BAPI_TRANSACTION_COMMIT
*-- OUTPUT --------------------------------------------
inv_doc_no = l_inv_doc_no.
fisc_year = l_fisc_year.
*------------------------------------------------------
*-- Obter a Fatura Financeira na BKPF
SELECT SINGLE * FROM rbkp INTO ls_rbkp_inv
WHERE bukrs EQ comp_code
AND belnr EQ l_inv_doc_no
AND gjahr EQ l_fisc_year.
IF sy-subrc EQ 0.
CONCATENATE ls_rbkp_inv-belnr ls_rbkp_inv-gjahr
INTO l_awkey.
SELECT SINGLE * FROM bkpf INTO ls_bkpf
WHERE bukrs EQ ls_rbkp_inv-bukrs
AND gjahr EQ ls_rbkp_inv-gjahr
AND xblnr EQ ls_rbkp_inv-xblnr
AND awkey EQ l_awkey.
IF sy-subrc EQ 0.
*-- OUTPUT --------------------------------------------
ac_doc_no = ls_bkpf-belnr. " ---------------------------------------------- Cant get this!
*------------------------------------------------------
ENDIF.
ENDIF.
2015 Jan 27 11:45 AM
Hi Mario ,
This statement is causing the error.
LOOP AT lt_return1 INTO ls_return WHERE type EQ 'E'. ENDLOOP.
IF sy-subrc NE 0.
because if the last line is having the warring or information message means the return value sy-subrc value is eq to 0.
so try to keep read table or before that maintain in another table and delete the non-error messages then do the same.
Thanks,
Krishna
2015 Jan 30 11:46 AM
2015 Jan 30 12:31 PM
Does your ZBAPI_INCOMINGINVOICE_CREATE FM contain a COMMIT WORK/BAPI_TRANSACTION_COMMIT without wait option, in this case, execution of a second commit has no longer any effect (too late)
You could also execute the SELECT BYPASSING BUFFER, also you could do it in a DO some TIMES/ENDDO til database updated and buffer refreshed with a WAIT UP TO 1 SECONDS when not read.
Regards,
Raymond