Miro BAPI

Hi,
I am trying to use BAPI_INCOMINGINVOICE_CREATE for MIRO transaction.  Can anyone please explain to me how to use component PROFIT_SEGM_NO in structure BAPI_INCINV_CREATE_GL_ACCOUNT?  (This is missing from the documentation as it is a 'late' addition to the BAPI).
Or:
Has anyone had success posting Incoming Invoice GL account line - with a profitability segment (COPA)?
Thanks,
Michal

Hi michal,
Look at the code in th fm:
<b>BBP_INVOICE_CREATE
MRM_XMLBAPI_INCINV_CREATE</b>
Look at this sample code
REPORT  Z_BAPI_INCOMINGINVOICE_CREATE           .
*       Create Vendor Invoices using BAPI               *
  Invoice data is sent by the vendors in a text file and an inbound
*  interface is required to create Vendor Invoices in SAP.
*  The file contains the Purchase Order information, material quantity
*  received from vendor along with the amount.
*  Here the requirement becomes a little complex as there might be
*  several ocuurences of same Purchase Order item in one  invoice.
*  Only a incomplete sample coding is given here and it can only be used
*  as a base for writing a program.
* Populate internal Table I_ITAB from the data uploaded
* from text data file.
* Populate Item Table from item data in data file
*   Processing for header records of data file.
*   set up header data for BAPI call.
*   Check whwther it's an Incoice or Credit Memo.
*   And populate Invoice indicator accordingly.
IF I_ITAB-TRANS EQ '-'.
  I_HEADER-INVOICE_IND = C_X.
ELSE.
  CLEAR I_HEADER-INVOICE_IND.
ENDIF.
I_HEADER-PSTNG_DATE = I_ITAB-BUDAT.
I_HEADER-DOC_DATE = I_ITAB-BLDAT.
I_HEADER-CURRENCY = W_WAERS.
I_HEADER-GROSS_AMOUNT = I_ITAB-DMBTR.
I_HEADER-COMP_CODE = I_ITAB-BUKRS.
I_HEADER-HEADER_TXT = I_ITAB-SGTXT.
I_HEADER-REF_DOC_NO = I_ITAB-XBLNR.
IF NOT I_ITAB-INV_REC_DATE IS INITIAL.
  I_HEADER-INV_REC_DATE = I_ITAB-INV_REC_DATE.
ELSE.
  I_HEADER-INV_REC_DATE = I_ITAB-BLDAT.
ENDIF.
I_HEADER-PYMT_METH = I_ITAB-ZLSCH.
APPEND I_HEADER.
* Populate Item Table from item data in data file
lv_count = 0.
LOOP AT I_ITAB.
*   Processing for header records of data file.
  lv_count = lv_count + 1.
* Item Data
  I_ITEM-INVOICE_DOC_ITEM = lv_COUNT.
  I_ITEM-PO_NUMBER    = I_ITAB-EBELN.
  I_ITEM-PO_ITEM      = I_ITAB-EBELP.
  I_ITEM-TAX_CODE     = I_ITAB-MWSKZ2.
  I_ITEM-ITEM_AMOUNT  = I_ITAB-NETWR.
* Populate quantities if not a blanket order
  IF I_ITAB-BLANKET EQ SPACE.
    I_ITEM-QUANTITY = I_ITAB-MENGE.
    PERFORM GET_MEINS USING I_ITAB-EBELN       " Use table EKPO
                            I_ITAB-EBELP
                      CHANGING I_ITEM-PO_UNIT.
    I_ACCOUNTINGDATA-PO_UNIT = I_ITEM-PO_UNIT.
    IF I_ITEM-QUANTITY EQ 0.
      I_ITEM-PO_UNIT = SPACE.
    ENDIF.
  ENDIF.
* Item Text
  I_ITEM-ITEM_TEXT = I_ITAB-ITEM_TEXT.
  APPEND I_ITEM.
