Loading

Thursday, May 28, 2015

API to Create Supplier in Oracle Apps R12 (ap_vendor_pub_pkg.create_vendor)










 

Script:

SET SERVEROUTPUT ON;
declare
  p_api_version          number;
  p_init_msg_list        varchar2(200);
  p_commit               varchar2(200);
  p_validation_level     number;
  x_return_status        varchar2(200);
  x_msg_count            number;
  x_msg_data             varchar2(200);
  l_msg                  varchar2(200);
  lr_vend                apps.ap_vendor_pub_pkg.r_vendor_rec_type;
  lr_ex_vend             ap_suppliers%rowtype;
  x_vendor_id            number;
  x_party_id             number;
  pin_copy_vendor_id     number;

begin
  -- Initialize apps session
  fnd_global.apps_initialize(1119,
                             50833,
                             200);
  mo_global.init('SQLAP');
  fnd_client_info.set_org_context(101);

  -- Assign Basic Values
  p_api_version      := 1.0;
  p_init_msg_list    := fnd_api.g_true;
  p_commit           := fnd_api.g_true;
  p_validation_level := fnd_api.g_valid_level_full;
  pin_copy_vendor_id := 6261;

  begin
    select *
      into lr_ex_vend
      from ap_suppliers asa
     where asa.vendor_id = pin_copy_vendor_id;
  exception
    when others then
      dbms_output.put_line('Unable to derive the supplier  information for vendor id:' ||
                           pin_copy_vendor_id);
  end;

  -- Hold Details
  lr_vend.hold_flag              := null;
  lr_vend.purchasing_hold_reason := null;
  lr_vend.hold_by                := null;
  lr_vend.hold_date              := null;

  -- Id details
  lr_vend.vendor_id         := null;
  lr_vend.segment1          := lr_ex_vend.segment1 || '_NEW1';
  lr_vend.vendor_name       := lr_ex_vend.vendor_name || '_NEW1';
  lr_vend.vendor_name_alt   := lr_ex_vend.vendor_name_alt||'_NEW1';
  lr_vend.summary_flag      := lr_ex_vend.summary_flag;
  lr_vend.enabled_flag      := lr_ex_vend.enabled_flag;
  lr_vend.start_date_active := lr_ex_vend.start_date_active;
  lr_vend.end_date_active   := lr_ex_vend.end_date_active; 

  -- Blank values
  lr_vend.party_id                  := null;
  lr_vend.parent_party_id           := null;
  lr_vend.jgzz_fiscal_code          := null;
  lr_vend.sic_code                  := null;
  lr_vend.url                       := null;
  lr_vend.supplier_notif_method     := null;
  lr_vend.remittance_email          := null;
  lr_vend.ceo_name                  := null;
  lr_vend.ceo_title                 := null;
  lr_vend.tax_reference             := null;
  lr_vend.inventory_organization_id := null;
  lr_vend.default_terms_id          := null;
  lr_vend.vendor_interface_id       := null;
  lr_vend.validation_number         := null;

  -- Other Values
  lr_vend.segment2                       := lr_ex_vend.segment2;
  lr_vend.segment3                       := lr_ex_vend.segment3;
  lr_vend.segment4                       := lr_ex_vend.segment4;
  lr_vend.segment5                       := lr_ex_vend.segment5;
  lr_vend.employee_id                    := lr_ex_vend.employee_id;
  lr_vend.vendor_type_lookup_code        := lr_ex_vend.vendor_type_lookup_code;
  lr_vend.customer_num                   := lr_ex_vend.customer_num;
  lr_vend.one_time_flag                  := lr_ex_vend.one_time_flag;
  lr_vend.parent_vendor_id               := lr_ex_vend.parent_vendor_id;
  lr_vend.min_order_amount               := lr_ex_vend.min_order_amount;
  lr_vend.terms_id                       := lr_ex_vend.terms_id;
  lr_vend.set_of_books_id                := lr_ex_vend.set_of_books_id;
  lr_vend.always_take_disc_flag          := lr_ex_vend.always_take_disc_flag;
  lr_vend.pay_date_basis_lookup_code     := lr_ex_vend.pay_date_basis_lookup_code;
  lr_vend.pay_group_lookup_code          := lr_ex_vend.pay_group_lookup_code;
  lr_vend.payment_priority               := lr_ex_vend.payment_priority;
  lr_vend.invoice_currency_code          := lr_ex_vend.invoice_currency_code;
  lr_vend.payment_currency_code          := lr_ex_vend.payment_currency_code;
  lr_vend.invoice_amount_limit           := lr_ex_vend.invoice_amount_limit;
  lr_vend.hold_all_payments_flag         := lr_ex_vend.hold_all_payments_flag;
  lr_vend.hold_future_payments_flag      := lr_ex_vend.hold_future_payments_flag;
  lr_vend.hold_reason                    := lr_ex_vend.hold_reason;
  lr_vend.type_1099                      := lr_ex_vend.type_1099;
  lr_vend.withholding_status_lookup_code := lr_ex_vend.withholding_status_lookup_code;
  lr_vend.withholding_start_date         := lr_ex_vend.withholding_start_date;
  lr_vend.organization_type_lookup_code  := lr_ex_vend.organization_type_lookup_code;
  lr_vend.minority_group_lookup_code     := lr_ex_vend.minority_group_lookup_code;
  lr_vend.women_owned_flag               := lr_ex_vend.women_owned_flag;
  lr_vend.small_business_flag            := lr_ex_vend.small_business_flag;
  lr_vend.terms_date_basis               := lr_ex_vend.terms_date_basis;
  lr_vend.inspection_required_flag       := lr_ex_vend.inspection_required_flag;
  lr_vend.receipt_required_flag          := lr_ex_vend.receipt_required_flag;
  lr_vend.qty_rcv_tolerance              := lr_ex_vend.qty_rcv_tolerance;
  lr_vend.qty_rcv_exception_code         := lr_ex_vend.qty_rcv_exception_code;
  lr_vend.enforce_ship_to_location_code  := lr_ex_vend.enforce_ship_to_location_code;
  lr_vend.days_early_receipt_allowed     := lr_ex_vend.days_early_receipt_allowed;
  lr_vend.days_late_receipt_allowed      := lr_ex_vend.days_late_receipt_allowed;
  lr_vend.receipt_days_exception_code    := lr_ex_vend.receipt_days_exception_code;
  lr_vend.receiving_routing_id           := lr_ex_vend.receiving_routing_id;
  lr_vend.allow_substitute_receipts_flag := lr_ex_vend.allow_substitute_receipts_flag;
  lr_vend.allow_unordered_receipts_flag  := lr_ex_vend.allow_unordered_receipts_flag;
  lr_vend.hold_unmatched_invoices_flag   := lr_ex_vend.hold_unmatched_invoices_flag;
  lr_vend.tax_verification_date          := lr_ex_vend.tax_verification_date;
  lr_vend.name_control                   := lr_ex_vend.name_control;
  lr_vend.state_reportable_flag          := lr_ex_vend.state_reportable_flag;
  lr_vend.federal_reportable_flag        := lr_ex_vend.federal_reportable_flag;
  lr_vend.auto_calculate_interest_flag   := lr_ex_vend.auto_calculate_interest_flag;
  lr_vend.exclude_freight_from_discount  := lr_ex_vend.exclude_freight_from_discount;
  lr_vend.tax_reporting_name             := lr_ex_vend.tax_reporting_name;
  lr_vend.check_digits                   := lr_ex_vend.check_digits;
  lr_vend.allow_awt_flag                 := lr_ex_vend.allow_awt_flag;
  lr_vend.awt_group_id                   := lr_ex_vend.awt_group_id;
  lr_vend.pay_awt_group_id               := lr_ex_vend.pay_awt_group_id;
  lr_vend.bank_charge_bearer             := lr_ex_vend.bank_charge_bearer;
  lr_vend.match_option                   := lr_ex_vend.match_option;
  lr_vend.create_debit_memo_flag         := lr_ex_vend.create_debit_memo_flag;
  lr_vend.ni_number                      := lr_ex_vend.ni_number;
  lr_vend.edi_payment_format             := lr_ex_vend.edi_payment_format;
  lr_vend.edi_transaction_handling       := lr_ex_vend.edi_transaction_handling;
  lr_vend.edi_payment_method             := lr_ex_vend.edi_payment_method;
  lr_vend.edi_remittance_method          := lr_ex_vend.edi_remittance_method;
  lr_vend.edi_remittance_instruction     := lr_ex_vend.edi_remittance_instruction;
  lr_vend.vat_code                       := lr_ex_vend.vat_code;
  lr_vend.auto_tax_calc_flag             := lr_ex_vend.auto_tax_calc_flag;
  lr_vend.offset_tax_flag                := lr_ex_vend.offset_tax_flag;
  lr_vend.vat_registration_num           := lr_ex_vend.vat_registration_num;
 
  -- Attribute Details
  lr_vend.attribute_category             := lr_ex_vend.attribute_category;
  lr_vend.attribute1                     := lr_ex_vend.attribute1;
  lr_vend.attribute2                     := lr_ex_vend.attribute2;
  lr_vend.attribute3                     := lr_ex_vend.attribute3;
  lr_vend.attribute4                     := lr_ex_vend.attribute4;
  lr_vend.attribute5                     := lr_ex_vend.attribute5;
  lr_vend.attribute6                     := lr_ex_vend.attribute6;
  lr_vend.attribute7                     := lr_ex_vend.attribute7;
  lr_vend.attribute8                     := lr_ex_vend.attribute8;
  lr_vend.attribute9                     := lr_ex_vend.attribute9;
  lr_vend.attribute10                    := lr_ex_vend.attribute10;
  lr_vend.attribute11                    := lr_ex_vend.attribute11;
  lr_vend.attribute12                    := lr_ex_vend.attribute12;
  lr_vend.attribute13                    := lr_ex_vend.attribute13;
  lr_vend.attribute14                    := lr_ex_vend.attribute14;
  lr_vend.attribute15                    := lr_ex_vend.attribute15;
 
  -- Global Attribute Details
  lr_vend.global_attribute1              := lr_ex_vend.global_attribute1;
  lr_vend.global_attribute2              := lr_ex_vend.global_attribute2;
  lr_vend.global_attribute3              := lr_ex_vend.global_attribute3;
  lr_vend.global_attribute4              := lr_ex_vend.global_attribute4;
  lr_vend.global_attribute5              := lr_ex_vend.global_attribute5;
  lr_vend.global_attribute6              := lr_ex_vend.global_attribute6;
  lr_vend.global_attribute7              := lr_ex_vend.global_attribute7;
  lr_vend.global_attribute8              := lr_ex_vend.global_attribute8;
  lr_vend.global_attribute9              := lr_ex_vend.global_attribute9;
  lr_vend.global_attribute10             := lr_ex_vend.global_attribute10;
  lr_vend.global_attribute11             := lr_ex_vend.global_attribute11;
  lr_vend.global_attribute12             := lr_ex_vend.global_attribute12;
  lr_vend.global_attribute13             := lr_ex_vend.global_attribute13;
  lr_vend.global_attribute14             := lr_ex_vend.global_attribute14;
  lr_vend.global_attribute15             := lr_ex_vend.global_attribute15;
  lr_vend.global_attribute16             := lr_ex_vend.global_attribute16;
  lr_vend.global_attribute17             := lr_ex_vend.global_attribute17;
  lr_vend.global_attribute18             := lr_ex_vend.global_attribute18;
  lr_vend.global_attribute19             := lr_ex_vend.global_attribute19;
  lr_vend.global_attribute20             := lr_ex_vend.global_attribute20;
  lr_vend.global_attribute_category      := lr_ex_vend.global_attribute_category;


  --Other non set values
  --lr_vend.EXT_PAYEE_REC          IBY_DISBURSEMENT_SETUP_PUB.EXTERNAL_PAYEE_REC_TYPE
  --lr_vend.AWT_GROUP_NAME         AP_AWT_GROUPS.NAME;
  --lr_vend.PAY_AWT_GROUP_NAME     AP_AWT_GROUPS.NAME;
  --TERMS_NAME                           AP_TERMS_TL.NAME;   


  -- Call the API
  ap_vendor_pub_pkg.create_vendor(p_api_version      => p_api_version,
                                  p_init_msg_list    => p_init_msg_list,
                                  p_commit           => p_commit,
                                  p_validation_level => p_validation_level,
                                  x_return_status    => x_return_status,
                                  x_msg_count        => x_msg_count,
                                  x_msg_data         => x_msg_data,
                                  p_vendor_rec       => lr_vend,
                                  x_vendor_id        => x_vendor_id,
                                  x_party_id         => x_party_id);

  dbms_output.put_line('X_RETURN_STATUS = ' || x_return_status);
  dbms_output.put_line('X_MSG_COUNT = ' || x_msg_count);
  dbms_output.put_line('X_MSG_DATA = ' || x_msg_data);
  dbms_output.put_line('X_VENDOR_ID = ' || x_vendor_id);
  dbms_output.put_line('X_PARTY_ID = ' || x_party_id);


  IF (x_return_status <> FND_API.G_RET_STS_SUCCESS)
  THEN     
    FOR i IN 1..FND_MSG_PUB.COUNT_MSG LOOP
      l_msg := FND_MSG_PUB.get( p_msg_index => i,
                                p_encoded   => FND_API.G_FALSE
                              );   
       dbms_output.put_line('The API call failed with error '||l_msg);
    END LOOP;
  ELSE
    dbms_output.put_line('The API call ended with SUCESSS status');
  END IF; 
 
end;
/

Test Result:




Happy Sharing !!!

1 Responses to “API to Create Supplier in Oracle Apps R12 (ap_vendor_pub_pkg.create_vendor)”

Sridevi K said...
October 8, 2016 at 12:49 AM

Regards
Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at training@oracleappstechnical.com | +91 - 9581017828.


Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.