Sunday, 25 May 2014

Update Purchase Order Header Details API Script: Oracle EBS R12

There are certain scenarios in which PO headers details are required to be updated. Oracle has provided a standard API to update  PO header details.

PO Header fields which cab be updated are :-

  • Vendor Site Details
  • Ship to Location
  • Bill to Location
  • Payment Term
  • Delivery Term
  • Buyer Details
Below mentioned is the sample script to update PO Header Details through Oracle standard API.

CREATE OR REPLACE
PROCEDURE po_update_headers(
    p_po_number        IN VARCHAR2,
    p_vendor_site_id   IN NUMBER,
    p_ship_to_location IN VARCHAR2,
    p_bill_to_location IN VARCHAR2,
    p_payment_id       IN NUMBER,
    p_delivery_term    IN VARCHAR2,
    p_buyer_id         IN NUMBER,
    p_status out VARCHAR2)
AS

------Cursor To Get All the Details of PO --------------
  CURSOR po_hdr_cur 
  IS
  SELECT  ph.ROWID, ph.*
  FROM apps.po_headers ph
  WHERE ph.segment1 = p_po_number; 
  
  v_hdr_rec po_hdr_cur%rowtype;
BEGIN 
    
    apps.mo_global.set_policy_context('S',204);
    apps.fnd_global.apps_initialize ( user_id => 1318, resp_id => 50578, resp_appl_id => 201 );   
    
    FOR hdr_rec IN po_hdr_cur
    loop    
      apps.po_headers_pkg_s3.update_row 
                   (  x_rowid        => hdr_rec.ROWID,
                      x_po_header_id => hdr_rec.po_header_id,                             
                      x_agent_id     => nvl(p_buyer_id, hdr_rec.agent_id),
                      x_type_lookup_code  => hdr_rec.type_lookup_code,
                      x_last_update_date  => hdr_rec.last_update_date,
                      x_last_updated_by   => hdr_rec.last_updated_by,
                      x_segment1          => hdr_rec.segment1,
                      x_summary_flag      => hdr_rec.summary_flag,
                      x_enabled_flag      => hdr_rec.enabled_flag,
                      x_segment2  => hdr_rec.segment2,
                      x_segment3  => hdr_rec.segment3,
                      x_segment4  => hdr_rec.segment4,
                      x_segment5  => hdr_rec.segment5,
                      x_last_update_login   => hdr_rec.last_update_login,
                      x_vendor_id           => hdr_rec.vendor_id,
                      x_vendor_site_id      => nvl(p_vendor_site_id, hdr_rec.vendor_site_id),         
                      x_vendor_contact_id   => hdr_rec.vendor_contact_id,
                      x_ship_to_location_id =>  nvl(p_ship_to_location, hdr_rec.ship_to_location_id),   
                      x_bill_to_location_id => nvl(p_bill_to_location, hdr_rec.bill_to_location_id),  
                      x_terms_id                  => nvl(p_payment_id, hdr_rec.terms_id),             
                      x_ship_via_lookup_code      => hdr_rec.ship_via_lookup_code,
                      x_fob_lookup_code           => nvl(p_delivery_term, hdr_rec.fob_lookup_code),    
                      x_freight_terms_lookup_code   => hdr_rec.freight_terms_lookup_code,
                      x_status_lookup_code           => hdr_rec.status_lookup_code,
                      x_currency_code                => hdr_rec.currency_code,
                      x_rate_type                    => hdr_rec.rate_type,
                      x_rate_date                   => hdr_rec.rate_date,
                      x_rate => hdr_rec.rate,
                      x_from_header_id         => hdr_rec.from_header_id,
                      x_from_type_lookup_code  => hdr_rec.from_type_lookup_code,
                      x_start_date             => hdr_rec.start_date,
                      x_end_date               => hdr_rec.end_date,
                      x_revision_num           => hdr_rec.revision_num,
                      x_revised_date           => hdr_rec.revised_date,
                      x_note_to_vendor         => hdr_rec.note_to_vendor,
                      x_printed_date          => hdr_rec.printed_date,
                      x_comments              => hdr_rec.comments,
                      x_reply_date          => hdr_rec.reply_date,
                      x_reply_method_lookup_code    => hdr_rec.reply_method_lookup_code,
                      x_rfq_close_date              => hdr_rec.rfq_close_date,
                      x_quote_type_lookup_code      => hdr_rec.quote_type_lookup_code,
                      x_quotation_class_code        => hdr_rec.quotation_class_code,
                      x_quote_warning_delay         => hdr_rec.quote_warning_delay,
                      x_quote_vendor_quote_number   => hdr_rec.quote_vendor_quote_number,
                      x_closed_date                 => hdr_rec.closed_date,
                      x_approval_required_flag    => hdr_rec.approval_required_flag,
                      x_attribute_category        => hdr_rec.attribute_category,
                      x_attribute1 => hdr_rec.attribute1,
                      x_attribute2 => hdr_rec.attribute2,
                      x_attribute3 => hdr_rec.attribute3,
                      x_attribute4 => hdr_rec.attribute4,
                      x_attribute5 => hdr_rec.attribute5,
                      x_attribute6 => hdr_rec.attribute6,
                      x_attribute7 => hdr_rec.attribute7,
                      x_attribute8 => hdr_rec.attribute8,
                      x_attribute9 => hdr_rec.attribute9,
                      x_attribute10 => hdr_rec.attribute10,
                      x_attribute11 => hdr_rec.attribute11,
                      x_attribute12 => hdr_rec.attribute12,
                      x_attribute13 => hdr_rec.attribute13,
                      x_attribute14 => hdr_rec.attribute14,
                      x_attribute15 => hdr_rec.attribute15) ;  
                        COMMIT;
                      p_status := 'SUCCESS';                 
    END loop;
    p_status := 'SUCCESS';
    
exception
  WHEN others THEN
    p_status       := 'ERROR '||sqlcode||' '||sqlerrm; 
END ;


Let us know our valuable feedback.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. HI,

    i am trying to update amount agreed at header level for Blanket Purchase Agreement which is already approved. Is there any APi to update blanket Po. PO_CHANGE_API1_S is not working .please help me on this ASAP.

    Thanks
    Rajesh

    ReplyDelete
    Replies
    1. Hi Rajesh,

      Were you able to find an API to fix this issue ?

      Thanks
      Sham

      Delete