* Populate Accounting Data
  IF I_ITAB-BLANKET EQ SPACE.
    I_ACCOUNTINGDATA-INVOICE_DOC_ITEM = lv_COUNT.
    I_ACCOUNTINGDATA-SERIAL_NO        = '01'.
    I_ACCOUNTINGDATA-TAX_CODE         = I_ITAB-MWSKZ2.
    I_ACCOUNTINGDATA-ITEM_AMOUNT      = I_ITAB-NETWR.
    SELECT SINGLE SAKTO KOSTL VBELN VBELP ANLN1 ANLN2 DABRZ
                  FISTL GEBER GRANT_NBR GSBER IMKEY KOKRS KSTRG PAOBJNR
                  PRCTR PS_PSP_PNR AUFNR MENGE
      FROM EKKN
      INTO (I_ACCOUNTINGDATA-GL_ACCOUNT, I_ACCOUNTINGDATA-COSTCENTER,
            I_ACCOUNTINGDATA-SD_DOC, I_ACCOUNTINGDATA-SDOC_ITEM,
            I_ACCOUNTINGDATA-ASSET_NO, I_ACCOUNTINGDATA-SUB_NUMBER,
            I_ACCOUNTINGDATA-REF_DATE, I_ACCOUNTINGDATA-FUNDS_CTR,
            I_ACCOUNTINGDATA-FUND, I_ACCOUNTINGDATA-GRANT_NBR,
            I_ACCOUNTINGDATA-BUS_AREA, I_ACCOUNTINGDATA-RL_EST_KEY,
            I_ACCOUNTINGDATA-CO_AREA, I_ACCOUNTINGDATA-COSTOBJECT,
           I_ACCOUNTINGDATA-PROFIT_SEGM_NO, I_ACCOUNTINGDATA-PROFIT_CTR,
            I_ACCOUNTINGDATA-WBS_ELEM, I_ACCOUNTINGDATA-ORDERID,
            I_ACCOUNTINGDATA-QUANTITY)
      WHERE EBELN EQ I_ITAB-EBELN
      AND   EBELP EQ I_ITAB-EBELP
      AND   ZEKKN EQ '01'.
    IF EKKO-BSART NE 'LTV'.
      CLEAR I_ACCOUNTINGDATA-QUANTITY.
      CLEAR I_ACCOUNTINGDATA-PO_UNIT.
    ENDIF.
    APPEND I_ACCOUNTINGDATA.
  ENDIF.
ENDLOOP.
*   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.
SORT I_ITEM BY INVOICE_DOC_ITEM PO_NUMBER PO_ITEM.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
  EXPORTING
    HEADERDATA       = I_HEADER
  IMPORTING
    INVOICEDOCNUMBER = W_BELNR
    FISCALYEAR       = W_GJAHR
  TABLES
    ITEMDATA         = I_ITEM
    ACCOUNTINGDATA   = I_ACCOUNTINGDATA
    TAXDATA          = I_TAX
    RETURN           = I_RETURN.
if sy-subrc < >  0.
  message e999(re) with  'Problem occured'.
else.
  loop at return.
    if not return is initial.
      clear bapi_retn_info.
      move-corresponding return to bapi_retn_info.
      if return-type = 'A' or return-type = 'E'.
        error_flag = 'X'.
      endif.
      append bapi_retn_info.
    endif.
  endloop.
  if error_flag = 'X'.
    message e999(re) with  'Problem occured'.
    rollback work.
  else.
     *       Return Table from BAPI call is empty
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT   = 'X'
      IMPORTING
        RETURN = I_RETURN.
  endif.
endif.
Thanks
Sudheer

