0% found this document useful (0 votes)
6 views3 pages

Create Supplier

The document outlines a process for creating employees as suppliers in a database using SQL and PL/SQL. It includes the creation of a custom view to select employee data and a procedure to insert this data into the vendor and vendor site tables. Error handling is implemented to ensure successful creation of suppliers and their associated sites, with output messages for any issues encountered.

Uploaded by

rashid agha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Create Supplier

The document outlines a process for creating employees as suppliers in a database using SQL and PL/SQL. It includes the creation of a custom view to select employee data and a procedure to insert this data into the vendor and vendor site tables. Error handling is implemented to ensure successful creation of suppliers and their associated sites, with output messages for any issues encountered.

Uploaded by

rashid agha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Create Employee as an Supplier

Custom View:=
create view xxca_vendor as select
t.employee_number,t.person_id,t.full_name,ad.address_line1,ad.address_line2,ad
.address_line3,ad.style,t.business_group_id, u.organization_id, u.name
from per_all_people_f t,
per_all_assignments_f v,
hr_all_organization_units u,
per_addresses ad
where/* t.employee_number = '1025'--'900001' --t.person_id=3000
an*/t.person_id = v.person_id
and v.organization_id = u.organization_id
-- and t.full_name like '%Sul%'
and ad.person_id=v.person_id
and v.effective_end_date = '31-DEC-4712'
and t.effective_end_date = '31-DEC-4712'
and t.employee_number not in (select a.segment1 from ap_suppliers a
/* where a.segment1='1025'*/)

Api used for create employe as an supplier:

declare
l_vendor_rec AP_VENDOR_PUB_PKG.r_vendor_rec_type;
l_vendor_site_rec AP_VENDOR_PUB_PKG.r_vendor_site_rec_type;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
l_upd number := 0;
x_vendor_id number;
x_party_id number;
x_vendor_site_id number;
x_party_site_id number;
x_location_id number;
l_party_site_id number;
l_organization_id number;

cursor c1 is
select * from XXCA_VENDOR a
where a.employee_number<>'900002';

begin
for i in c1 loop
dbms_output.enable(1000000);
mo_global.set_policy_context('S',84/*83*/);
l_vendor_rec.SEGMENT1 := I.employee_number;
l_vendor_rec.VENDOR_NAME := I.full_name;
l_vendor_rec.SUMMARY_FLAG :='Y';-- I.SUMMARY_FLAG;
l_vendor_rec.ENABLED_FLAG := 'Y';--I.ENABLED_FLAG;
l_vendor_rec.EMPLOYEE_ID := I.PERSON_ID;
l_vendor_rec.VENDOR_TYPE_LOOKUP_CODE := 'EMPLOYEE';
l_vendor_rec.SET_OF_BOOKS_ID := 2021;
l_vendor_rec.allow_awt_flag := 'Y';
l_vendor_rec.INVENTORY_ORGANIZATION_ID := 82;
--SELECT * FROM PER_ALL_PEOPLE_F F WHERE F.PERSON_ID = 3054
AP_VENDOR_PUB_PKG.Create_Vendor(p_api_version => 1,
x_return_status => x_return_status,
Create Employee as an Supplier
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_vendor_rec => l_vendor_rec,
x_vendor_id => x_vendor_id,
x_party_id => x_party_id);

if (x_return_status <> 'S') then


dbms_output.put_line('Encountered ERROR in supplier creation!!!');
dbms_output.put_line('--------------------------------------');
dbms_output.put_line(x_msg_data);
end if;

/* IF x_msg_count > 1 THEN


FOR i IN 1 .. x_msg_count LOOP
dbms_output.put_line(substr(FND_MSG_PUB.Get(p_encoded =>
FND_API.G_FALSE),
1,
255));
END LOOP;
END IF;

else

l_vendor_site_rec.vendor_id := x_vendor_id;
l_vendor_site_rec.VENDOR_SITE_CODE := 'OFFICE';
l_vendor_site_rec.org_id := 83;
l_vendor_site_rec.COUNTRY := 'PK';
l_vendor_site_rec.ADDRESS_STYLE := 'POSTAL_ADDR_DEF';
l_vendor_site_rec.ADDRESS_LINE1 := I.ADDRESS_LINE1;
l_vendor_site_rec.ADDRESS_LINE2 := I.ADDRESS_LINE2;
l_vendor_site_rec.ADDRESS_LINE3 := I.ADDRESS_LINE3;
l_vendor_site_rec.PURCHASING_SITE_FLAG := 'Y';
l_vendor_site_rec.PAY_SITE_FLAG := 'Y';

\* l_vendor_site_rec.vendor_id := x_vendor_id;
l_vendor_site_rec.VENDOR_SITE_CODE := 'OFFICE';
l_vendor_site_rec.org_id := I.ORG_ID; -- 367;
l_vendor_site_rec.COUNTRY := 'PK';
l_vendor_site_rec.CITY := I.CITY;
l_vendor_site_rec.ADDRESS_LINE1 := I.ADDRESS_LINE1;
l_vendor_site_rec.ADDRESS_LINE2 := I.ADDRESS_LINE2;
l_vendor_site_rec.ADDRESS_LINE3 := I.ADDRESS_LINE3;
l_vendor_site_rec.PURCHASING_SITE_FLAG := 'Y';
l_vendor_site_rec.PAY_SITE_FLAG := 'Y';
*\

AP_VENDOR_PUB_PKG.Create_Vendor_Site(p_api_version => 1,
x_return_status =>
x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_vendor_site_rec =>
l_vendor_site_rec,
x_vendor_site_id =>
x_vendor_site_id,
x_party_site_id =>
x_party_site_id,
Create Employee as an Supplier
x_location_id =>
x_location_id);

if (x_return_status <> 'S') then


dbms_output.put_line('Encountered ERROR in supplier site
creation!!!');
dbms_output.put_line('--------------------------------------');
dbms_output.put_line(x_msg_data);
IF x_msg_count > 1 THEN
FOR i IN 1 .. x_msg_count LOOP
dbms_output.put_line(substr(FND_MSG_PUB.Get(p_encoded =>
FND_API.G_FALSE),
1,
255));
END LOOP;
END IF;
ELSE
dbms_output.put_line('Supplier Site Created!!!');

end if;
end if;*/
END LOOP;
COMMIT;

end;

You might also like