Bapi to post planned delivery cost of a purchase order

Hi every body,
         Can anybody please give me the full details of the planned delivery cost data
to post with BAPI_INCOMINGINVOICE_CREATE
what are the manditory fields,
I am using the following code , but  a few are posting , remaining r not posting
but when I post the same through MIRO it is posted what is difference
this error was came
ERROR: enter good reciept data only when working with GR-based IV
REPORT  ZBAPI_MIRO                              .
tables: ekko,ekbe,ekpo,lfa1,EKBZ,t000.
data: itemdata like BAPI_INCINV_CREATE_ITEM occurs 0 with header line,
  headerdata like BAPI_INCINV_CREATE_HEADER occurs 0 with header line,
     return like BAPIRET2 occurs 0 with header line,
     DOC_NO LIKE BAPI_INCINV_FLD-INV_DOC_NO,
     FISC_YEAR LIKE BAPI_INCINV_FLD-FISC_YEAR.
DATA:error_flag.
data: item_data like EK08BN occurs 0 with header line.
data: begin of  itab occurs 0,
             p_order like ekpo-ebeln,
             p_item like ekpo-ebelp,
             p_ctype like konv-kschl,
             p_lifnr like lfa1-lifnr,
      end of itab.
data:  order(10) type N,
      vendor(10) type N.
data: begin of it_doc occurs 0,
            DOC_NO LIKE BAPI_INCINV_FLD-INV_DOC_NO,
            p_order like  ekko-ebeln,
      end of it_doc.
PARAMETERS:  fn LIKE rlgrap-filename OBLIGATORY.
DATA: FN1 TYPE STRING,
     l .
AT SELECTION-SCREEN ON VALUE-REQUEST FOR fn. "p_file.
  CALL FUNCTION 'F4_FILENAME'
       EXPORTING
            field_name = 'FN'
       IMPORTING
            file_name  = fn.
START-OF-SELECTION.
   FN1 = FN.
PERFORM upload.
loop at itab.
CLEAR: EKBZ,EKPO,LFA1,ITEM_DATA,HEADERDATA,itemdata.
REFRESH:itemdata,HEADERDATA,ITEM_DATA.
order = itab-p_order.
itab-p_order = order.
vendor = itab-P_lifnr.
itab-p_lifnr = vendor.
select single * from ekbz where ebeln = order
                           and ebelp = itab-p_item
                          and kschl = itab-p_ctype
                          and bewtp = 'F'.
select single * from ekpo where ebeln = order
                       and ebelp = itab-p_item.
SELECT SINGLE * FROM LFA1 WHERE LIFNR = vendor.
clear: item_data.
refresh:item_data.
call function 'ME_READ_COND_INVOICE'
   exporting
   I_BUDAT            =
    I_EBELN            = itab-p_order
    I_EBELP            = itab-p_item
   I_FRBNR            = ' '
     i_lifnr            = ' '
   I_XBLNR            = ' '
   RE_KURSF           =
   RE_WAERS           =
   I_RESWK            = ' '
   I_EKKI             = 'X'
   I_BUBIS            =
   RE_WWERT           =
   XEK08B_FLAG        =
   I_BELNR            =
   I_BUZEI            =
   I_READ_KRUEK       = ' '
   I_DISPLAY          = ' '
  TABLES
    XEK08BN            = item_data
   XEK08BN_CURR       =
read table item_data with key kschl = itab-P_ctype.
headerdata-INVOICE_IND = 'X'.
headerdata-DOC_TYPE = 'KR'.
headerdata-DOC_DATE = ekbz-budat.
headerdata-PSTNG_DATE = SY-DATUM.
headerdata-REF_DOC_NO = itab-P_ORDER.
headerdata-COMP_CODE = 'HPL'.
headerdata-DIFF_INV = itab-p_lifnr.
headerdata-CURRENCY_ISO = ekbz-waers.
headerdata-GROSS_AMOUNT = item_data-WEWWR - item_data-AREWR .
headerdata-BLINE_DATE = SY-DATUM.
headerdata-DEL_COSTS_TAXC = 'V0'.
headerdata-PO_REF_NO = itab-P_ORDER.
headerdata-bus_area = 'OTHR'.
headerdata-ITEM_TEXT = LFA1-NAME1.
*headerdata-HEADER_TXT = .
headerdata-ALLOC_NMBR = itab-P_ORDER.
  APPEND HEADERDATA.