Similar Messages

  • Linking of url in MIRO BAPI

    Dear MM/Bapi Experts,
    We are trying to book Miro transaction through BAPI
    "BAPI_INCOMINGINVOICE_CREATE" we are facing these issues.
    1. Our outside party vendor is scaning Invoice for us and sending the details to book invoice aloong with URL where actual phisical invoiced got store.When we are doing MIRO
    transaction we can go to Note Tab and there we can give the URL link which we can see in the Docuement,but when we are doing Miro through BAPI the same is not able to put in note tab as the field is not there in BAPI.Please tell how to put the URL in MIRO Document in case of Bapi so taht user can go and click to link and can get access to actual Invoice.
    2.We want to park the Docuement if  incoming amount coming through external system is not matching to DMBTR of EKPO, i mean if i am booikng the Invoice through MIRO then i cna very well park it also so i just wana know if after executing this bapi if transaction is not getting posted due to Amount mismatch then how to park the same throught BAPI.there is bapi to park the document also but the same we come to know after the executing this bapi that amount is not matching.
    Please reply ASAP and thanks for help in adavance

    Hi ruchi,
       i know that when recording is not happening for some fields ,but OUR  functional consultant dont know about BAPI CONCEPT, thay i will stick why possable is not from BDC so i need valid answer to tell.... like MIRO IS ENJOYABLE tcode some whar like that....Please POVIDE me valid answer so that my  putted effort will go not off.
    regards ,
    santosh
    Edited by: santosh jajur on Aug 27, 2009 12:44 PM
    Edited by: santosh jajur on Aug 27, 2009 12:46 PM

  • Miro bapi changing item

    Hi all,
    i`m looking for a BAPI wich change an invoice. I need to change field RSEG-KZMEK only but BAPI_INCOMINGINVOICE_CHANGE don`t have this field.
    What can i do?
    Thanks & sorry ab my english

    BAPI_INCOMINGINVOICE_GETDETAIL
    Please reward points if useful.

  • Extra positions MIRO

    Hi!
    We want create extra positions in an invoice created with a MIRO BAPI (BAPI_INCOMINGINVOICE_CREATE). It is possible? How we can do it?
    Thanks a lot!
    Edited by: LM on Dec 11, 2008 8:11 AM

    Hi,
    (just as a suggestion but not tested personally )
    have a look at:
    include LMR1MF0D
    form DOCUMENT_PARK
    here you have fm MRM_INVOICE_PARK
    note here that for update f_xupda must be c_update ('U')
    in order to get all the values you need for the fm you can use
    fm MRM_INVOICE_READ.
    This fm will retrieve all the data of an invoice stored in tables.
    Then you just have to add you modifications and then do as in form DOCUMENT_PARK (see above).
    Best regards.
    Edited by: Pablo Casamayor on Dec 11, 2008 8:27 AM

  • Error while using bapi BAPI_INCOMINGINVOICE_CREATE to post MIRO

    Hi Friends,
             Im using bapi BAPI_INCOMINGINVOICE_CREATE to post MIRO.
             im passing data to table GLACCOUNTDATA.
             Below are the table fields im paasing
         INVOICE_DOC_ITEM " '000001' deafault always
         GL_ACCOUNT  "Which is constant for all in my case               
         ITEM_AMOUNT      " Total PO net amt + Frieght charges header level      
         DB_CR_IND      " 'S' always default     
         COMP_CODE      " 'RPPL' always default          
         TAX_CODE      " 'V0'     deafault always     
         PROFIT_CTR       " for ex 1100180. based on plant
              While posting this bapi is trhrowing error as below
         'profit centre  RPPL/1100180 does not exist for 01.12.2008'
         where 01.12.2008 is the MIRO posting date which im passing in header.
            We checked dates for profit centres they are correct.
            Awaiting the reply ASAP.
    Regards,
    Venky

    Hi,
    It would be better if you do a recheck on data input for BAPI. If you sure the data are ok but the BAPI still gives error message, then I suggest to post to OSS.
    Regards,
    Teddy Kurniawan

  • BAPI Program -Invoice_update- For not allowing MIRO if Quality not clear

    Hello Gurus,
    Does anybody have program done for BAPI -Invoice Update
    This is for not allowing user to post MIRO-Vendor Incoming Invoice Creation & Posting if any material against that PO or GR is lying in the Quality Inspection.
    Please send if you have the same.
    Thanks
    Rahul

    hi,
       You can use user exit  --EXIT_SAPLMRMP_010 (LMR1M001)    which definitely will solve ur issue.
       revert to me if u have any doubts on it.
    murali.c

  • BAPI for MIRO Incoming Invoice

    Hi All,
    I want BAPI for MIRO Posting ie for Incoming Invoice.
    .here MIRO is being done with Delivery Note number
    Following are the necessary entries for MIRO Posting
    Invoice date
    Reference
    Amount
    Calculate Tax
    Tax amount
    Delivery Note
    Vednor
    Business Area
    Please suggest me suitable BAPI for MIRO Incoming Invoice Posting with sample code.
    immediately.Please give some sample code for my reference.
    Rewards will be given.
    Regards.
    Ulhas

    Hi,
    BAPI for Invoice Verification: Post Invoice
    BAPI_INCOMINGINVOICE_CREATE
    The method can only carry out your function if no error messages were
    generated in the Return table. This is the case if the header data and
    all the items were processed successfully.
    Transaction control is not implemented. The calling program therefore
    has to execute the Commit Work itself after this method has been
    successfully called (in other words, if no errors were reported in the
    Return parameter).

  • BAPI to hold an invoice/document in MIRO

    Hi everyone,
    I'm facing a problem trying to hold an invoice in MIRO. I'm using the bapi BAPI_INCOMINGINVOICE_PARK, but this bapi creates a parked document, and sets RBKP-RBSTAT as 'A' (Parked), and i've been reading some forums and found that a parked invoice creates also a FI document (see on BKPF + VBSEGK). What I need is to hold invoice (not to post), i mean that the value of field RBSTAT in table RBKP saved as 'D' (Entered and held).
    Is there any BAPI or FM that helps me to do that?
    Thank you

    Hi,
    in fm MRM_INVOICE_PARK you have as export parameter TE_ERRPROT.
    in the documentation button of miro it says:
    If you are interrupted while entering or parking an invoice, you can hold the data you have already entered, such as the list field selections, header data, and item data. The system creates an invoice document but does not make any checks, updates, or postings.
    The key here is: The system creates an invoice document but does not make any checks
    Bear that in mindf if you just want to hold an invoice in MIRO.
    Best regards.
    Edited by: Pablo Casamayor on Dec 10, 2010 10:02 AM

  • BAPI/FM to remove payment block on MIRO Invoice

    I need a BAPI/FM to remove a payment block on a MIRO invoice.  I realize that this has probably been answered before but, due to SDN's search feature, I haven't been able to find an answer.
    Regards,
    Davis

    Yes you are right. all methods are for price block only . sorry about that.
    How about BAPI_INCOMINGINVOICE_CHANGE and it have import header table BAPI_INCINV_CHNG_HEADER-PMNT_BLOCK

  • Issue:BAPI Reflectiin on both F-48 and MIRO

    Hi,
      I hav implemented an BAPI (FQST_CIN_WITHITEM) for the t-code f-48. The output was to open a vendor advance payment details.  But it also affects the MIRO tcode. I dont want the output in MIRO. I want to avoid it.  Help me to overcome this issue.
    Thanks and Regards,
    Karthik

    Hi Janagar,
                Thanks for your valuable reply. The issue was solved. But when i debug, the output was sy-tcode = fba7. So i changed the code as sy-tcode = fba7. But why f-48 runs fba7 tcode. Whats the difference between fba7 and f-48.
    Thanks and regards,
    Karthik

  • Periodical creation of PO-Invoice per LSMW or BAPI (MIRO)

    Hi Friends,
    i'm just wondering, what would be the best way to create purchase invoices like in MIRO, with LSMW or BAPI?
    BAPI is more flexible and easier to analyze the ERRORS?
    Thanks for your input
    Jimbob

    Hi Kris,
    I think you'r right.
    In my case a have to use the Idoc ACLPAY, ACLPAY01 as Message Type and Basis Type in LSMW.
    Furthermore I have an Input file.
    So LSMW save some time for handling the Input file.
    And regarding the error log I can read the data from the table which is used by WE05.
    With BAPI it would be easy to create log files on the basis of the returntables.
    OK. Thank you very much.
    Rg. Jimbob

  • BAPI for subsequent credit memo in MIRO transaction

    hi,
    i need to upload the data for subsequent credit memo in MIRO transaction using BAPI.
    Is there any BAPI for subsequent credit memo in MIRO transaction?
    Thanks & regards
    Prajwala

    Hi,
    I am not 100 percent sure but try this BAPI:
    BAPI_INCOMINGINVOICE_CREATE.
    Regards,
    Rahul

  • User Exits & BAPI in MIRO transaction.

    Hi all,
    We have a scenario as below.
    We are raising PO (Say PO No.1) with upper delivery tolerance as 10% at item level. The quantity upto 10% tolerance level is received via movement type 101.
    The quantity received above 10% but upto 20% is received via separate movement type say Z01 & PO No. 2 is getting created automatically.
    The quantity received above 20% is received via separate movement type say Z02 & PO No. 3 is getting created automatically.
    Now consider that Rs. 500 received through 101 movement. Rs. 200 received through Z01 movement & Rs. 100 received through Z02 movement.
    Now our requirement is as below.
    1. At the time of MIRO,  user will give  PO No. 1 as input. System should through throw message to select PO No. 2 & PO No. 3 also.
    2. Following entries should get passed.
    101 movement :   Vendor A/C Cr.   500
                                 GR/IR A/C    Dr.           500
    Z01 movement     Vendor A/C Cr.  200
                                 GR/IR A/C    Dr.           200
    Z02 movement     Provisional GL A/C Cr.  100
                                 GR/IR A/C               Dr.            100
    As regards the Z02 movement, we are passing it via GL account tab in MIRO transaction.
    After the above entries are passed, system should also raise a debit note for 50% amount of Z01 movement as below.
    Provisional GL A/C  Cr.  100
    Vendor A/C              Dr.          100
    Can any one suggest suitable user exits/BADI/BAPI to satisfy above requirement.
    Shripad

    Hi
    1. In my opinion, there is no mechanism by which you can tag PO 1/2/3... So, while entering PO1 in MIRO, I dont think there is any mechanism by which you can get a message for Po 2 and 3
    You can still try your hand at BAPI_ACC_INVOICE_RECEIPT_POST.... Or go to T code BAPI and explore the right BAPI
    2. Regarding other requirements of Z02 and Z01, you can create a Z t code using a BDC for F-02 or BAPI_ACC_DOCUMENT_POST
    br, Ajay M

  • Bapi for reversing MIRO transaction

    Hi everybody,
    i want a bapi that i can use for reversing MIRO that is posted.
    Thanks in advance.
    Abhijit D.

    hi prabhu..
    thanks for the solution.
    this is a perfect one..
    thanks again.
    hi vikas..
    i didnt try the transaction u said
    but BAPI_INCOMINGINVOICE_CANCEL works
    fine
    nways thanks for the suggestion vikas..
    Message was edited by:
            abhijit dangat

  • MIRO: EXIT_SAPLMR1M_002 & BAPI: invoice_update

    Hello,
    Can anyone tell me how to use exit EXIT_SAPLMR1M_002 in transaction MIRO? 
    I have requirements to create new line items with GL accounts and amounts.  From OSS, exit EXIT_SAPLMR1M_002, should be use.  But I cannot trigger this exit.  I have tried to figure out how  this is called, but the only thing I found is it is called in screen 210 of program SAPLMR1M.  But I could not find where or how this screen is displayed in the transaction.  I also tried using BAPI invoice_update, but I could not create any new entries because the parameters are 'importing' parameters only. 
    So, can anyone suggest on how to create new GL line items in transaction MIRO?
    This is pretty urgent because if it cannot be done with these exits, a new design solution would be necessary and I have short time-frame for development.
    Any suggestion is greatly appreciated.
    Regards,
    Anna-Liza

    Hi
    Define a variable for VORGANG and set a value in the same way that from VORGANG SAP gives values for other fields in include LMR1MF5G (FORM vorgang)
      CASE rm08m-vorgang.
        WHEN '1'.                          " Rechnung
          rbkpv-xrech      = 'X'.          " - Rechnungs-Kennzeichen
          rbkpv-tbtkz      = space.        " - Nachbelastungs-Kennzeichen
          rbkpv-xrechl     = 'S'.
          rbkpv-xrechr     = 'H'.
        WHEN '2'.                          " Gutschrift
          rbkpv-xrech      = space.
          rbkpv-tbtkz      = space.
          rbkpv-xrechl     = 'H'.
          rbkpv-xrechr     = 'H'.
        WHEN '3'.                          " nachträgliche Belastung
          rbkpv-xrech      = 'X'.
          rbkpv-tbtkz      = 'X'.
          rbkpv-xrechl     = 'S'.
          rbkpv-xrechr     = 'H'.
        WHEN '4'.                          " nachträgliche Entlastung
          rbkpv-xrech      = space.
          rbkpv-tbtkz      = 'X'.
          rbkpv-xrechl     = 'H'.
          rbkpv-xrechr     = 'S'.
    So, do the algorithm in the reverse for fields XRECH, TBTKZ, XRECHL and XRECHR in MRM_RBKPV.
    I hope this helps you
    Regards
    Eduardo

Maybe you are looking for

  • How do i find out which itunes account my ipod is sync to?

    Ive had my ipod shuffle for a few years now and haven't updated my songs since i brought it. is there a way to find out which itunes library i oringally connected it to?

  • Table EKPO - PO Active/Closed Indicator field exist ?

    Hi, I am not an MM guy. But, i am writing a report based on MM. I would like to know, whether any indicator field exist in EKPO table, that will give the status of an PO for a given material ? If exist, what is the name of the field and what value do

  • Problem in primary key column where user does typo error.

    Hi all, I have a primary key in the table that some part of it was the current date. For example if today date is 3rd May then it will contain xxxxxx-0503 (where xxxxxx will be unique for this day). In order save time needed to enter the data, I achi

  • How can I find a IPhone 4S if it is off?

    How can I find a IPhone 4S if it is off?

  • Videos in the iphoto library

    Is there a way of sifting out the videos from the iPhoto library while in iMovie (10.0.3) apart from opening every event and then importing them into imovie? My iPhoto library is large at 20000+ but there are apparently 400 videos hidden in there I w