AR Mising Script
AR Mising Script
/*spool Invoice_Closed_Line.lst*/
DECLARE
l_file_val
VARCHAR2(600);
l_line_id
NUMBER ;
l_hdr_id
NUMBER ;
l_result_out
varchar2(300);
l_return_status varchar2(30);
err_msg
VARCHAR2(2000);
l_org
NUMBER;
l_count number := 0;
l_line_count number :=0;
l_result
VARCHAR2(300);
cursor c_lines is
SELECT l.line_id,
l.header_id,
l.org_id,
l.created_by
FROM apps.oe_order_lines_all l,
apps.oe_order_headers_all h
WHERE
l.header_id = h.header_id
and l.line_id in (719938158) /*Modify the line ids for which item got missed
*/
and l.org_id = h.org_id;
BEGIN
oe_debug_pub.debug_on;
oe_debug_pub.initialize;
l_file_val := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
DBMS_OUTPUT.PUT_LINE('Output Debug File is stored at : '||OE_DEBUG_PUB.G_DIR||'/
'||OE_DEBUG_PUB.G_FILE);
OE_DEBUG_PUB.SETDEBUGLEVEL(5);
for l_cur in c_lines loop
l_line_id := l_cur.line_id;
l_org := l_cur.org_id;
l_line_count := l_line_count +1;
l_hdr_id:= l_cur.header_id;
dbms_output.put_line('Processing Line' || l_line_id||' of header, '||l_hdr_i
d);
l_count := 0;
SELECT count(*) into l_count from apps.RA_CUSTOMER_TRX_LINES_ALL
where line_type = 'LINE'
and interface_line_context = 'ORDER ENTRY'
and interface_line_attribute6 = to_char(l_line_id);
dbms_output.put_line('Count in AR tbl='||l_count);
-- Resetting count to 0
--l_count := 0;
IF(l_count = 0) THEN
SELECT count(*) into l_count from apps.RA_INTERFACE_LINES_ALL
where line_type = 'LINE'
and interface_line_context = 'ORDER ENTRY'
and interface_line_attribute6 = to_char(l_line_id);
END IF;
IF(l_count = 0) THEN
dbms_output.put_line('Invoicing Line' || l_line_id);
BEGIN
DELETE FROM apps.RA_INTERFACE_SALESCREDITS_ALL
WHERE INTERFACE_LINE_ATTRIBUTE6=to_char(l_line_id) and interf
ace_line_context = 'ORDER ENTRY';
dbms_output.put_line('Line DELETED FROM Sales Credit' || l_lin
e_id);
EXCEPTION
WHEN OTHERS THEN
NULL;
dbms_output.put_line('Line NOT in Sales Credit' || l_line_id);
END;
UPDATE apps.OE_ORDER_LINES_ALL SET
INVOICED_QUANTITY = NULL,
INVOICE_INTERFACE_STATUS_CODE = NULL,
OPEN_FLAG='Y', LAST_UPDATE_DATE = SYSDATE
WHERE LINE_ID = l_line_id;
-- fnd_client_info.set_org_context(to_char(l_org)); -- To be used for
R11
mo_global.set_policy_context(p_access_mode => 'S',p_org_id => l_org);
-- To be used for R12
dbms_output.put_line('Calling Interface line for '|| l_line_id);
oe_debug_pub.add( 'Sujith, Calling Interface line for '|| l_line
_id);
OE_INVOICE_PUB.Interface_Line(l_line_id,'OEOL',l_result_out,l_return_
status);
UPDATE apps.OE_ORDER_LINES_ALL SET
FLOW_STATUS_CODE='CLOSED'
WHERE LINE_ID = l_line_id;
OPEN_FLAG='N',