Tuesday, February 11, 2014

Standard PO Interface / import with a distribution line

-- Standard PO import with a distribution line in "Incomplete" state
--
--

--
-- Run "Import Standard Purchase Orders" to import purchase orders
--

DECLARE

BEGIN

  fnd_global.apps_initialize (1318,50578,201);  -- user ID, responsibility ID, application ID
  mo_global.set_policy_context('S', 204); -- Vision Operations (USA)
  mo_global.init ('PO');

INSERT INTO po_headers_interface
(interface_header_id
,batch_id
,action
,org_id
,document_type_code
,vendor_id
,vendor_site_code
,vendor_site_id
,vendor_doc_num
,currency_code
,agent_id
,terms_id
,approval_status
,ship_to_location_id
,effective_date
,creation_date
,created_by
,last_update_date
,last_updated_by
--,attribute_category
--,attribute9 --xtra information
,comments
)
VALUES (po_headers_interface_s.NEXTVAL
,po_headers_interface_s.CURRVAL
,'ORIGINAL'
,204
,'STANDARD'
,601 -- vendor_id for Abbott Laboratories, Inc.
,'CORP HQ'-- vendor_site_code
,1415 -- vendor_site_id
,po_headers_interface_s.CURRVAL
,'USD'
,25 --agent_id for Stock, Ms. Pat= buyer
,10003 --terms_id
,'INCOMPLETE' -- "APPROVED" to approve PO
,2005 --deliver_to_location_id
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
--,'DS Fields'
--,rec_get_header_info.attribute9 --xtra information
,'PO Int Hdr ID= '||po_headers_interface_s.CURRVAL
);

INSERT INTO po.po_lines_interface
(interface_line_id,
interface_header_id,
line_num,
shipment_num,
line_type,
item,
uom_code,
quantity,
unit_price,
ship_to_organization_code,
ship_to_location)
VALUES
(po_lines_interface_s.nextval,
po_headers_interface_s.currval,
1,
1,
'Goods',
'200-0065',
'Ea',
1,
19.99,
'M1',
'M1- Seattle Mfg' );

INSERT INTO po.po_distributions_interface
(interface_header_id,
interface_line_id,
interface_distribution_id,
distribution_num,
quantity_ordered,
charge_account_id)
VALUES
(po_headers_interface_s.currval,
po.po_lines_interface_s.CURRVAL,
po.po_distributions_interface_s.NEXTVAL,
1,
1,
12943 -- CCID for the Charge Account = 01-410-5110-0000-000
);

COMMIT;

END;
/

--
-- Blanket PO import in Approved state
--
-- Run "Import Price Catalogs" to import blanket POs
--


DECLARE

BEGIN

  fnd_global.apps_initialize (1318,50578,201);  -- user ID, responsibility ID, application ID
  mo_global.set_policy_context('S', 204); -- Vision Operations (USA)
  mo_global.init ('PO');

INSERT INTO po_headers_interface
(interface_header_id
,batch_id
,action
,org_id
,document_type_code
,vendor_id
,vendor_site_code
,vendor_site_id
,vendor_doc_num
,currency_code
,agent_id
,terms_id
,approval_status
--,ship_to_location_id
,effective_date
,creation_date
,created_by
,last_update_date
,last_updated_by
--,attribute_category
--,attribute9 --xtra information
,comments
)
VALUES (po_headers_interface_s.NEXTVAL
,po_headers_interface_s.CURRVAL
,'ORIGINAL'
,204
,'BLANKET'
,601 -- vendor_id for Abbott Laboratories, Inc.
,'CORP HQ'-- vendor_site_code
,1415 -- vendor_site_id
,po_headers_interface_s.CURRVAL
,'USD'
,25 --agent_id for Stock, Ms. Pat= buyer
,10003 --terms_id
,'APPROVED'
--,2005 --deliver_to_location_id
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
--,'DS Fields'
--,rec_get_header_info.attribute9 --xtra information
,'Test PO Int Hdr ID= '||po_headers_interface_s.CURRVAL
);

INSERT INTO po.po_lines_interface
(interface_line_id,
interface_header_id,
line_num,
shipment_num,
line_type,
item,
uom_code,
quantity,
unit_price,
ship_to_organization_code,
ship_to_location)
VALUES
(po_lines_interface_s.nextval,
po_headers_interface_s.currval,
1,
1,
'Goods',
'200-0065',
'Ea',
1,
19.99,
'M1',
'M1- Seattle Mfg' );

COMMIT;

END;
/

--
-- Standard PO with no distribution line in Incomplete state
--


DECLARE

BEGIN

  fnd_global.apps_initialize (1318,50578,201);  -- user ID, responsibility ID, application ID
  mo_global.set_policy_context('S', 204); -- Vision Operations (USA)
  mo_global.init ('PO');

INSERT INTO po_headers_interface
(interface_header_id
,batch_id
,action
,org_id
,document_type_code
,vendor_id
,vendor_site_code
,vendor_site_id
,vendor_doc_num
,currency_code
,agent_id
,terms_id
,approval_status
--,ship_to_location_id
,effective_date
,creation_date
,created_by
,last_update_date
,last_updated_by
--,attribute_category
--,attribute9 --xtra information
,comments
)
VALUES (po_headers_interface_s.NEXTVAL
,po_headers_interface_s.CURRVAL
,'ORIGINAL'
,204
,'STANDARD'
,601 -- vendor_id for Abbott Laboratories, Inc.
,'CORP HQ'-- vendor_site_code
,1415 -- vendor_site_id
,po_headers_interface_s.CURRVAL
,'USD'
,25 --agent_id for Stock, Ms. Pat= buyer
,10003 --terms_id
,'INCOMPLETE'--'APPROVED'
--,2005 --deliver_to_location_id
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
,TO_DATE (SYSDATE, 'DD-MON-RRRR')
,fnd_profile.VALUE ('USER_ID')
--,'DS Fields'
--,rec_get_header_info.attribute9 --xtra information
,'Test PO Int Hdr ID= '||po_headers_interface_s.CURRVAL
);

INSERT INTO po.po_lines_interface
(interface_line_id,
interface_header_id,
line_num,
shipment_num,
line_type,
item,
uom_code,
quantity,
unit_price,
ship_to_organization_code,
ship_to_location)
VALUES
(po_lines_interface_s.nextval,
po_headers_interface_s.currval,
1,
1,
'Goods',
'200-0065',
'Ea',
1,
19.99,
'M1',
'M1- Seattle Mfg' );

COMMIT;

END;
/

No comments:

Post a Comment