<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: BAPI_INCOMINGINVOICE_CREATE - Error in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310641#M1636439</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob and Pablo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quicks replys, both helped me to understand that i was referencing to a wrong Material Document. The functional told me that I have to use the one that was created on Migo with Movement type 101 ( the one that was made when the goods were sent to the customer) and not the return one that I've created.&lt;/P&gt;&lt;P&gt;Ok, so far so good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got it through, I had some other mistakes as well, doc_type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you both for your help.&lt;/P&gt;&lt;P&gt;Really apreciate it !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 03 Nov 2011 15:48:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-11-03T15:48:18Z</dc:date>
    <item>
      <title>BAPI_INCOMINGINVOICE_CREATE - Error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310638#M1636436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm creating an credit invoice that a return.&lt;/P&gt;&lt;P&gt;I've done succesfully the following steps: VA01, VL01N, VF01 and MIGO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here goes my codding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

  DATA: l_headerdata TYPE bapi_incinv_create_header.
  DATA: l_invoicedocnumber TYPE bapi_incinv_fld-inv_doc_no.
  DATA: lt_return  TYPE STANDARD TABLE OF bapiret2.
  DATA: lt_itemdata TYPE STANDARD TABLE OF bapi_incinv_create_item.
  DATA: ls_itemdata TYPE bapi_incinv_create_item.
  DATA: ls_goodsmvt_item TYPE bapi2017_gm_item_create.


  READ TABLE lt_zvpfpdev INTO ls_zvpfpdev INDEX 1.
  READ TABLE lt_goodsmvt_item INTO ls_goodsmvt_item INDEX 1.


  IF ls_zvpfpdev-belnr_fp IS INITIAL.

    DATA: ls_vbrk TYPE vbrk.

    SELECT SINGLE * FROM vbrk
      INTO ls_vbrk
    WHERE vbeln EQ ls_zvpfpdev-vbeln_pi.

***COPIADO DA MIGO*********
    DATA: lt_mseg TYPE STANDARD TABLE OF mseg.
    DATA: ls_mseg TYPE mseg.
    FIELD-SYMBOLS: &amp;lt;mseg&amp;gt; TYPE mseg.



    SELECT * FROM mseg
      INTO TABLE lt_mseg
      WHERE mblnr = ls_zvpfpdev-mblnr_101
      AND   mjahr = sy-datum(4).

******************
    DATA: lt_ekbe TYPE STANDARD TABLE OF ekbe.
    DATA: ls_ekbe TYPE ekbe.

    READ TABLE lt_mseg INTO ls_mseg INDEX 1.

    SELECT * FROM ekbe
      INTO TABLE lt_ekbe
      WHERE ebeln = ls_mseg-ebeln
      AND   belnr = ls_zvpfpdev-mblnr_101
      AND     gjahr = sy-datum(4).


    READ TABLE lt_ekbe INTO ls_ekbe INDEX 1.

***COPIADO DA MIGO*********

    l_headerdata-doc_type = 'DC'.
    l_headerdata-doc_date = sy-datum.
    l_headerdata-pstng_date = sy-datum.
    l_headerdata-ref_doc_no = ls_zvpfpdev-vbeln_d_fp.
    l_headerdata-header_txt = 'Devoluções Pasta Fine Paper à Portucel'.
    l_headerdata-calc_tax_ind = 'X'.
    l_headerdata-bline_date = sy-datum.
    l_headerdata-gross_amount = ls_vbrk-netwr - ls_vbrk-mwsbk. " + ou - ??

******************
    l_headerdata-currency     = ls_ekbe-waers.
    l_headerdata-bline_date   = sy-datum.

    l_headerdata-comp_code    = 'P168'. "ls_ekko-bukrs.




    DATA: n TYPE i.
*  if p_id = 'CPST1' and p_bukrs = 'PI10' and zsdvdesp-bukrs_c = 'P160'.
*    tab_itemdata-quantity         = vbrp-fkimg * 1000.
*  else.




    LOOP AT lt_goodsmvt_item INTO ls_goodsmvt_item.
      n = n + 10.
