A/P Invoice and BaseRef(Purchase Order) as parameter of function

Every time i add row in A/P Invoice need to fire some function using formatted search where one of the parameter is BaseRef(DocNum) of the Purchase Order. So lets say formatted search is connected with Price and looks like this: SELECT dbo.example("BaseRef(DocNum) of Purchase Order")
Which variable is responsible for store Baseref - DocNum of Purchase Order?

Hi Przemek,
Do you mean you wish to retrieve the purchase order number for each line in the purchase invoice ?
The baseref column in the A/P invoice lines refers to the docnum of the base document (baseentry refers to the docentry of the base document), which can be either a goods receipt document or a purchase order document. The basetype document specifies the type of the document in which the baseentry and baseref columns refer to.
There are several ways you could solve this problem, but here's one solution you might want to try:
= = = Formatted search query that calls a user function in  MS SQL Server = = =
select dbo.getOrderNumForPurchaseInvoiceRow($[PCH1.BaseEntry],$[PCH1.BaseLine],$[PCH1.BaseType])
= = = Three user functions that have to be created in MS SQL Server = = =
create function getGoodsReceiptBaseRef(@DocEntry int, @LineNum int)
returns int
as
begin
  return(select baseref from pdn1 where docentry=@DocEntry and linenum=@LineNum)
end
go
create function getPurchaseOrderNum(@docentry int)
returns int
as
begin
  return(select docnum from opor where docentry=@docentry)
end
go
create function getOrderNumForPurchaseInvoiceRow(@baseentry int, @baseline int, @basetype int)
Returns int
as
begin
  declare @result int,
  @baseref int
  /* If basetype is not goods receipt or order, simply return null*/
  if(@basetype not in(20, 22))
    begin
      set @result=null
    end
  else
    begin   
      /* base document is goods receipt */
      if(@basetype=20)
        begin
          /* Retrieve the base reference number of the goods receipt */
          set @result=dbo.getGoodsReceiptBaseRef(@baseentry,@baseline)
        end
      else
        /* Base document is purchase order - simply return the baseref of the invoice itself */
        begin
          set @result=dbo.getPurchaseOrderNum(@baseentry)
        end
    end   
  return @result
end

