Home » Applications » Oracle Fusion Apps & E-Business Suite » tried to execute the below code. Its run but not getting expected output
tried to execute the below code. Its run but not getting expected output [message #674367] |
Wed, 23 January 2019 06:07  |
 |
Hriday2289
Messages: 22 Registered: January 2019
|
Junior Member |
|
|
Hello,
I tried to execute the below code. Its run but not getting expected output. Could you please help.
SET SERVEROUTPUT ON;
Create or Replace Procedure test
as
-- declare
l_Sub_Inv varchar(10);
BEGIN
FOR i IN (SELECT 'CG1' as Org_Code, '73A' as Locator FROM DUAL
UNION ALL
SELECT 'CG2', '19B' FROM DUAL
UNION ALL
SELECT 'CG4', '15C' FROM DUAL
UNION ALL
SELECT 'CG6', '35D' FROM DUAL
UNION ALL
SELECT 'CG7', '66I' FROM DUAL
UNION ALL
SELECT 'CP1', '75E'FROM DUAL
UNION ALL
SELECT 'CP2', '59F' FROM DUAL
UNION ALL
SELECT 'CP4', '39G' FROM DUAL
UNION ALL
SELECT 'CP6', '71H' Locator FROM DUAL
UNION ALL
SELECT 'CP7', '41J' Locator FROM DUAL,
(SELECT msi.secondary_inventory_name Sub_Inv
FROM mtl_secondary_inventories msi
WHERE msi.secondary_inventory_name like '%RCV-CAPXU%'))loop
DBMS_OUTPUT.PUT_LINE (i.Org_Code ||'-'|| i.Locator ||'-'||l_Sub_Inv);
end loop;
end;
/
exec test;
---------------------------------------------------------------------------------------------------
After run the above code got the below output-
CG1-73A-
CG2-19B-
CG4-15C-
CG6-35D-
CG7-66I-
CP1-75E-
CP2-59F-
CP4-39G-
CP6-71H-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
CP7-41J-
PL/SQL procedure successfully completed.
---------------------------------------------------------------------------------------------------
Expected output will be-
Org_Code Locator Sub_Inv
CG1 73A RCV-CAPXU1
CG2 19B RCV-CAPXU2
CG4 15C RCV-CAPXU4
CG6 35D RCV-CAPXU6
CG7 66I RCV-CAPXU7
CP1 75E RCV-CAPXU1
CP2 59F RCV-CAPXU2
CP4 39G RCV-CAPXU4
CP6 71H RCV-CAPXU6
CP7 41J RCV-CAPXU7
Need Help..!!
|
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674374 is a reply to message #674371] |
Wed, 23 January 2019 22:42   |
 |
Hriday2289
Messages: 22 Registered: January 2019
|
Junior Member |
|
|
Thank you for your reply.
I tried this below, still getting same output.
SET SERVEROUTPUT ON;
Create or Replace Procedure test
as
l_Sub_Inv varchar(10);
begin
for i in (SELECT 'CG1' as Org_Code, '73A' as Locator FROM DUAL
UNION ALL
SELECT 'CG2', '19B' FROM DUAL
UNION ALL
SELECT 'CG4', '15C' FROM DUAL
UNION ALL
SELECT 'CG6', '35D' FROM DUAL
UNION ALL
SELECT 'CG7', '66I' FROM DUAL
UNION ALL
SELECT 'CP1', '75E'FROM DUAL
UNION ALL
SELECT 'CP2', '59F' FROM DUAL
UNION ALL
SELECT 'CP4', '39G' FROM DUAL
UNION ALL
SELECT 'CP6', '71H' Locator FROM DUAL
UNION ALL
SELECT 'CP7', '41J' Locator FROM DUAL,
(SELECT msi.secondary_inventory_name Sub_Inv, msi.organization_id, ood.organization_code Org_code
FROM mtl_secondary_inventories msi, ORG_ORGANIZATION_DEFINITIONS ood
WHERE msi.secondary_inventory_name IN (SELECT msi.secondary_inventory_name
FROM mtl_secondary_inventories msi
WHERE msi.secondary_inventory_name like '%RCV-CAPXU%')
and msi.organization_id = ood.organization_id))loop
DBMS_OUTPUT.PUT_LINE (i.Org_Code ||'-'|| i.Locator ||'-'||l_Sub_Inv);
end loop;
end;
/
exec test;
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674384 is a reply to message #674374] |
Thu, 24 January 2019 03:49   |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
cookiemonster already explained you the current result set. Unfortunately, nothing in your posts indicates what shall the procedure really display.
Additionally, the local variable L_SUB_INV is not assigned with anything, so it is empty (NULL), so it is correctly empty in DBMS_OUTPUT. You may put there NULL directly.
Without the variable, you may use plain SQL (no procedure), so the will be easier.
Instead of repeating the same query, you should rather describe in words what is required.
Currently, you have 13 rows from MTL_SECONDARY_INVENTORIES (it is the number how many times "CP7-41J-" is repeated in the current output).
You have 10 hard-coded (ORG_CODE, LOCATOR) pairs.
You probably want to assign them to SUB_INVs returned from the first query.
But, it is totally unclear, how are they related? What is the logical rule for their relation?
Run the query from MTL_SECONDARY_INVENTORIES standalone (probably the one from the initial post should suffice).
Examine its result - column SECONDARY_INVENTORY_NAME and eventually any other relevant ones.
State how exactly are these rows related to those hardcoded values in UNION (if they really are).
Only after determining these rules start writing code for achieving the required result.
|
|
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674395 is a reply to message #674392] |
Fri, 25 January 2019 01:17   |
 |
Michel Cadot
Messages: 68757 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Thu, 24 January 2019 08:00Michel Cadot wrote on Wed, 23 January 2019 13:29
Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674396 is a reply to message #674392] |
Fri, 25 January 2019 01:53   |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
You forgot to answer the most important question I asked:
Quote:State how exactly are these rows related to those hardcoded values in UNION (if they really are).
Assuming there is no relationship between these queries and exactly 10 rows shall be reported regardless number of rows returned from MTL_SECONDARY_INVENTORIES, you may join them on surrogate column identifying row number, something like:
select i.org_code||'-'||i.locator||'-'||msi.sub_inv
from (
SELECT 'CG1' as org_code, '73A' as locator, 1 as rn FROM DUAL
UNION ALL
SELECT 'CG2', '19B', 2 FROM DUAL
UNION ALL
SELECT 'CG4', '15C', 3 FROM DUAL
UNION ALL
SELECT 'CG6', '35D', 4 FROM DUAL
UNION ALL
SELECT 'CG7', '66I', 5 FROM DUAL
UNION ALL
SELECT 'CP1', '75E', 6 FROM DUAL
UNION ALL
SELECT 'CP2', '59F', 7 FROM DUAL
UNION ALL
SELECT 'CP4', '39G', 8 FROM DUAL
UNION ALL
SELECT 'CP6', '71H', 9 FROM DUAL
UNION ALL
SELECT 'CP7', '41J', 10 FROM DUAL
) i
left join (
SELECT secondary_inventory_name as sub_inv, rownum as rn
FROM mtl_secondary_inventories
WHERE secondary_inventory_name like '%RCV-CAPXU%'
) msi
on (i.rn = msi.rn);
[Edit: added aliases to the query]
[Updated on: Fri, 25 January 2019 04:00] Report message to a moderator
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674504 is a reply to message #674396] |
Wed, 30 January 2019 04:34   |
 |
Hriday2289
Messages: 22 Registered: January 2019
|
Junior Member |
|
|
Hello,
I tried the above given code, I did some modification into it and its working.. thank you
Now, Integrate this code to stock locator API, trying to automate this process but got error while compiling the below code.
Please Help..!!
SET SERVEROUTPUT ON;
Create or Replace Procedure testcreatelocator
as
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_inventory_location_id NUMBER;
l_locator_exists VARCHAR2(1);
l_organization_id NUMBER;
l_organization_code VARCHAR2(10);
l_subinventory_code VARCHAR2(10);
l_concatenated_segments VARCHAR2(100);
begin
for j in (select stk.organization_code||'-'||locator||'-'||subinventory_code||'-'||organization_id Locators
from (SELECT 'CG1' as organization_code, '73A' as locator FROM DUAL
UNION ALL
SELECT 'CG2', '19B' FROM DUAL
UNION ALL
SELECT 'CG4', '15C' FROM DUAL
UNION ALL
SELECT 'CG6', '35D' FROM DUAL
UNION ALL
SELECT 'CG7', '66I' FROM DUAL
UNION ALL
SELECT 'CP1', '75E' FROM DUAL
UNION ALL
SELECT 'CP2', '59F' FROM DUAL
UNION ALL
SELECT 'CP4', '39G' FROM DUAL
UNION ALL
SELECT 'CP6', '71H' FROM DUAL) stk
left join (SELECT msit.secondary_inventory_name as subinventory_code,
msit.organization_id as organization_id,
ood.organization_code as organization_code
FROM mtl_secondary_inventories msit,
ORG_ORGANIZATION_DEFINITIONS ood
WHERE secondary_inventory_name like '%RCV-CAPXU%'
and msit.organization_id = ood.organization_id) msi
on (stk.organization_code = msi.organization_code))loop
DBMS_OUTPUT.PUT_LINE (j.locators);
l_concatenated_segments := j.Locators;
l_organization_id := j.organization_id;
l_organization_code := j.organization_code;
l_subinventory_code := j.subinventory_code;
INV_LOC_WMS_PUB.CREATE_LOCATOR(
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
x_inventory_location_id => l_inventory_location_id,
x_locator_exists => l_locator_exists,
p_organization_id => l_organization_id,
p_organization_code => l_organization_code,
p_concatenated_segments => l_concatenated_segments,
p_description => 'Created by Script',
p_inventory_location_type => NULL,
p_picking_order => NULL,
p_location_maximum_units => NULL,
p_subinventory_code => l_subinventory_code,
p_location_weight_uom_code => NULL,
p_max_weight => NULL,
p_volume_uom_code => NULL,
p_max_cubic_area => NULL,
p_x_coordinate => NULL,
p_y_coordinate => NULL,
p_z_coordinate => NUll,
p_physical_location_id => NULL,
p_pick_uom_code => NULL,
p_dimension_uom_code => NULL,
p_length => NULL,
p_width => NULL,
p_height => NULL,
p_status_id => 1,
p_dropping_order => NULL
);
IF (l_return_status = 'S') then
dbms_output.put_line('Locator Id:' || l_inventory_location_id);
dbms_output.put_line('Locator exists:' || l_locator_exists);
ELSIF (l_msg_count = 1) THEN
dbms_output.put_line(replace(l_msg_data,chr(0),' '));
ELSE
For I in 1..l_msg_count LOOP
l_msg_data := fnd_msg_pub.get(I,'F');
dbms_output.put_line(replace(l_msg_data,chr(0),' '));
END LOOP;
END IF;
END LOOP;
end;
/
----------------------------------
Error:
Error(44,1): PL/SQL: Statement ignored
Error(44,24): PLS-00302: component 'ORGANIZATION_ID' must be declared
Error(45,1): PL/SQL: Statement ignored
Error(45,26): PLS-00302: component 'ORGANIZATION_CODE' must be declared
Error(46,1): PL/SQL: Statement ignored
Error(46,27): PLS-00302: component 'SUBINVENTORY_CODE' must be declared
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674506 is a reply to message #674504] |
Wed, 30 January 2019 05:24   |
 |
Michel Cadot
Messages: 68757 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Fri, 25 January 2019 08:17Michel Cadot wrote on Thu, 24 January 2019 08:00Michel Cadot wrote on Wed, 23 January 2019 13:29
Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
|
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674511 is a reply to message #674510] |
Wed, 30 January 2019 07:54   |
 |
Michel Cadot
Messages: 68757 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Wed, 30 January 2019 12:24Michel Cadot wrote on Fri, 25 January 2019 08:17Michel Cadot wrote on Thu, 24 January 2019 08:00Michel Cadot wrote on Wed, 23 January 2019 13:29
Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
|
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674607 is a reply to message #674603] |
Tue, 05 February 2019 08:09   |
 |
Michel Cadot
Messages: 68757 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Michel Cadot wrote on Wed, 30 January 2019 14:54Michel Cadot wrote on Wed, 30 January 2019 12:24Michel Cadot wrote on Fri, 25 January 2019 08:17Michel Cadot wrote on Thu, 24 January 2019 08:00Michel Cadot wrote on Wed, 23 January 2019 13:29
Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Indent the code, use code tags and align the columns in result.
Also always post your Oracle version, with 4 decimals, as solution depends on it.
With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
[Updated on: Tue, 05 February 2019 08:10] Report message to a moderator
|
|
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674623 is a reply to message #674612] |
Wed, 06 February 2019 06:19   |
 |
Hriday2289
Messages: 22 Registered: January 2019
|
Junior Member |
|
|
Hello,
I tried to registered the below code to concurrent program, requests runs successfully but locator is not created but while compile the below code from back end and again submitted the concurrent request after that the locator is created. Also not getting logs after completed the request.
I want to create locator on concurrent request submission. please help me on this.
SET SERVEROUTPUT ON;
Create or Replace Procedure testcreatelocator
(
errbuf out VARCHAR2,
retcode out NUMBER
)
as
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_inventory_location_id NUMBER;
l_locator_exists VARCHAR2(1);
l_organization_id NUMBER;
l_organization_code VARCHAR2(10);
l_subinventory_code VARCHAR2(10);
l_concatenated_segments VARCHAR2(100);
begin
for j in (select stk.organization_code||'-'||locator||'-'||subinventory_code||'-'||organization_id Locators
from (SELECT 'CG1' as organization_code, '73A' as locator FROM DUAL
UNION ALL
SELECT 'CG2', '19B' FROM DUAL
UNION ALL
SELECT 'CG4', '15C' FROM DUAL
UNION ALL
SELECT 'CG6', '35D' FROM DUAL
UNION ALL
SELECT 'CG7', '66I' FROM DUAL
UNION ALL
SELECT 'CP1', '75E' FROM DUAL
UNION ALL
SELECT 'CP2', '59F' FROM DUAL
UNION ALL
SELECT 'CP4', '39G' FROM DUAL
UNION ALL
SELECT 'CP6', '71H' FROM DUAL) stk
left join (SELECT msit.secondary_inventory_name as subinventory_code,
msit.organization_id as organization_id,
ood.organization_code as organization_code
FROM mtl_secondary_inventories msit,
ORG_ORGANIZATION_DEFINITIONS ood
WHERE secondary_inventory_name like '%RC%'
and msit.organization_id = ood.organization_id) msi
on (stk.organization_code = msi.organization_code))loop
DBMS_OUTPUT.PUT_LINE (j.locators);
l_concatenated_segments := j.Locators;
l_organization_id := j.organization_id;
l_organization_code := j.organization_code;
l_subinventory_code := j.subinventory_code;
INV_LOC_WMS_PUB.CREATE_LOCATOR(
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
x_inventory_location_id => l_inventory_location_id,
x_locator_exists => l_locator_exists,
p_organization_id => l_organization_id,
p_organization_code => l_organization_code,
p_concatenated_segments => l_concatenated_segments,
p_description => 'Created by Script',
p_inventory_location_type => NULL,
p_picking_order => NULL,
p_location_maximum_units => NULL,
p_subinventory_code => l_subinventory_code,
p_location_weight_uom_code => NULL,
p_max_weight => NULL,
p_volume_uom_code => NULL,
p_max_cubic_area => NULL,
p_x_coordinate => NULL,
p_y_coordinate => NULL,
p_z_coordinate => NUll,
p_physical_location_id => NULL,
p_pick_uom_code => NULL,
p_dimension_uom_code => NULL,
p_length => NULL,
p_width => NULL,
p_height => NULL,
p_status_id => 1,
p_dropping_order => NULL
);
IF (l_return_status = 'S') then
dbms_output.put_line('Locator Id:' || l_inventory_location_id);
dbms_output.put_line('Locator exists:' || l_locator_exists);
ELSIF (l_msg_count = 1) THEN
dbms_output.put_line(replace(l_msg_data,chr(0),' '));
ELSE
For I in 1..l_msg_count LOOP
l_msg_data := fnd_msg_pub.get(I,'F');
dbms_output.put_line(replace(l_msg_data,chr(0),' '));
END LOOP;
END IF;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
errbuf := 'No locator found';
retcode := '1'; -- warning
fnd_file.put_line(fnd_file.log, errbuf);
WHEN OTHERS THEN
errbuf := SQLERRM;
retcode := '2'; -- error
fnd_file.put_line(fnd_file.log, errbuf);
end;
/
[Updated on: Wed, 06 February 2019 06:30] by Moderator Report message to a moderator
|
|
|
|
Re: tried to execute the below code. Its run but not getting expected output [message #674625 is a reply to message #674624] |
Wed, 06 February 2019 06:41   |
 |
Hriday2289
Messages: 22 Registered: January 2019
|
Junior Member |
|
|
Hello,
I tried to registered the below code to concurrent program, requests runs successfully but locator is not created but while compile the below code from back end and again submitted the concurrent request after that the locator is created. Also not getting logs after completed the request.
I want to create locator on concurrent request submission. please help me on this.
PFB formatted code,
SET serveroutput ON;
CREATE OR replace PROCEDURE Testcreatelocator (errbuf OUT VARCHAR2,
retcode OUT NUMBER)
AS
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
l_inventory_location_id NUMBER;
l_locator_exists VARCHAR2(1);
l_organization_id NUMBER;
l_organization_code VARCHAR2(10);
l_subinventory_code VARCHAR2(10);
l_concatenated_segments VARCHAR2(100);
BEGIN
FOR j IN (SELECT stk.organization_code
||'-'
||locator
||'-'
||subinventory_code
||'-'
||organization_id Locators
FROM (SELECT 'CG1' AS organization_code,
'73A' AS locator
FROM dual
UNION ALL
SELECT 'CG2',
'19B'
FROM dual
UNION ALL
SELECT 'CG4',
'15C'
FROM dual
UNION ALL
SELECT 'CG6',
'35D'
FROM dual
UNION ALL
SELECT 'CG7',
'66I'
FROM dual
UNION ALL
SELECT 'CP1',
'75E'
FROM dual
UNION ALL
SELECT 'CP2',
'59F'
FROM dual
UNION ALL
SELECT 'CP4',
'39G'
FROM dual
UNION ALL
SELECT 'CP6',
'71H'
FROM dual) stk
left join (SELECT msit.secondary_inventory_name AS
subinventory_code,
msit.organization_id AS
organization_id,
ood.organization_code AS
organization_code
FROM mtl_secondary_inventories msit,
org_organization_definitions ood
WHERE secondary_inventory_name LIKE '%RC%'
AND msit.organization_id =
ood.organization_id) msi
ON ( stk.organization_code =
msi.organization_code ))LOOP
dbms_output.Put_line (j.locators);
l_concatenated_segments := j.locators;
l_organization_id := j.organization_id;
l_organization_code := j.organization_code;
l_subinventory_code := j.subinventory_code;
inv_loc_wms_pub.Create_locator(x_return_status => l_return_status,
x_msg_count => l_msg_count, x_msg_data => l_msg_data,
x_inventory_location_id => l_inventory_location_id,
x_locator_exists => l_locator_exists,
p_organization_id => l_organization_id
,
p_organization_code => l_organization_code,
p_concatenated_segments => l_concatenated_segments,
p_description => 'Created by Script', p_inventory_location_type => NULL,
p_picking_order => NULL, p_location_maximum_units => NULL,
p_subinventory_code => l_subinventory_code,
p_location_weight_uom_code => NULL,
p_max_weight => NULL, p_volume_uom_code => NULL,
p_max_cubic_area => NULL,
p_x_coordinate => NULL, p_y_coordinate => NULL, p_z_coordinate => NULL,
p_physical_location_id => NULL, p_pick_uom_code => NULL,
p_dimension_uom_code => NULL, p_length => NULL, p_width => NULL,
p_height => NULL, p_status_id => 1, p_dropping_order => NULL);
IF ( l_return_status = 'S' ) THEN
dbms_output.Put_line('Locator Id:'
|| l_inventory_location_id);
dbms_output.Put_line('Locator exists:'
|| l_locator_exists);
ELSIF ( l_msg_count = 1 ) THEN
dbms_output.Put_line(Replace(l_msg_data, Chr(0), ' '));
ELSE
FOR i IN 1..l_msg_count LOOP
l_msg_data := fnd_msg_pub.Get(i, 'F');
dbms_output.Put_line(Replace(l_msg_data, Chr(0), ' '));
END LOOP;
END IF;
END LOOP;
EXCEPTION
WHEN no_data_found THEN
errbuf := 'No locator found';
retcode := '1'; -- warning
fnd_file.Put_line(fnd_file.log, errbuf); WHEN OTHERS THEN
errbuf := SQLERRM;
retcode := '2'; -- error
fnd_file.Put_line(fnd_file.log, errbuf);
END;
/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Sat May 03 17:45:35 CDT 2025
|