CREATE OR REPLACE PROCEDURE APPS.XXSPANV_REC_INTERFACE (errbuf OUT varchar2 ,
retcode OUT number)
IS
CURSOR rec_header IS
SELECT po_number,
vendor_name
FROM
xxspanv_inv_rec_preinterface;
CURSOR rec_transaction (p_po_number IN varchar2)
IS
SELECT
pha.po_header_id,
pha.org_id,
pla.unit_meas_lookup_code,
pla.quantity,
pla.item_id,
pha.vendor_id,
pla.po_line_id,
plla.line_location_id,
TRUNC(TO_DATE(pha.creation_date,'DD-MON-RRRR')) creation_date,
plla.receiving_routing_id,
pha.segment1,
plla.ship_to_organization_id,
pha.agent_id
--plla.sh--
FROM
po_headers_all pha,
po_lines_all pla,
po_line_locations_all plla
WHERE
pha.po_header_id=pla.po_header_id
AND plla.po_header_id=pha.po_header_id
AND plla.po_line_id=pla.po_line_id
AND UPPER(pha.AUTHORIZATION_STATUS)='APPROVED'
AND pha.ORG_ID=204
AND pla.item_id IS NOT NULL
AND pha.segment1=(p_po_number)
AND TRUNC(pha.creation_date) BETWEEN ('01-SEP-13')AND ('30-SEP-13')
AND pla.QUANTITY IS NOT NULL
order by pha.po_header_id;
l_autotransact_code rcv_headers_interface.AUTO_TRANSACT_CODE%type;
BEGIN
fnd_file.put_line(fnd_file.log,'Inserting into rcv_headers_interface');
FOR I IN rec_header
LOOP
INSERT INTO RCV_HEADERS_INTERFACE
(header_interface_id ,
group_id ,
processing_status_code ,
receipt_source_code ,
transaction_type ,
last_update_date ,
last_updated_by ,
last_update_login ,
VENDOR_NAME,
expected_receipt_date ,
validation_flag
)
values (rcv_headers_interface_s.NEXTVAL ,
rcv_interface_groups_s.NEXTVAL ,
'PENDING',
'VENDOR' ,
'NEW' ,
SYSDATE ,
fnd_profile.value('USER_ID'),
fnd_global.LOGIN_ID,
i.vendor_name,
SYSDATE ,
'Y'
);
FOR j IN rec_transaction (i.po_number)
LOOP
l_autotransact_code:=NULL;
IF j.receiving_routing_id in (1,3) then
l_autotransact_code:='RECEIVE';
ELSE l_autotransact_code:='DELIVER';
END IF;
INSERT INTO RCV_TRANSACTIONS_INTERFACE
(interface_transaction_id ,
group_id ,
last_update_date ,
last_updated_by ,
creation_date ,
created_by ,
last_update_login ,
transaction_type ,
transaction_date ,
processing_status_code ,
processing_mode_code ,
transaction_status_code ,
po_header_id,
po_line_id ,
item_id ,
quantity ,
unit_of_measure ,
po_line_location_id ,
auto_transact_code ,
receipt_source_code ,
to_organization_id ,
source_document_code ,
header_interface_id ,
validation_flag,
employee_id
)
VALUES (rcv_transactions_interface_s.NEXTVAL ,
rcv_interface_groups_s.CURRVAL ,
SYSDATE,
fnd_profile.VALUE('USER_ID') ,
SYSDATE,
fnd_profile.VALUE('USER_ID'),
fnd_global.login_id,
'RECEIVE',
sysdate,
'PENDING',
'BATCH',
'PENDING',
j.po_header_id,
j.po_line_id,
j.item_id,
j.quantity,
j.unit_meas_lookup_code,
j.line_location_id,
'RECEIVE',--l_autotransact_code,
'VENDOR',
j.ship_to_organization_id,
'PO',
rcv_headers_interface_s.CURRVAL ,
'Y',
j.agent_id
) ;
END LOOP;
END LOOP;
commit;
EXCEPTION WHEN OTHERS
THEN
fnd_file.put_line(fnd_file.log,'error occure in XXSPANV_REC_INTERFACE due to : '||SQLERRM);
END;
/
retcode OUT number)
IS
CURSOR rec_header IS
SELECT po_number,
vendor_name
FROM
xxspanv_inv_rec_preinterface;
CURSOR rec_transaction (p_po_number IN varchar2)
IS
SELECT
pha.po_header_id,
pha.org_id,
pla.unit_meas_lookup_code,
pla.quantity,
pla.item_id,
pha.vendor_id,
pla.po_line_id,
plla.line_location_id,
TRUNC(TO_DATE(pha.creation_date,'DD-MON-RRRR')) creation_date,
plla.receiving_routing_id,
pha.segment1,
plla.ship_to_organization_id,
pha.agent_id
--plla.sh--
FROM
po_headers_all pha,
po_lines_all pla,
po_line_locations_all plla
WHERE
pha.po_header_id=pla.po_header_id
AND plla.po_header_id=pha.po_header_id
AND plla.po_line_id=pla.po_line_id
AND UPPER(pha.AUTHORIZATION_STATUS)='APPROVED'
AND pha.ORG_ID=204
AND pla.item_id IS NOT NULL
AND pha.segment1=(p_po_number)
AND TRUNC(pha.creation_date) BETWEEN ('01-SEP-13')AND ('30-SEP-13')
AND pla.QUANTITY IS NOT NULL
order by pha.po_header_id;
l_autotransact_code rcv_headers_interface.AUTO_TRANSACT_CODE%type;
BEGIN
fnd_file.put_line(fnd_file.log,'Inserting into rcv_headers_interface');
FOR I IN rec_header
LOOP
INSERT INTO RCV_HEADERS_INTERFACE
(header_interface_id ,
group_id ,
processing_status_code ,
receipt_source_code ,
transaction_type ,
last_update_date ,
last_updated_by ,
last_update_login ,
VENDOR_NAME,
expected_receipt_date ,
validation_flag
)
values (rcv_headers_interface_s.NEXTVAL ,
rcv_interface_groups_s.NEXTVAL ,
'PENDING',
'VENDOR' ,
'NEW' ,
SYSDATE ,
fnd_profile.value('USER_ID'),
fnd_global.LOGIN_ID,
i.vendor_name,
SYSDATE ,
'Y'
);
FOR j IN rec_transaction (i.po_number)
LOOP
l_autotransact_code:=NULL;
IF j.receiving_routing_id in (1,3) then
l_autotransact_code:='RECEIVE';
ELSE l_autotransact_code:='DELIVER';
END IF;
INSERT INTO RCV_TRANSACTIONS_INTERFACE
(interface_transaction_id ,
group_id ,
last_update_date ,
last_updated_by ,
creation_date ,
created_by ,
last_update_login ,
transaction_type ,
transaction_date ,
processing_status_code ,
processing_mode_code ,
transaction_status_code ,
po_header_id,
po_line_id ,
item_id ,
quantity ,
unit_of_measure ,
po_line_location_id ,
auto_transact_code ,
receipt_source_code ,
to_organization_id ,
source_document_code ,
header_interface_id ,
validation_flag,
employee_id
)
VALUES (rcv_transactions_interface_s.NEXTVAL ,
rcv_interface_groups_s.CURRVAL ,
SYSDATE,
fnd_profile.VALUE('USER_ID') ,
SYSDATE,
fnd_profile.VALUE('USER_ID'),
fnd_global.login_id,
'RECEIVE',
sysdate,
'PENDING',
'BATCH',
'PENDING',
j.po_header_id,
j.po_line_id,
j.item_id,
j.quantity,
j.unit_meas_lookup_code,
j.line_location_id,
'RECEIVE',--l_autotransact_code,
'VENDOR',
j.ship_to_organization_id,
'PO',
rcv_headers_interface_s.CURRVAL ,
'Y',
j.agent_id
) ;
END LOOP;
END LOOP;
commit;
EXCEPTION WHEN OTHERS
THEN
fnd_file.put_line(fnd_file.log,'error occure in XXSPANV_REC_INTERFACE due to : '||SQLERRM);
END;
/
Need to run Receiving Transaction Processor to populate rcv_transactions.
No comments:
Post a Comment