Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_INCOMINGINVOICE_CREATE problem checking FI Doc.

Former Member
0 Likes
1,299

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

5 REPLIES 5
Read only

krishna_k19
Contributor
0 Likes
1,016

Hi Mario ,

    Can you post your code including commit work.

It's a miracle for wait statement is not working?.

Regards,

Krishna

Read only

0 Likes
1,016

*-- 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.

Read only

0 Likes
1,016

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

Read only

0 Likes
1,016

Did your issue get resolved???

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,016

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