CLEAR: LS_EKBE.
read table LT_EKBE INTO LS_EKBE WITH KEY CHARG = ls_goodsmvt_item-BATCH.

      ls_itemdata-invoice_doc_item = n.
      ls_itemdata-po_number = ls_goodsmvt_item-po_number.
      ls_itemdata-po_item   =   ls_goodsmvt_item-po_item.
      ls_itemdata-po_unit   =   ls_goodsmvt_item-base_uom.



***TEST*****
      ls_itemdata-ref_doc_year =   ls_goodsmvt_item-ref_doc_yr.
      ls_itemdata-ref_doc_it   =   ls_goodsmvt_item-ref_doc_it.
      ls_itemdata-ref_doc      =   ls_goodsmvt_item-ref_doc.
      ls_itemdata-quantity     =   ls_goodsmvt_item-quantity.

***TEST*****




      ls_itemdata-tax_code = 'MW'.
     ls_itemdata-de_cre_ind = 'X'.
      ls_itemdata-ITEM_AMOUNT = LS_EKBE-WRBTR.

      APPEND ls_itemdata TO lt_itemdata.
      CLEAR: ls_itemdata.
    ENDLOOP.



    CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
      EXPORTING
        headerdata                = l_headerdata
*   ADDRESSDATA               =
     IMPORTING
       invoicedocnumber          = l_invoicedocnumber
*   FISCALYEAR                =
      TABLES
        itemdata                  = lt_itemdata
*   ACCOUNTINGDATA            =
*   GLACCOUNTDATA             =
*   MATERIALDATA              =
*   TAXDATA                   =
*   WITHTAXDATA               =
*   VENDORITEMSPLITDATA       =
        return                    = lt_return
*   NFMETALLITMS              =
              .

    IF l_invoicedocnumber IS NOT INITIAL.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
   EXPORTING
     WAIT          = 'X'
*   IMPORTING
*     RETURN        =
            .

      LOOP AT lt_zvpfpdev ASSIGNING &amp;lt;zvpfpdev&amp;gt;.
        &amp;lt;zvpfpdev&amp;gt;-belnr_fp = l_invoicedocnumber.
      ENDLOOP.

      MODIFY zvpfpdev FROM TABLE lt_zvpfpdev.

    ENDIF.

  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is comming back with the error: MSGID - M8 - MESSAGE - 080&lt;/P&gt;&lt;P&gt;Its something about the Quantity of the return is bigger than the invoices. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure that we got a invoice of 100k, and i'm testing this with just 2k.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea ? The functional says everything is alright, that it should go through, but I'm stuck and with this, since friday, and I cannot see anything ..&lt;/P&gt;&lt;P&gt;Help please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 15:45:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310638#M1636436</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-02T15:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_INCOMINGINVOICE_CREATE - Error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310639#M1636437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check the document history for the order. It will tell you if other returns were made.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 16:01:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310639#M1636437</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-02T16:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_INCOMINGINVOICE_CREATE - Error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310640#M1636438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put a break-point in function module MRM_QUANTITY_CHECK and check what is going on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 16:08:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310640#M1636438</guid>
      <dc:creator>former_member182371</dc:creator>
      <dc:date>2011-11-02T16:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_INCOMINGINVOICE_CREATE - Error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310641#M1636439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rob and Pablo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the quicks replys, both helped me to understand that i was referencing to a wrong Material Document. The functional told me that I have to use the one that was created on Migo with Movement type 101 ( the one that was made when the goods were sent to the customer) and not the return one that I've created.&lt;/P&gt;&lt;P&gt;Ok, so far so good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got it through, I had some other mistakes as well, doc_type.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you both for your help.&lt;/P&gt;&lt;P&gt;Really apreciate it !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 15:48:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310641#M1636439</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-03T15:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_INCOMINGINVOICE_CREATE - Error</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310642#M1636440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The error was on the reference document.&lt;/P&gt;&lt;P&gt;You must reference to the material document with the type 101, and not the 122 ( Return to Vendor ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Nov 2011 15:49:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-incominginvoice-create-error/m-p/8310642#M1636440</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-03T15:49:18Z</dc:date>
    </item>
  </channel>
</rss>