CLEAR HEADERDATA.
itemdata-INVOICE_DOC_ITEM = '00001' .
itemdata-PO_NUMBER = itab-P_ORDER.
itemdata-PO_ITEM = itab-P_ITEM.
*itemdata-REF_DOC = ekbz-belnr.
itemdata-REF_DOC_YEAR = ekbz-gjahr.
itemdata-REF_DOC_IT = itab-P_ITEM.
itemdata-TAX_CODE = 'V0'.
itemdata-ITEM_AMOUNT = item_data-WEWWR - item_data-AREWR .
itemdata-QUANTITY = item_data-BPWEM - item_data-BPREM .
itemdata-PO_UNIT = ekpo-meins.
itemdata-PO_PR_UOM = ekpo-meins.
itemdata-COND_TYPE = itab-P_CTYPE.
*itemdata-ITEM_TEXT = .
append itemdata.
clear itemdata.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'
  EXPORTING
    HEADERDATA       = HEADERDATA
  IMPORTING
    INVOICEDOCNUMBER = DOC_NO
    FISCALYEAR       = FISC_YEAR
  TABLES
    ITEMDATA         = ITEMDATA
   ACCOUNTINGDATA   = I_ACCOUNTINGDATA
   TAXDATA          = I_TAX
    RETURN           = 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 = RETURN.
  endif.
endif.
       write:/ 'Document no :', doc_no.
       it_doc-doc_no = doc_no.
       it_doc-p_order = itab-p_order.
       append it_doc.
       CLEAR IT_DOC.
endloop.
loop at it_doc.
   if it_doc-doc_no = ' '.
      write:/ 'purchase order not posted ' , it_doc-p_order.
   else.
   write:/ 'document no:' , it_doc-doc_no, 'p.order:' , it_doc-p_order.
  endif.
endloop.
*&      Form  upload
      text
-->  p1        text
<--  p2        text
form upload .
  CALL function 'GUI_UPLOAD'
  exporting
    filename                      = FN1
   FILETYPE                      = 'ASC'
  HAS_FIELD_SEPARATOR           = ' '
  HEADER_LENGTH                 = 0
  READ_BY_LINE                  = 'X'
  DAT_MODE                      = ' '
  CODEPAGE                      = ' '
  IGNORE_CERR                   = ABAP_TRUE
  REPLACEMENT                   = '#'
  CHECK_BOM                     = ' '
  NO_AUTH_CHECK                 = ' '
IMPORTING
  FILELENGTH                    =
  HEADER                        =
  tables
    data_tab                      = ITAB
EXCEPTIONS
  FILE_OPEN_ERROR               = 1
  FILE_READ_ERROR               = 2
  NO_BATCH                      = 3
  GUI_REFUSE_FILETRANSFER       = 4
  INVALID_TYPE                  = 5
  NO_AUTHORITY                  = 6
  UNKNOWN_ERROR                 = 7
  BAD_DATA_FORMAT               = 8
  HEADER_NOT_ALLOWED            = 9
  SEPARATOR_NOT_ALLOWED         = 10
  HEADER_TOO_LONG               = 11
  UNKNOWN_DP_ERROR              = 12
  ACCESS_DENIED                 = 13
  DP_OUT_OF_MEMORY              = 14
  DISK_FULL                     = 15
  DP_TIMEOUT                    = 16
  OTHERS                        = 17
endform.                    " upload

