0% found this document useful (0 votes)
30 views24 pages

Alert When PO Approved

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 24

Alert when PO Approved

MAIL_PO_APPROVAL

select distinct poh.segment1,papf.email_address, papf.full_name,buyer.email_address,buyer.full_name

into &PO_NUMBER, &EMAIL_PREPARER, &PREPARER, &EMAIL_BUYER, &BUYER

from po_headers_all poh

,po_lines_all pol

,po_distributions_all pod

,po_requisition_headers_all reqh

,po_requisition_lines_all reql

,po_req_distributions_all reqd

,per_all_people_f papf
,per_all_people_f buyer

where poh.type_lookup_code='STANDARD'

and poh.approved_flag='Y'

and poh.rowid=:ROWID

and poh.po_header_id=pol.po_header_id

and poh.po_header_id=pod.po_header_id

and reqh.preparer_id=papf.person_id

and reqh.requisition_header_id=reql.requisition_header_id

and reql.requisition_line_id=reqd.requisition_line_id

and reqd.distribution_id=pod.req_distribution_id

and pol.item_id=reql.item_id

and poh.agent_id=buyer.person_id

and sysdate between buyer.effective_start_date and buyer.effective_end_date

and sysdate between papf.effective_start_date and papf.effective_end_date


2) When GRN Receive System automatically create misc receipt in targeted Org
elect rsh.receipt_num,po.segment1,papf.email_address, rsh.shipment_header_id

into

&RECEIPT_NUM, &PO_NUM, &EMAIL, &GRN_HEADER

from

RCV_SHIPMENT_HEADERS rsh

,po_headers_all po

,per_all_people_f papf

where rsh.rowid=:ROWID

and rsh.shipment_header_id in (select distinct rshl.shipment_header_id from rcv_shipment_lines rshl

where rshl.shipment_header_id=rsh.shipment_header_id)

and po.po_header_id in (select distinct rshl.po_header_id from rcv_shipment_lines rshl


where rshl.shipment_header_id=rsh.shipment_header_id)

and papf.person_id=po.agent_id

and sysdate between papf.effective_start_date and papf.effective_end_date


create or replace procedure grn_misc_receipt_interface
(
errbuf OUT NOCOPY VARCHAR2
,retcode OUT NOCOPY NUMBER
)
is
v_item Varchar2(161);
v_item_uom Varchar2(100);
v_subinv Varchar2(100);
v_po Varchar2(15);
v_rc_no Varchar2(15);
v_unit_cost Number;
err Varchar2(180);
v_to_org Number(15);
cursor receipts is
select cvi.transact_qty,rcl.*
from Rcv_Shipment_Lines rcl
,RCV_VRC_TXS_INT_V cvi
where to_date(rcl.creation_date)=to_date(sysdate)
and cvi.destination_type_code='EXPENSE'
AND cvi.inspection_status_code='ACCEPTED'
and rcl.shipment_line_id=cvi.shipment_line_id
and rcl.attribute15 is null;
begin
for rec in receipts loop
begin
if rec.to_organization_id=581 then
v_to_org:=582;
elsif rec.to_organization_id=104 then
v_to_org:=583;
end if;
select items.segment1, subinv.secondary_inventory, items.primary_uom_code
into v_item, v_subinv, v_item_uom
from mtl_system_items_b items
,mtl_item_sub_inventories subinv
where items.organization_id=v_to_org
and items.inventory_item_id=rec.item_id
and items.organization_id=subinv.organization_id
and items.inventory_item_id=subinv.inventory_item_id;

select poh.segment1, rch.receipt_num into v_po, v_rc_no


from
po_headers_all poh
,Rcv_Shipment_Headers rch
where poh.po_header_id=rec.po_header_id
and rch.shipment_header_id=rec.shipment_header_id;

select unit_price into v_unit_cost


from po_lines_all where po_line_id=rec.po_line_id;

insert into mtl_transactions_interface


(
source_code
,source_line_id
,source_header_id
,process_flag
,transaction_mode
,inventory_item_id
,inventory_item
,organization_id
,subinventory_code
,transaction_quantity
,transaction_uom
,transaction_date
,primary_quantity
,transaction_source_type_id
,transaction_action_id
,transaction_type_id
,distribution_account_id
,dst_segment1
,dst_segment2
,dst_segment3
,dst_segment4
,dst_segment5
,dst_segment6
,dst_segment7
,dst_segment8
,transfer_subinventory
,transfer_organization
,creation_date
,created_by
,last_update_date
,last_updated_by
,transaction_cost
,transaction_reference
)
values
(
'INTERFACE' --SOURCE_CODE
,rec.shipment_line_id --SOURCE_LINE_ID
,rec.shipment_header_id --SOURCE_HEADER_ID
,1 --PROCESS_FLAG 1 FOR ROWS TO BE PROCESSED
,3 --TRANSACTION_MODE 3 FOR PROCESSING USING
BACKGROUND
,rec.item_id --INVENTORY_ITEM_ID
,v_item --INVENTORY_ITEM
,v_to_org --ORGANIZATION_ID
,v_subinv --SUBINVENTORY_CODE
,rec.transact_qty --TRANSACTION_QUANTITY
,v_item_uom --TRANSACTION_UOM
,SYSDATE --TRANSACTION_DATE
,rec.transact_qty --PRIMARY_QUANTITY
,13 --TRANSACTION_SOURCE_TYPE_ID
,27 --TRANSACTION_ACTION_ID
,120 --TRANSACTION_TYPE_ID
,1016 --DISTRIBUTION_ACCOUNT_ID
,'00' --DST_SEGMENT1
,'000' --DST_SEGMENT2
,'000' --DST_SEGMENT3
,'0000' --DST_SEGMENT4
,'110901' --DST_SEGMENT5
,'000000' --DST_SEGMENT6
,'0000' --DST_SEGMENT7
,'00' --DST_SEGMENT8
,v_subinv --TRANSFER_SUBINVENTORY
,v_to_org --TRANSFER_ORGANIZATION
,SYSDATE --CREATION_DATE
,1318 --CREATED_BY
,SYSDATE --LAST_UPDATE_DATE
,1318 --LAST_UPDATE_BY
,v_unit_cost --TRANSACTION COST
,'PO: '||v_po||' and GRN: '||v_rc_no
);
update Rcv_Shipment_Lines wsha
set wsha.attribute15='T'
where wsha.shipment_line_id=rec.shipment_line_id;
commit;
exception
when others then null;
end;
end loop;
exception
when others then null;
end grn_misc_receipt_interface;

You might also like