Similar Messages

  • A report which shows the vendor invoice and its purchase order MM

    Hi All,
    I wonder if ther's a SAP standard report which shows the vendor invoice (the FI document) and its purchase order MM.
    Could anyone help me?
    Thanks
    G.Rossi
    Edited by: Lakshmipathi on Aug 2, 2011 2:24 PM
    Thread Locked - Reason  Cross Posted

    Dear,
    you can use FBL1N,
    From there you can view following things:
    1. Vendor Invoice = Reference
    2. Document type = KR and RE for Invoices
    3. Po Number
    4. Amount
    you can enable there many fields as per your requirement.
    Hope this helps!!!
    Br,Vivek

  • Account assignment of the incoming invoice and the purchase order

    Hi,
    I am trying to control the account assignment of an incoming invoice against the account assignment of the purchase order used. The link I found is the field ZEKKN. I think RBCO-ZEKKN tells me what account assignment of the purchase order (EKKN-ZEKKN) I am using (just as RSEG-EBELN and RSEG-EBELP help to point the item of the PO used in the invoice). This link is working pretty well in 99% of my Pos and invoices. But sometimes when I create an assignment line in the PO, this line is created with a key EBELN, EBELP, ZEKKN = ‘02’, even if any assignment was created wit an ZEKKN = ‘01’.
    In this case, when I park an invoice on this PO, the value of RBCO-ZEKKN is ‘01’ and not ‘02’ as in the table EKKN.
    It is very annoying because the control I implement blocks the posting of the invoice..
    Any idea or any new link between tables RBCO and EKKN will be very appreciable.
    Thanks in advance

    Hi, I've got the same issue if someones has a clue it would be very helpfull

  • Invoice Verification without GR and with Purchase Order

    Hi all
    During the Logistic Invoice Verfication (MIRO) without GR and with Purchase Order, I want to exclude "Invoice to be received" account (WRX) from the posting. How can I do it?
    Let me know
    Thanks

    it doesn't work. Can you explain me better the solution?
    Thanks

  • Report for Vendor Invoices Parked against Purchase Order

    Dear Team,
    I want a report or table name where I can get the Parked Invoices against a Purchase order.My requirement is to know which are the invoices which are parked against a PO since ME2M shows Invoices posted, so bye anyway is it possible to get such report.
    Regards,

    Invioces Parked
    Transaction: MIR6 & MIR5
    In MIR6, Select Held/Parked and execute to get the results. 
    In MIR5, Select Parked and execute to get the results. 
    Table: RBKP
    FieldS:
      Status  - RBSTAT
      ( A - Parked
        C - Parked and Held )
      Inv Doc - BELNR
      Fis year- GJAHR
    Invoices Parked against a PO
    Table: EKBE
    Enter the below:
    EBELN  - PO Number                    (Enter the PO Number(s))
    VGABE - Trans./event type         (Enter P - Invoice Parking)
    BEWTP - PO History Category     (Enter T - VRe)  This is optional

  • Third Party and Individual Purchase Order

    <b>Can anybody please send me the steps to configure the Return Process for both Third Party and Indvidual Purchase Orders.</b>

    dear sunil
    THIRD PARTY SCENARIO
    in third-party order processing, your company does not deliver the items requested by a customer. Instead, you pass the order along to a third-party vendor who then ships the goods directly to the customer and bills you. A sales order may consist partly or wholly of third-party items. Occasionally, you may need to let a vendor deliver items you would normally deliver yourself.
    Process Flow
    the processing of third-party orders is controlled via material types. Material types define whether a material is produced only internally can be ordered only from third-party vendors, or whether both are possible. For example, a material that is defined as a trading good can only be ordered from a third-party vendor. However, if you manufacture your own finished products, you may also want, from time to time, to be able to order the same type of product from other vendors.
    Processing Third-Party Orders in Sales
    Third-party items can be created automatically by the system, depending on how your system is set. However, you can also change a standard item to a third-party item during sales processing manually.
    Automatic third-party order processing:-
    if a material is always delivered from one or more third-party vendors, you can specify in the material master that the material is a third-party item. During subsequent sales order processing, the system automatically determines the appropriate item category for a third-party item: TAS. To specify a material as a third-party item, enter BANS in the Item category group field in the Sales 2 screen of the material master record.
    Manual third-party order processing
    In the case of a material that you normally deliver yourself but occasionally need to order from a third-party vendor, you can overwrite the item category during sales order processing. For a material that you normally deliver yourself, you specify the item category group NORM in the material master.
    If, as an exception, you use a third-party material, change the entry TAN to TAS in the ItCa field when processing the sales document. The item is then processed as third-party item.
    If address data for the ship-to party is changed in the sales order in third-party business transactions, the changed data will automatically be passed on to purchase requisition and also to the purchase order ,if one already exists. In the purchase order, you can display the address data for the ship-to party in the attributes for the item.
    You can only change the address data for the ship-to party in the sales order for third-party business transactions, and not in the purchase order.
    Processing Third-Party Orders in Purchasing
    when you save a sales order that contains one or more third-party items, the system automatically creates a purchase requisition in Purchasing. Each third-party item in a sales order automatically generates a corresponding purchase requisition item. During creation of the requisition, the system automatically determines a vendor for each requisition item. If a sales order item has more than one schedule line, the system creates a purchase requisition item for each schedule line.
    Purchase orders are created from purchase requisitions in the usual way. For more information about creating purchase orders, see the Purchasing documentation. During creation of the purchase order, the system automatically copies the delivery address of your customer from the corresponding sales order. In a sales order, you can enter purchase order texts for each third-party item. When you create the corresponding purchase order, the texts are automatically copied into the purchase order. The number of the purchase order appears in the document flow information of the sales order.
    All changes made in the purchase order are automatically made in the sales order as well. For example, if the vendor confirms quantities and delivery dates different from those you request and enters them in the purchase order, the revised data is automatically copied into the sales order
    you process third-party items by creating a normal sales order. In overview for the order, you can then overwrite the default item category (TAN in the standard system) with the special item category for third-party items: TAS
    Billing Third-Party Orders
    If relevance for billing indicator for the item category has been set to B (relevant for order-related billing on the basis of the order quantity) in Customizing, the system includes the order in the billing due list immediately. If, however, the indicator has been set to F (relevant to order-related billing on the basis of the invoice quantity), the system does not include the order in the billing due list until an invoice from the vendor has been received and processed by the purchasing department. In the standard system, item category TAS (third-party order processing) has been given billing-relevance indicator F.
    In the first case, the third-party order is considered to be completely billed only when the invoiced quantity equals the order quantity of the sales order item. In the second case, each time a vendor invoice is received, a customer invoice is created for the quantity in the vendor invoice and the order is considered to be fully invoiced until the next vendor invoice is received.
    If you have activated billing-relevance indicator F for item categories in Customizing, billing can refer to the goods receipt quantity instead of the incoming invoice quantity.
    You can control whether the invoice receipt quantity or the quantity of goods received is relevant for billing in Customizing for copying control for billing at item level.
    FOR YOUR PROCESS Individual Purchase Orders WELL GIVE THE RIGHT SOLUTION
    Individual purchase orders are used when your customer orders goods from you that are not in stock and must be ordered from one or more external vendors.
    Process Flow
    During sales order entry, the system automatically creates a purchase requisition item. The purchasing department creates a purchase order based on the requisition and the vendor ships the goods directly to you (unlike third party order processing, where the vendor ships directly to your customer). You then ship the goods to your customer. While the goods are part of your inventory, you manage them as part of the sales order stock. Sales order stock consists of stock that is assigned to specific sales orders and cannot be used for other purposes.
    Process Flow for 3rd Party Sales
    Customize the third party sales in summary:
    Prerequisites for 3rd party sales,
    Purchasing org,
    purchasing group,
    assign the Purchase org to company code
    assign Purchase org to plant,
    should not maintain the stock in material, it should be trading goods,
    1. Create Vendor XK01
    2. Create Material – Material Type as "Trading Goods". Item category group as "BANS".
    3. Assign Item Category TAS to Order type that you are going to use.
    4. A sale order is created and when saved a PR is generated at the background
    5. With reference to SO a PO is created (ME21N). The company raises PO to the vendor.
    6. Vendor delivers the goods and raises bill to company. MM receives the invoice MIRO
    7. Goods receipt MIGO
    8. Goods issue
    9. The item cat TAS or Schedule line cat CS is not relevant for delivery which is evident from the config and, therefore, there is no delivery process attached in the whole process of Third party sales.
    10. Billing *--
    SD - 3rd party sales order Create Sales Order
    VA01
    Order Type
    Sales org, distr chnl, div
    Enter
    Sold to
    PO #
    Material
    Quantity
    Enter
    Save
    SD - 3rd party sales order View the PR that is created with a third party sales order
    VA01
    Order Number
    Goto Item Overview
    Item ->Schedule Item
    SD - 3rd party sales order View the PR that is created
    ME52N
    Key in the PR number
    Save
    SD - 3rd party sales order Assign the PR to the vendor and create PO
    ME57
    Key in the PR number
    Toggle the "Assigned Purchase Requisition"
    Execute
    Check the box next to the material
    Assign Automatically button
    Click on "Assignments" button
    Click on "Process assignment"
    The "Process Assignment Create PO" box , enter
    Drag the PR and drop in the shopping basket
    Save
    SD - 3rd party sales order Receive Goods
    MIGO_GR
    PO Number
    DN Number
    Batch tab , click on classification
    Serial Numbers tab
    Date of Production
    Flag Item OK
    Check, just in case
    Post
    Save
    SD - 3rd party sales order Create Invoice
    MIRO
    Invoice Date
    Look for the PO , state the vendor and the Material
    Check the box
    Click on "Copy"
    Purchase Order Number (bottom half of the screen)
    Amount
    State the baseline date
    Simulate & Post
    Invoice Number
    *Invoice blocked due to date variance
    SD - 3rd party sales order Create a delivery order
    VL01N
    In the order screen , go to the menu Sales Document , select "Deliver"
    Go to "picking" tab
    State the qty and save
    SD - 3rd party sales order Create a billing document
    VF01
    Ensure that the delivery document is correct in the
    Enter
    Go to edit -> Log
    Save
    rewards pls
    siva

  • Error when posting invoice for Asset purchase order

    Hi,
    we are getting the errore message account determination for asset posting with keys not defined in chart of accounts,when posting an invoice for asset purchase order.
    Can any one see why this error is coming and what will be the solution.
    Nagesh

    Hi Prabhakar,
    Here is the reply,
    we have 10 line items,in which 3 items are freight related and other 7 items are related to goods reciept.
    i am trying to enter invoice for 3 line items at a time with two relevant to goods reciept and other related to non goods receipt(freight related).
    accounting entries generated after the GR are as follows,
    asset under construction account,and GR/IR account.
    Let me know the details is sufficient or not.

  • Posting multiple invoices against single purchase order line item

    Hi,
    We receive invoices on completion of certain milestones and Goods receipt is done when the final lot of material is delivered.  For example the purchase order may be to deliver 1 quantity of Machine.  Material is supplied in bits like Gear Box, Engine and body.  Invoice is received when Gear Box, Engine is supplied. Final invoicing is received on completion of delivery (taking into account what has already been delivered)
    Goods Receipt in SAP needs to be posted only once when complete machinery is delivered (the tracking for different parts delivered is done outside SAP).  However, the multiple invoice needs to be posted in SAP referring to same PO item (Please note PO quantity for complete assembled material is only 1).
    This needs to be treated as material and not service in SAP.  Can you please suggest how to book multiple invoices for same purchase order line item?
    Thanks

    Hi Charan
    Thanks for your reply.  However, both the options are not feasible.  Invoices can be received in different periods, sometimes over different months or years, hence needs to be booked immediately.
    Also, i cannot create material master for each component as the quantity for the final material is only 1.
    Any other alternatives?
    regards
    Sameer

  • Message alert when Invoice date preceds Purchase order date

    Hi all,
    I want to define message alert, when Invoice date precedes Purchase order date. Is there any standard message type is there, If yes please let me know. Otherwise how can i define this, please.
    Thanks
    CS..

    Hi,
    You can take help of your abbaper and enter the validation in the user exit of MIRO thru which Invoices are booked.
    Hope this helps, if yes, please assign points.
    Regards,
    Harish

  • BI : Invoice number in Purchase Order

    Hi Experts,
    I am doing Standard extraction for having purchase order related data in BI. we are using the below data sources :
    2LIS_02_itm, 2lis_02_cgr,2lis_02_scn & 2lis_02_sgr. Our requirement is we want to have the invoice number(XBLNR,REBZG)  in the extraction but none of the standard PO related Datasource has these fields. Kindly advise how can we bring the invoice number for purchase order extraction.
    thanks & regards,
    M.S

    Hi,
    You ERP system should be upgraded to Enhancement pack 3 to avail this datasource. Could you confirm the patch level of your ECC system. Or you can use 2lis_06_inv datasource to get the PO Number and accounting information.
    Thanks,
    RRR.
    Edited by: Rammi on Feb 18, 2010 10:11 AM
    Edited by: Rammi on Feb 18, 2010 10:12 AM
    Edited by: Rammi on Feb 18, 2010 10:12 AM

  • Table to show thw invoice for a purchase order

    In which table we can see the invoice for a purchase order?Or in which t code.

    Hi,
    Go to table EKBE in SE16/ SE16N and give the PO number and value "2 (Invoice receipt)" in the filed "Transaction/event type, purchase order history"
    Regards,
    SDNer

  • Make to Order and Individual Purchase Order ( MTO & IPO)

    Hello Gurus,
    1. Can anyone let me know what is Make to order (MTO)and Individual purchase
        order (IPO) and the Differences between both?
    2.  What is the purpose of MTO and IPO and where it is used.
    I would be thankful if anyone can provide me the meaning of both.
    Prashant V.T (PVT)

    Hi Prashant,
    MTO : Make to Order means the Production of the Material starts after getting the sales Order.
    Means once the Sales Order raised for any particuler customer then based on that order production / procurement takes place, and the stock what ever produced will be restricted for that Order only. The Stock cant be used for any other orders.
    where as IPO is different.
    IPO : Individual Purchase Order is like Third Party Sales but with a difference. In Third Party Sales, after getting the Sales Order a Purchase Order is raised to vendor and vendor will supply directly to the customer, and the Ordering compnay will raise the Invoice to the customer once the customer received the stock from vendor.
    IPO is similer but the difference is vendor will send the stock to the company instead of direclty sending to the customer. And the actual compnay will take the stock and do the delivery / shipping/ invoice to the customer.
    MM T.codes MIGO, MIRO plays crucial role in these type of scenarios.
    Hope this gives you some idea.
    REWARD IF HELPFUL.
    Regards,
    Praveen

  • How to Identify open Stock Transport Orders and their Purchase Order No?

    I am looking for the most efficient way, with the best SAP tables, to read , to get  STOs and their Purchase Order numbers.
    Also, what would be the best way to get its related Sales Order Number.
       Thank-You.

    STO's : EKPO-PSTYP = 7
    SO : VBFA-VBTYP_N = 'V', AND VBFA-VBTYP_V = 'C',

  • Single invoice for Multiple Purchase Orders

    Hi,
    How to Park the single invoice for multiple purchase orders

    brother this is possible to enter one Invoice fro multiple purchase order.
    call transaction MIR7, select " purchase order/Scheduling Agreement" from the PO refernce Tab. then click on arrow. give your purchase orders here.
    Thanks

  • Terms of Payment for Local and Import Purchase Order

    Hello Experts,
    I am SAP FICO Consultant, I am given a task of maintaining payment terms for local and import purchase order, I would highly appreciate your help in this regard. I know I can maintain payment terms via OBB8 but I am not sure that how to cover the following scenarios.
    1. 100% Advance
    2. 50% Advance, Balance in 07 Days (usually balance immediate with delivery is accepted but it is paid in 07 days for the record)
    3. 25% Advance, Balance in 07 Days
    4. 10% Advance, Balance in 07 Days
    5. 30 Days Credit
    6. 15 Days Credit
    7. 07 Days Credit
    IMPORTS
    1. 100% Irrevocable LC in advance
    2. 100% TT in Advance
    3. 50% TT in advance & 50% before shipment.
    Looking forward to hear from you.
    Regards
    Muhammad Yousuf Ali

    Hi
    <b>All the Local as well as the R/3 data gets stored in the SRM tables ->
    BBP_PAYTERM (Terms of Payment, Backend-Dependent)
    BBP_PAYTERM_TEXT ( Texts for Terms of Payment, Backend-Dependent)
    BBP_TQ02B ( QM System)
    BBP_TQ02U (Description QM system)
    Also refer to Transaction SLG1 for the log created in this case.</b>
    Hope this will help.
    Please reward suitable points.
    Regards
    - Atul

Maybe you are looking for

  • How to change my name on my iCloud email address

    Hi! I need some help I am trying to figure out why whenever I send an email, it has someone else's name on it. So other people think that it is someone else emailing them, I can't find the option to change your name in mail prefrences, it was greyed

  • Content Preview in Form Builder

    Hi all, I have duplicated the standard SAP XML form SAP_Announcements from the Form Builder. The standard xml form displays only the title and creator of the item in the RenderListItem tab. I am trying to modify it such that it displays the first 3 l

  • Apple Mail attachment

    I use gmail as my primary email account. Every time I send an email via Apple Mail using the attachment, the attachment icon that appears in gmail does not appear next to the email. Although the attachment IS in the email, I am not able to see whethe

  • Can't read full podcast name

    Is there any way to view the full name of a podcast episode or somehow make it line rap or show up in a second window by tapping on something? I subscribe to a podcase that has a really long series name along with fairly long episode names. From the

  • I'm trying to find the latest version of Quicktime player that I can load to my computer. I've got an old PPC and am running OS 10.4.11. Can anyone help?

    Can anyone tell me what the latest version of Quicktime Player is that I can load to my Mac PPC running OSX 10.4.11?