I think you need to implement user-exit EXIT_SAPMM06E_012 of enhancement MM06E005.
Look in OSS with seach term MM06E005 to get some examples.
Note310154 "ME21N/ME51N: Customer-specific check, generating error log" has some examples.
You should use the macros to set errors/warnings
Example:
  mmpur_business_obj_id pt_ekpo-id.
  mmpur_metafield mmmfd_partners.
  mmpur_message_forced 'W' '00' '208' text-001 '' '' ''.
regards,
JG

Similar Messages

  • Tax code error while posting Planned delivery costs in Import Scenario

    Hi!!!!!
    I am getting on error while posting Planned delivery costs in MIRO for Import Purchase Order with zero value tax code v0. The error is
    "Tax code V0 country IN does not exist in procedure ZAXINN"
    For Import I defined a pricing procedure which contains all condition types for CVD, Ecess, SEcess, Additional Customs Duty and Others.
    While making Import PO im putting V0 tax code. I assigned the Tax Codes to the Company code.
    Please let me know what config is missing.
    Regards,
    Durga

    Is you ZAXINN assigned to the country India
    and is your taxcode (created in FTXP) created for country India?
    kr
    hakan

  • No delivery costs exist for purchase order

    Dear Friends,
    While doing MIRO, i am getting an error message as mentioned below----
    "No delivery costs exist for purchase order xxxxxxxxx"
    Message no. M8014.
    Kindly guide me in resolving the error.
    Thanks & Regards,

    hi
    >"No delivery costs exist for purchase order xxxxxxxxx"
    itself says that there is no delivery cost,
    firstly check ur PO ,Did u entere the delivery cost conditions like for freight or octoi in the PO
    or if u have entered the condition then check if it is not already invoiced
    if u dont have delivery cost in po and wanna do IV for material then in miro
    change the option of delivery cost to goods/service
    (at right side of the po no field)
    regards
    kunal

  • Not to Post Planned Delivery Cost in IV before MIGO

    Dear Experts,
    We are maintaining the Delivery cost Condition values for different vendors in Purchase Order and we are selecting the GR Based IV check box. At the time of MIRO before making MIGO (Goods receipt) it will not allow to Post Incoming Invoice if I select Goods/Service items or both Goods/Service items & Planned Delivery Cost but it will allow if we select only Planned Delivery Cost to Post.
    Kindly suggest us if anybody have the solution to restrict to Post the Planned Delivery cost before posting the Goods Receipt (MIGO).
    Thanks & regards,
    Dhanu

    Dear,
    First u do the MIGO, After that post the Material IV with goods/service, after that u again do IV for planned delivery cost selection of Planned delivery cost.
    Thanks,
    If this is helpful for u then reward me.

  • LIV-Planned Del.Cost for Multiple Purchase order.

    Hi Gurus,
    I have following issue while doing LIV -T-code MIRO . Passing Planned del. cost (Imports -Custom Duty) for Multiple POs (Same Vendor)
    Checked following basics.
    1.In Po Planned Del cost are maintained .(Custom Duty)
    2.in MIRO -Selected Layout All information and Planned Del. cost
    3.In Details tab Entered Doc. type RI (inv. receipt-IM) for imports.
    4.Entered all mand. details like Amount ,currencey etc
    1.Selected Layout All information and Planned Del. cost
    2.Selected in Po reference Tab- Purchase order/Scheduling agreement and in more allocation area ,I am entering mulitple purchase order.(say 2 Pos)
    When I adopt required 2 Po and line items to be settled r desplayed. and Again when I enter.Only One PO is displayed and other vansihes.
    I need Both the PO  (multiple PO).
    Please help in resolving the issue.
    Thanks in Advance.
    Regards
    Amar

    Hi,
    Yes, it is possible.
    In MIRO, click on "More Allocation Criteria" button besides Purchase Order field
    here go to search help of PO in the Pop-up screen and enter the vendor code and company code and execute
    Now select the POs and click on "Copy" button and now click on "Adopt" button in the pop-up screen
    It will copy all the POs and then follow the normal procedure of LIV.
    Regards
    Amar

  • Return delivery and Planned delivery costs

    Hi guru
    scenario: I create a PO (Vendor A) with Planned delivery costs on order item.
    I store planned delivery costs in the purchase order item on the Item conditions screen. ( I enter a different vendor for "freight vendor" - Vendor B, select the desired condition on the condition screen and choose Goto - Details. Overwrite the content of the Vendor field).
    I create GR. OK
    I create a return delivery (122) but I have to pay invoice for "freight vendor" to Vendor B.
    Can I make it?

    Hi,
    At the time of GR;
    Stock A/c - 110 - Dr
    GR/IR Clearing - 100 - Cr
    Freight Clearing - 10 - Cr
    And when you return it then same entry gets reversed.
    So at the time of MIRO, it will not propose the freight value automatically but you refer the PO and select "Planned delivery cost" and then under "GL Account" Tab, enter Freight Expense A/c - Dr and "Simulate", it will credit vendor and then Post

  • Planned delivery cost for the scheduling agreement

    Hi Experts
    1. I have an requirement to post Invoice ver. for the Planned delivery cost (freight,customs duty,CVD etc) against the Scheduling Agreement just like Import Purchases with checking off the GR Based IV Indicator before doing the GR
    I tried it but its giving me that no delivery costs are Planned in the Scheduling agreements it runs fine in case of the PO because PO is a time independent.  Please inform how to post the same for schedule agreement with time dependent indicator on. I tried switching off the time dependent indicator and the system allowed, but my requirement is to Post I.V for the delivery cost with the time dependent indicator on.
    Appreciate if you can suggest something in this case Urgently .
    2. Aother issue is we have some uploaded Scheduling agreement from legacy system with Time dependent conditions. For this we need to post planned delivery cost in Miro. Since the system is not allowing to post, how to about for this. Shall we enter the delivery cost in unplanned delivery cost in Miro and post.  Please suggest if any alternate solution is available.
    Regards
    Arvind

    Hi,
    As you know if the delivery cost document is not posted during GR the
    delivery cost is not proposed during invoice (MIRO). Planned delivery
    cost will be proposed in invoice only when there are records in EKBZ
    table. The EKBZ table will be updated when delivery cost is posted
    during GR itself.
    Please ensure in the PO itself thatr the conditions have been defined
    properly with the relevant amounts and values.
    During GR when planned delivery cost conditions are present in PO,
    system checks for values in amount field. Then only appropriate
    calculations will be done for delivery cost and planned delivery cost
    document will posted during GR and hence updates EKBZ table.
    Solution to this issue is described in below steps,
    1) reverse the invoice document
    2) reverse GR document.
    3) You have to give values in amount field in relevant conditions ZGDS
       in the PO.
       If you face any issues changing the values, delete above conditions
       and put it again manually and give values in amount field also.
    4) Post GR once again, delivery cost document will also be posted.
       You can check it in PO history.
    5) During invoice select Item + planned delivery cost and post the
       invoice. If you need planned delivery cost to be posted separately,
       then you can post individual invoice for item and delivery cost.
    Please note it is not possible to post delivery costs for documents with
    multiple accountassignments. 
    For your second question, I am afraid I can not answer. Please open a new ntry in the forum, so that someone else can answer it.
    Best Regards,
    Arminda Jack

  • MIRO for Planned delivery cost

    Hello,
    Its Raw material  PO with Freight  & unloading Charges codition.Excise duty applicable only for Raw material .
    service tax applicable for Freight & unloading charges vendor.
    while booking MIRO for  Raw material ,excise accounts should be hit  & for  Planned delivery cost  service accounts shoud  hit.
    but While Posting Planned delivery cost tax code for which sevice tax code has been used, excise offset account is getting Posted together with service tax accounts.
    How to Post MIRO for Planned delivery cost with only service tax accounts.
    Regards,
    Jyoti

    Hi Deva,
    Is the problem about the rounding of the value?
    If so I sugest you modify the rounding scheme of the conditions to 'round up' in the condition master. In this case 0,004 would become 0,01. It's important to know that currency is always posted with two decimal numbers, but you can always do this: 1000units cost 4$ (for example).
    For what I know you cannot post a value in invoices for less than 0,01$.
    Give more feedback.

  • BDC/BAPI for set delivery cmlition indicator in purchase order @ item level

    Hi Expert,
    could you please suggest me bapi to set/reset delivery completion  indicator in purchase order at item level for  t-code "ME22n"?
    Thanks and regard,
    Santosh Gupta

    Use BAPI_PO_CHANGE to set the delivery completed indicator.
    Refer to table section in the BAPI Interface
    POITEM     LIKE     BAPIMEPOITEM
    POITEMX     LIKE     BAPIMEPOITEMX
    Set Field POITEM-NO_MORE_GR = 'X' & Set field POITEMX-NO_MORE_GR = 'X'

  • Function modules or BAPI for posting plan costs for WBS Element

    Hi all,
    Does anyone know, whether there exists a function module or BAPI for posting plan costs to a WBS Element? K_COSTS_PLAN_PS does not work, because RKP1 is not allowed.
    Greetings

    check
    BAPI_COSTACTPLN_POSTACTINPUT   Activity Input Planning: Posting                
    BAPI_COSTACTPLN_POSTACTOUTPUT  Activity/Price Planning: Posting                
    BAPI_COSTACTPLN_POSTKEYFIGURE  Stat. Key Figure Planning: Postings             
    BAPI_COSTACTPLN_POSTPRIMCOST   Primary Cost Planning: Postings                 
    BAPI_PDTRANSCO_POSTPRIMCOST    Transfer of Planning Data: Post Primary Costs   
    K40C                           CO Actual Postings, Manual                      
    BAPI_ACC_PRIMARY_COSTS_POST    Accounting: Post Primary Costs                  
    BAPI_COPAACTUALS_POSTCOSTDATA  BAPI Operating Concern: Post Costing-Based Actua
    BAPI_PRIM_COST_CHECK_AND_POST  Primary Costs: Formal Parameter Check           
    S@meer

  • How to change posting of Planned Delivery cost in Po?

    i need to change posting of planned delivery cost in PO to other expense account.
    as when i enter any planed delivery cost in PO it direct posted to the inventory account but i need to change it to be posted to other account.

    Hi Dear,
                 You need to maintain the Account Key for the condition type in the Pricing Procedure.
    and then for the same key maintain the GL account in the OBYC settings.
    Hope it helps you.
    Regards,
    Yawar Khan

  • Problem with MIRO Transaction while posting Un planned Delivery cost

    Hi all,
    We have entered all the details including unplanned delivery cost in transaction MIRO. When we are trying to post the same by using post button directly with out simulation, system is asking for plant details.
    For first time we have entered wrong Plant details , system immediately asking again for plant details.
    Next time even if we entered correct plant details, the system is coming out from the screen MIRO and it is not posting the document.
    If you go through simulate button and it is working fine and it is giving Warning message, If we enter the wrong Plant details.
    My Client requirement is If we post the MIRO transaction including Un planned delivery cost with Post button. If we enter wrong plant details. System will through Error message, until we enter the correct plant details.
    Is there any way to do this. Pl help me in this regard.
    Regards,
    Ramesh

    In the MIRO T Code, U can see PO reference tab is there, Just below it there is Purchase order/scheduling agreement field is there . enter the purchase order number in blank field next to Purchase order/scheduling agreement and press enter. U can see it will  take the required data automatically.
    hope this helps
    regards

  • Planned Delivery Costs Posting in MRRL

    Hello Experts,
    We have ERS active in our system for regular consumprion items. These are the items where the price settled is inclusive of packing anf forwarding charges. There is no issue of LIV for these invoices.
    But when in a Purchase order any other charges are loaded such as Packing, Forwarding etc. these charges fall under planned delivery costs in terms of LIV. And these charges are not captured at the time of LIV through ERS.
    Does anybody aware of any userexit or SAP note which will help me capturing these charges in ERS as well.
    Early response will be appreciated as I want to transfer all plant purchases' invpoice verification on ERS.
    Thnaks & Regards,
    Rahul Puranik.

    As per SAP Standard system, it is not possible to post the planned deliver cost thro' ERS or by MRRL.

  • Distribute planned delivery cost into all open POs when post FI vendor invo

    Hi,
    We planned transport cost in PO usning condition type but we post the freight invoice monthly for freight vendor using F-43 with out refernce to POs.
    So POs always expect a freight invoce,ends up with GR/IR clearing balance and so we can't archive these POs now.
    Now we are looking for a new solution that to distribute monthly freight invoice amt into all those open invoices when we post a FI freight invoice for vendor (F-43).
    Please do suggest any user exit or BADI to check for open POs for that vendor when post F-43.
    hope to hear your reply soon. Thanks in Advance
    Regards,
    Jagadheshwar

    Hi
    Since it is planned delivery cost, I belive the Freight posting would have happened at MIGO itself.... i.e. the Freight amount would have been inventorized or posted into consumption account in the case of account assigned PO... Is this understandng correct?
    If yes, then ideally you should be passing entry using F-02, Dr the GR/IR account and Crediting the Vendor account... Allow manual posting for GR/IR in FS00... populate the PO No in GR/IR account while doing the posting.... Then you can clear them...
    Ideally, you should not have had planned delvery cost, if you are not booking the invoice PO wise....
    If you are getting the freight invoice for each PO separately, you can do ERS (Evaluated Receipt Settlement)... Which means system would automatically Dr the Gr/IR and Credit the vendor.... You dont need to wait for the invoice.... This is usually done for trusted vendors
    Br, Ajay M

  • Planned delivery cost posting in MIRO through IDOC_INPUT_INVOIC_MRM

    Hi Experts
    I came to know from the OSS Note 119092 that the planned delivery costs can not be posted for logistics(MM) incoming invoice throgh inbounf Function Module IDOC_INPUT_INVOIC_MRM.
    I just want to know whether this problem is rectified in ECC 6.0 or still this problem exists?
    Awaiting for your earliest response.
    Regards
    Mohamed

    Hi,
    There is a modification note that is released.
    1386272 EDI: Planned delivery costs..
    If you require this functionality please raise a message with SAP..
    Since this is a Pilot note release for few customers.
    regards,
    Lalita

Maybe you are looking for

  • How do I block a website?

    I have an addiction to some forums and social networking sites.. I've tried removing them from all my favorites to deter me from visiting them, but I find myself just typing out the web addresses. It's that bad. How can I block these sites completely

  • Videos marked as "TV Show"... where did they go???!!!

    I marked a bunch of my viedeos as TV shows (as opposed to movies) and they suddenly dissapeared from my movie library. Where did they go?

  • Show button on file open if interactivity supported

    Is there any way to show a button upon file open if and only if the PDF reader opening the file supports interactivity? That is, there's no point showing the button if the end user can't do anything with it. It would be fine if the button showed if a

  • SAP Does not start after backup complition

    Dear All, Since last two times when we put Offline whole database + Redolog backup, after complition of backup SAP Does not start. I have tried to start SAP Manually, but didn't start. To start SAP we have to restart the SERVER. Attached please find

  • Serious problems with El7/8: please help!

    Hello all, I really hope someone can help me-I've had no luck whatsoever with the customer support team. I have been using El 3 very successfully for a couple of years. I recently upgraded to El 7 in order to be able to edit HD video and SD video tog