PO Create Quotation
|
3 min read
PO - Create Quotation using API
home/Professional
Open University/ERP/Purchasing/Inititation
Example of using an API for creating Quotation.
can be used for any PO document.
Insertion
/*
<mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark>===
Name : Create Quotation
Purpose : This plsql program is used to Create quotationhi through
PDOI : Import price catalog concurrent program
<mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark><mark></mark>===
*/
DECLARE
------------------------------------------------------------------------------------
--Define Mandatory column variables to insert into interface tables. Values to all
-- Variables need to be intialized with required data before running the script.
------------------------------------------------------------------------------------
---------------------------------------------------------------------------------
--Header level information
---------------------------------------------------------------------------------
--This provides batch id which is used to run particular set of data
l_batch_id po_headers_interface.batch_id%TYPE := 102;
--Contains Organization ID
l_org_id po_headers_interface.org_id%TYPE := 41;
--Contains Agent ID for which PO is created
l_agent_id po_headers_interface.agent_id%TYPE := 6516;
--Contains Vendor ID
l_vendor_id po_headers_interface.vendor_id%TYPE := 6426;
--Contains Vendor Site ID
l_vendor_site_id po_headers_interface.vendor_site_id%TYPE := 6545;
--Contains Ship to Location ID
l_ship_to_location_id po_headers_interface.ship_to_location_id%TYPE := 12710;
--Contains Bill to Location ID
l_bill_to_location_id po_headers_interface.bill_to_location_id%TYPE := 12710;
-- Contains Attribute value which can be your username
-- which can be used to check records inserted by the user
l_attribute1 po_headers_interface.attribute1%TYPE;-- := 'SBONTALA';
--Contains document subtype
l_document_subtype po_headers_interface.document_subtype%TYPE := 'STANDARD';
---------------------------------------------------------------------------------
--Line level information
---------------------------------------------------------------------------------
--Contains Line type
l_line_type po_lines_interface.line_type%TYPE := 'Goods';
--Contains Item information
l_item_desc po_lines_interface.item_description%TYPE := 'AS10000';
--Specifies UOM code
l_uom_code po_lines_interface.uom_code%TYPE := 'יח';
--Contains Unit price of the Item
l_unit_price po_lines_interface.unit_price%TYPE:= 100;
--Specifies the price override for the item
l_price_override po_line_locations_interface.price_override%TYPE := 10;
--Specified the quantity for the price break
l_quantity po_line_locations_interface.quantity%TYPE := 100;
--Contains ship to organization id
l_ship_to_organization_id po_line_locations_interface.ship_to_organization_id%TYPE := 12710;
l_unit_of_measure po_line_locations_interface.unit_of_measure%TYPE := 'יחידה';
-- Specifies number of Purchase order to be created
l_header_count NUMBER := 1;
--Specifies number of lines to be created per PO
l_line_count NUMBER := 1;
--Specifies number of price breaks to be created per Line
L_prc_brk_count NUMBER := 1;
--To track progress
l_progress VARCHAR2(10) ;
BEGIN
--Header Loop
FOR hdr_cnt IN 1..L_header_count
LOOP
---- Inserting into header interface table
l_progress := '001';
Insert into PO.PO_HEADERS_INTERFACE
(INTERFACE_HEADER_ID,
BATCH_ID,
PROCESS_CODE,
ACTION,
ORG_ID,
DOCUMENT_TYPE_CODE,
DOCUMENT_SUBTYPE ,
CURRENCY_CODE,
AGENT_ID,
VENDOR_ID,
VENDOR_SITE_ID,
SHIP_TO_LOCATION_ID,
BILL_TO_LOCATION_ID,
ATTRIBUTE1,
CREATION_DATE)
VALUES
( po_headers_interface_s.NEXTVAL, --- INTERFACE_HEADER_ID,
l_batch_id, --- BATCH_ID,
'PENDING', --- PROCESS_CODE,
'ORIGINAL', --- ACTION,
l_org_id, --- ORG_ID,
'QUOTATION', --- DOCUMENT_TYPE_CODE,
l_document_subtype,
'ILS', --- CURRENCY_CODE,
l_agent_id, --- AGENT_ID,
l_vendor_id, --- VENDOR_ID,
l_vendor_Site_id, --- VENDOR_SITE_ID,
l_ship_to_location_id, --- SHIP_TO_LOCATION_ID,
l_bill_to_location_id, --- BILL_TO_LOCATION_ID,
l_attribute1, --- ATTRIBUTE1,
SYSDATE ); --- CREATION_DATE,
---Line Loop
FOR line_cnt IN 1..l_line_count LOOP
l_progress := '002';
--- Inserting into Lines interface table
l_progress := '002';
Insert into PO.PO_LINES_INTERFACE
(INTERFACE_LINE_ID,
INTERFACE_HEADER_ID,
ACTION,
LINE_NUM,
LINE_TYPE,
Item_Description,
UOM_CODE,
UNIT_PRICE,
SHIP_TO_ORGANIZATION_ID,
SHIP_TO_LOCATION_ID,
NEED_BY_DATE,
PROMISED_DATE,
CREATION_DATE,
LINE_LOC_POPULATED_FLAG)
Values
(po_lines_interface_s.nextval, --- INTERFACE_LINE_ID,
po_headers_interface_s.currval, --- INTERFACE_HEADER_ID,
'ADD', --- ACTION,
line_cnt, --- LINE_NUM,
l_line_type, --- LINE_TYPE,
l_item_desc, --- ITEM,
l_uom_code, --- UOM_CODE,
l_unit_price,--- UNIT_PRICE,
l_ship_to_organization_id, --- SHIP_TO_ORGANIZATION_ID,
l_ship_to_location_id, --- SHIP_TO_LOCATION_ID,
SYSDATE, --- NEED_BY_DATE,
SYSDATE, --- PROMISED_DATE,
SYSDATE, --- CREATION_DATE,
'Y'); --- LINE_LOC_POPULATED_FLAG,
--Price Break Loop
FOR prc_brk_cnt IN 1..L_prc_brk_count LOOP
--Inserting into line location interface table
Insert into PO.PO_LINE_LOCATIONS_INTERFACE
(INTERFACE_LINE_LOCATION_ID,
INTERFACE_HEADER_ID,
INTERFACE_LINE_ID,
SHIPMENT_TYPE,
SHIPMENT_NUM,
SHIP_TO_ORGANIZATION_ID,
SHIP_TO_LOCATION_ID,
QUANTITY,
UNIT_OF_MEASURE,
PRICE_OVERRIDE,
CREATION_DATE)
Values
(po_line_locations_interface_s.nextval,--- INTERFACE_LINE_LOCATION_ID,
po_headers_interface_s.currval, --- INTERFACE_HEADER_ID,
po_lines_interface_s.currval, --- INTERFACE_LINE_ID,
'QUOTATION', --- SHIPMENT_TYPE,
prc_brk_cnt, --- SHIPMENT_NUM,
l_ship_to_organization_id, --- SHIP_TO_ORGANIZATION_ID,
l_ship_to_location_id, --- SHIP_TO_LOCATION_ID,
l_quantity, --- QUANTITY,
l_unit_of_measure,
l_price_override,
SYSDATE); --- CREATION_DATE,
END LOOP; --End of Price break loop
END LOOP; --End of line loop
END LOOP; --End of header loop
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error while inserting data at :'||l_progress||SQLCODE||SQLERRM);
END;
Calling the API
BEGIN
begin fnd_global.APPS_INITIALIZE(9151,20707,201); end;
-- Call the procedure
po_pdoi_grp.start_process(
p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_validation_level => FND_API.G_VALID_LEVEL_FULL,
p_commit => FND_API.G_TRUE,
x_return_status => :l_return_status,
p_gather_intf_tbl_stat => FND_API.G_FALSE,
p_calling_module => PO_PDOI_CONSTANTS.g_CALL_MOD_CONCURRENT_PRGM,
p_selected_batch_id => :p_selected_batch_id,
p_batch_size => PO_PDOI_CONSTANTS.g_DEF_BATCH_SIZE,
p_buyer_id => 6516,--:p_buyer_id,
p_document_type => 'QUOTATION',--:p_document_type,
p_document_subtype => 'STANDARD', --:p_document_subtype,
p_create_items => 'N',--:p_create_items,
p_create_sourcing_rules_flag => 'N',--:p_create_sourcing_rules_flag,
p_rel_gen_method => :p_rel_gen_method,
p_sourcing_level => :p_sourcing_level,
p_sourcing_inv_org_id => :p_sourcing_inv_org_id,
p_approved_status => 'APPROVED',--:p_approved_status,
p_process_code => PO_PDOI_CONSTANTS.g_process_code_PENDING,
p_interface_header_id => NULL,
p_org_id => 41,--:p_org_id,
p_ga_flag => 'N'--:p_ga_flag,
);
end;
#op/erp/po
#inititation