Monday, November 6, 2023
Release the Sales Order using API
Friday, August 11, 2023
How to handle Log messages in stored objects (Functions, Procedure, Package Body)
Normally we handle log messages using FND_FILE.PUT_LINE(fnd_file.LOG,'Msg');
But in some cases we need to handle Log messages based on the Parameter value.
If we give the parameter value for DEBUG as Y (Yes), then the program must print a message in the log file. And if the N (No) value is entered, the program cannot print the message.
We can do it using following code logic.. (You can modify it according to your requirement and logic)
Procedure write_log(p_message IN VARCHAR2
, p_debug_flag IN VARCHAR2 Default 'N');
--
Procedure employee_details(errbuf OUT VARCHAR2
, retcode OUT VARCHAR2
, p_debug_flag IN VARCHAR2
, p_emp_id IN NUMBER);
CREATE OR REPLACE Package Body XXC_GET_DATA
IS
PROCEDURE write_log(p_message IN VARCHAR2
, p_debug_flag IN VARCHAR2 Default 'N')
IS
BEGIN
fnd_file.put_line(fnd_file.LOG,lc_time||'-'||p_message);
EXCEPTION
WHEN others THEN
fnd_file.put_line(fnd_file.LOG,'Error in Write_Log procedure: '||SQLERRM);
END write_log;
PROCEDURE employee_details(errbuf OUT VARCHAR2
, retcode OUT VARCHAR2
, p_debug_flag IN VARCHAR2
, p_emp_id IN NUMBER)
IS
lc_emp_name emp.emp_name%TYPE;
lc_address emp.address%TYPE;
ln_emp_num emp.emp_number%TYPE;
Monday, June 5, 2023
Delete AR(Account Receivable) Transaction Using API in Oracle Apps
Before delete AR transaction "Allow Transaction Deletion" flag should be Y.
Allow Transaction Deletion:
Enable the Allow transaction deletion option if you want to let users delete transactions from Oracle Receivables after the transactions have been saved.
You will update this option at Operating Unit level.
Check in database table:
SELECT invoice_deletion_flag
FROM ar_system_parameters_all ab
WHERE org_id = 201; -- Operating Unit org_id
If value of 'invoice_deletion_flag' is Y, its mean you are enable to delete AR Transaction, otherwise you need to do setup for this.
Setup:
Navigation: Receivable Responsibility --> Setup --> System --> System Options
Select 'Trans and Customers' Tab:
Click on "Allow Transaction Deletion" button and Save it.
Check in database table.
To delete AR Transaction, follow below steps:
Step 1) Create a staging table to stored data related to AR transaction.
CREATE TABLE xx_delete_ar_transaction
AS
SELECT customer_trx_id,
trx_date,
trx_number,
org_id,
creation_date,
created_by,
'N' record_status
FROM ra_customer_trx_all
WHERE org_id = 201
AND trx_number IN ('123000', '124000');
Step 2) Call API in PLSQL block to Delete AR Transactions:
DECLARE
CURSOR lcur_ar_trans
IS
SELECT ROWID,
customer_trx_id,
trx_date,
trx_number,
org_id,
creation_date,
created_by
FROM xx_delete_ar_transaction
WHERE record_status = 'N';
lc_msg_data VARCHAR2(4000);
ln_msg_count NUMBER;
lc_ret_status VARCHAR2(1) := 'S';
v_message_tbl arp_trx_validate.message_tbl_type;
ln_user_id NUMBER;
ln_responsibility_id NUMBER;
ln_application_id NUMBER;
ln_msg_index NUMBER;
BEGIN
--
ln_user_id := 0;
ln_application_id := 0;
ln_responsibility_id := 0;
-- Get application and responsibility id's
BEGIN
SELECT application_id, responsibility_id
INTO ln_application_id, ln_responsibility_id
FROM fnd_responsibility_tl
WHERE responsibility_name = 'Responsibility Name'; -- Enter valid Responsibility Name
EXCEPTION
WHEN others THEN
lc_ret_status := 'E';
dbms_output.put_line('Error at getting Responsibility id: '||SQLERRM);
END;
-- Get User ID
BEGIN
SELECT user_id
INTO ln_user_id
FROM fnd_user
WHERE user_name = 'ABC007'; -- Enter valid User Name
EXCEPTION
WHEN others THEN
lc_ret_status := 'E';
dbms_output.put_line('Error at getting User id: '||SQLERRM);
END;
--
FOR lreq_ar IN lcur_ar_trans
LOOP
-- Variable initialization:
ln_msg_count := NULL;
lc_msg_data := NULL;
--
dbms_output.put_line ('--> TRX Number: '|| lreq_ar.trx_number);
-- Set Org Context for the session
apps.mo_global.set_policy_context ('S', lreq_ar.org_id);
-- Set Oracle applications context
apps.fnd_global.apps_initialize (ln_user_id, ln_responsibility_id, ln_application_id);
-- Call API
ar_invoice_api_pub.delete_transaction (
p_api_name => 'Delete_Transaction',
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
p_validation_level => fnd_api.g_valid_level_full,
p_customer_trx_id => lreq_ar.customer_trx_id,
p_return_status => lc_ret_status,
p_msg_count => ln_msg_count,
p_msg_data => lc_msg_data,
p_errors => v_message_tbl);
IF lc_ret_status <> 'S' THEN
dbms_output.put_line ('--> Status: '||lc_ret_status);
BEGIN
UPDATE xx_delete_ar_transaction
SET record_status = lc_ret_status
WHERE ROWID = lreq_ar.ROWID;
EXCEPTION
WHEN others THEN
dbms_output.put_line('Error at update staging table: '||SQLERRM);
END;
FOR i IN 1 .. ln_msg_count
LOOP
apps.fnd_msg_pub.get (i,
apps.fnd_api.g_false,
lc_msg_data,
ln_msg_index
);
dbms_output.put_line ('Error: '||lc_msg_data);
END LOOP;
ELSE
dbms_output.put_line ('AR Transaction Successfully Deleted.');
END IF;
dbms_output.put_line ('--------------------');
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line ('Error in main block: ' || SQLERRM);
END;
/
Cannot update price since the Purchase Agreement doest not allow changes to the Purchase Order line price - Oracle Apps R12
Actual Behavior: While updating the Standard PO Line Unit Price using the Oracle API: PO_CHANGE_API1_S.UPDATE_PO , API returned a below error message:
"Cannot update price since the Purchase Agreement doest not allow changes to the Purchase Order line price."
Problematic Record details
Line Num: 1
Item Num: A22909
Unit Price: 67.34
User was tyring to update new Unit Price as 70.21 -- at this step got an above error.
Analysis: Standard Purchase Order has linked with Blancket Purchase Agreement, and that BPA is the Global Purchase Agreement(GBPA). That's a reason API not allow to update PO Unit Price.
Query to check the Standard PO is linked or not with Global BPA:
,pha2.segment1 GBPA_num, pla2.line_num gbpa_line_num, pha2.global_agreement_flag
FROM po_headers_all pha1, po_lines_all pla1
,po_headers_all pha2, po_lines_all pla2
WHERE pha1.po_header_id = pla1.po_header_id
AND pla1.from_header_id = pha2.po_header_id
AND pla1.from_line_id = pla2.po_line_id
--
AND pha1.segment1 = '27578'
AND pla1.line_num = 1;
Solution: Oracle API has failed to update Standard PO Line level Unit Price because the value of "Allow_Price_Override_Flag" field of Global BPA line is N (No). So, need to update it as Y (Yes).
We can do it through Purchase Order form:
Navigation: PO SuperUser --> Purchase Orders --> Purchase Orders
--> Query (F11) --> Enter Global BPA number --> Run (Ctrl + F11)
--> Click on Price Reference tab --> Select Line --> Click on Allow Price Override check button. And save it
Note: If new and old Unit Price values are same then API will allow to update it.
Thank you..
Sunday, January 22, 2023
AP (Account Payable) Invoice Interface or Conversion in Oracle Apps
A) Header Staging table:
CREATE TABLE xx_ap_inv_hdr_stg
(invoice_num VARCHAR2 (75),
invoice_type_lookup_code VARCHAR2 (75),
invoice_date DATE,
po_number VARCHAR2 (25),
vendor_num VARCHAR2 (25),
vendor_name VARCHAR2 (100),
vendor_site_code VARCHAR2 (25),
invoice_amount NUMBER,
invoice_currency_code VARCHAR2 (25),
exchange_rate NUMBER,
exchange_rate_type VARCHAR2 (25),
exchange_date DATE,
terms_name VARCHAR2 (50),
description VARCHAR2 (240),
source VARCHAR2 (80),
voucher_num VARCHAR2 (50),
payment_method_lookup_code VARCHAR2 (25),
goods_received_date DATE,
invoice_received_date DATE,
gl_date DATE,
accts_pay_code_comb_code VARCHAR2 (50),
creation_date DATE,
created_by NUMBER,
last_updated_by NUMBER,
last_update_date DATE,
error_text VARCHAR2 (2000),
process_flag CHAR (1)
);
B) Line Staging table:
CREATE TABLE xx_ap_inv_line_stg
(invoice_number VARCHAR2 (20),
vendor_num VARCHAR2 (40),
line_number VARCHAR2 (20),
line_type_lookup_code VARCHAR2 (20),
quantity_invoiced VARCHAR2 (30),
unit_price VARCHAR2 (10),
amount VARCHAR2 (10),
accounting_date DATE,
description VARCHAR2 (40),
tax_code VARCHAR2 (20),
po_number VARCHAR2 (20),
po_shipment_num VARCHAR2 (40),
dist_code_comb_code VARCHAR2 (10),
expenditure_type VARCHAR2 (20),
income_tax_region VARCHAR2 (20),
process_flag CHAR (1),
creation_date DATE,
created_by NUMBER,
last_updated_by NUMBER,
last_update_date DATE,
error_text VARCHAR2 (2000)
);
Step 2) Create Control files (.ctl) to insert data from CSV or text (.txt) files to staging tables:
A) Header Control file:
LOAD DATA
INFILE "D:\oracle\visappl\ap\11.5.0\data\XX_AP_INVOICE_HEADRES_DATA.txt"
APPEND INTO TABLE xx_ap_inv_hdr_stg
FIELDS TERMINATED BY ','
TRAILING NULLCOLS(invoice_num,
invoice_type_lookup_code,
invoice_date,
po_number,
vendor_num,
vendor_name,
vendor_site_code,
invoice_amount,
invoice_currency_code,
exchange_rate,
exchange_rate_type,
exchange_date,
terms_name,
description,
source,
voucher_num,
payment_method_lookup_code,
goods_received_date,
invoice_received_date,
gl_date,
accts_pay_code_comb_code,
creation_date "SYSDATE",
created_by constant "-1",
last_updated_by constant "-1",
last_update_date "SYSDATE",
process_flag constant "N"
)
B) Line Control file:
LOAD DATA
INFILE "D:\ORACLE\VISAPPL\AP\11.5.0\DATA\XX_AP_INVOICE_LINES_DATA.TXT"
APPEND INTO TABLE xx_ap_inv_line_stg
FIELDS TERMINATED BY ','
TRAILING NULLCOLS(invoice_number,
vendor_num,
line_number,
line_type_lookup_code,
quantity_invoiced,
unit_price,
amount,
accounting_date,
description,
tax_code,
po_number,
po_shipment_num,
dist_code_comb_code,
expenditure_type,
income_tax_region,
process_flag constant "N",
creation_date "SYSDATE",
created_by constant "-1",
last_updated_by constant "-1",
last_update_date "SYSDATE"
);
A) Package Specification:
CREATE OR REPLACE PACKAGE xx_ap_invoice_create_pkg
IS
PROCEDURE xx_ap_invoice_create_proc(errbuf out VARCHAR2,
retcode out NUMBER);
END;
/
B) Package Body:
CREATE OR REPLACE PACKAGE BODY xx_ap_invoice_create_pkg IS PROCEDURE xx_ap_invoice_create_proc(errbuf out VARCHAR2, retcode out NUMBER) IS ln_vendor_id NUMBER; ln_error_count NUMBER; ln_record_count NUMBER; lc_invoice_number VARCHAR2(75); ln_vendor_site_id NUMBER; lc_term_name VARCHAR2(50); lc_error_text VARCHAR2(2000):=''; ln_hdr_count NUMBER := 0; ln_line_count NUMBER := 0; BEGIN FOR lreq_hdr IN (SELECT a.rowid row_id,a.* FROM xx_ap_inv_hdr_stg a WHERE a.process_flag = 'N' ) LOOP lc_invoice_number := NULL; ln_record_count := ln_record_count + 1; -- Get Vendor Id BEGIN SELECT vendor_id INTO ln_vendor_id FROM po_vendors WHERE vendor_name = lreq_hdr.vendor_name AND segment1 = lreq_hdr.vendor_num; EXCEPTION WHEN OTHERS THEN -- here we can add other exceptions like NO_DATA_FOUND, TOO_MANY_ROWS etc. ln_error_count:=1; lc_error_text :='Vendor name does Not Exist'; END; --Primary key validation BEGIN SELECT 1 INTO lc_invoice_number FROM ap_invoices_all WHERE vendor_id = ln_vendor_id AND invoice_num = lreq_hdr.invoice_num; EXCEPTION WHEN OTHERS THEN ln_error_count:=0; END; -- IF (lc_invoice_number IS NOT NULL) THEN ln_error_count := 1; lc_error_text := lc_error_text||','||'Invoice number: '||lreq_hdr.invoice_num||' already Exist'; END IF; --To Get Vendor Site Id BEGIN SELECT vendor_site_id INTO ln_vendor_site_id FROM po_vendor_sites_all WHERE vendor_site_code = lreq_hdr.vendor_site_code AND vendor_id = ln_vendor_id AND org_id = 204; --get from PO or enter manually EXCEPTION WHEN OTHERS THEN ln_error_count:=1; lc_error_text := lc_error_text||','||'Vendor Site code does Not Exists'; END; --Term Name Exists or Nor BEGIN SELECT name INTO lc_term_name FROM ap_terms WHERE name = lreq_hdr.terms_name; EXCEPTION WHEN OTHERS THEN ln_error_count:=1; lc_error_text :=lc_error_text||','||'Term Name Not Exists'; END; IF ln_error_count <> 0 THEN UPDATE xx_ap_inv_hdr_stg SET process_flag = 'E', error_text = lc_error_text WHERE ROWID = lreq_hdr.ROW_ID; ELSE ln_hdr_count := ln_hdr_count + 1; INSERT INTO ap_invoices_interface (invoice_id, invoice_num, invoice_type_lookup_code, invoice_date, po_number, vendor_id, vendor_site_code, invoice_amount, invoice_currency_code, exchange_rate, exchange_rate_type, exchange_date, terms_name, description, source, voucher_num, payment_method_lookup_code, goods_received_date, invoice_received_date, gl_date, accts_pay_code_combination_id, org_id, creation_date, created_by, last_update_date, last_updated_by ) VALUES(ap_invoices_interface_s.nextval, lc_invoice_number, lreq_hdr.invoice_type_lookup_code, lreq_hdr.invoice_date, lreq_hdr.po_number, ln_vendor_id, lreq_hdr.vendor_site_code, lreq_hdr.invoice_amount, lreq_hdr.invoice_currency_code, lreq_hdr.exchange_rate, lreq_hdr.exchange_rate_type, lreq_hdr.exchange_date, lreq_hdr.terms_name, lreq_hdr.description, lreq_hdr.source, lreq_hdr.voucher_num, lreq_hdr.payment_method_lookup_code, lreq_hdr.goods_received_date, lreq_hdr.invoice_received_date, lreq_hdr.gl_date, lreq_hdr.accts_pay_code_comb_code, 204, sysdate, fnd_global.user_id, sysdate, fnd_global.user_id); -- Update staging table with process flag S (Successfully inserted record in stg table.) BEGIN UPDATE xx_ap_inv_hdr_stg SET process_flag = 'S' WHERE rowid = lreq_hdr.row_id; EXCEPTION WHEN others THEN lc_error_text :=lc_error_text||','||'Header Stg table updation failed -'||SQLERRM; END; -- FOR j IN (SELECT b.rowid row_id,b.* FROM xx_ap_inv_line_stg b WHERE process_flag = 'N' AND vendor_num = lreq_hdr.vendor_num AND invoice_number = lreq_hdr.invoice_num ) LOOP ln_line_count := ln_line_count + 1; INSERT INTO ap_invoice_lines_interface
Steps to get ZPL code output using Zebra viewer - Online
Introduction ZPL is a print language used by many label printers. A print language is a set of commands that can be used to draw elements li...
-
Overview: This document focuses on creating Standard Purchase Orders using Interface approach. This will help you to loa...
-
Overview: This document help you to update Purchase Order using the API in oracle apps. Oracle has provided the c...
-
Overview: A blanket release is an actual order of goods or services you raise against a blanket purchase agreement. The blanke...