You are on page 1of 2

declare

cursor c1_rec is select * from sys.yld_item_load_stg where rownum <10;


l_template_id NUMBER;
l_item_table ego_item_pub.item_tbl_type;
lx_item_table ego_item_pub.item_tbl_type;
lx_return_status VARCHAR2 (1);
lx_msg_count NUMBER (10);
lx_message_list error_handler.error_tbl_type;
lx_msg_data VARCHAR2 (1000);
l_msg_index_out NUMBER;
l_message VARCHAR2 (4000);
l_org_code org_organization_definitions.organization_code%TYP
E;
g_error boolean;
v_ccid number;
v_count number:=0;
BEGIN
--
-- Populate Item Record
--

for c1_select in c1_rec loop


l_item_table (1).item_number := c1_select.item_name;
l_item_table (1).transaction_type := 'CREATE';
l_item_table (1).organization_id := 101;
--
l_item_table (1).primary_uom_code := 'EA';
l_item_table (1).description := c1_select.full_item_descrip
tion;
l_item_table (1).template_id := 82;

l_item_table (1).sales_account:= fnd_flex_ext.get_ccid('SQLGL','


GL#',101,to_char(sysdate,'DD-MON-YYYY'),
c1_select.sales_account);
--attribute_assignment
--
-- Call Item Creation / Assignment API
--
error_handler.initialize;
--
ego_item_pub.process_items
(p_api_version => 1.0
,p_init_msg_list => fnd_api.g_true
,p_commit => fnd_api.g_false
,p_item_tbl => l_item_table
,x_item_tbl => lx_item_table
,x_return_status => lx_return_status
,x_msg_count => lx_msg_count
);
--
-- Check for Errors
--
IF (lx_return_status = FND_API.G_RET_STS_SUCCESS)
THEN
dbms_output.put_line('Created Successfully');
--
COMMIT;
ELSE
error_handler.get_message_list
(x_message_list => lx_message_list);
--
FOR l_iCount IN 1..lx_message_list.COUNT
LOOP
g_error := TRUE;
--
dbms_output.put_line(SUBSTR (lx_message_list(l_iCount).m
essage_text,1, 2000));
END LOOP;
END IF;
v_count:=v_count+1;
end loop;
dbms_output.put_line('Number of Items Loaded :'||v_count);
EXCEPTION
WHEN OTHERS
THEN
IF lx_msg_count > 0
THEN
FOR l_index IN 1 .. lx_msg_count
LOOP
g_error := TRUE;
--
fnd_msg_pub.get
(p_msg_index => l_index
,p_encoded => 'F'
,p_data => lx_msg_data
,p_msg_index_out => l_msg_index_out
);
--
dbms_output.put_line( SUBSTR (lx_msg_data, 1, 200));
END LOOP;
END IF;
END;

You might also like