[Home] [Help]
PACKAGE BODY: APPS.EAM_MRI_UTILS
Source
1 PACKAGE BODY eam_mri_utils AS
2 /* $Header: EAMMRIUB.pls 115.3 2003/05/02 22:26:24 lllin ship $ */
3
4 /**
5 * This is almost a copy of WIP_JDI_Utils.Error_If_Batch. Just modified
6 * the table name and such to make it usable for meter reading interface.
7 */
8 procedure error_if_batch(p_group_id number,
9 p_new_process_status number,
10 p_where_clause varchar2,
11 p_error_type number,
12 p_error_msg varchar2) is
13 x_statement varchar2(2000) :=
14 ' select interface_id
15 from eam_meter_readings_interface mri' ||
16 ' where mri.group_id = :x_group_id'||
17 ' and mri.process_phase = '|| WIP_CONSTANTS.ML_VALIDATION ||
18 ' and mri.process_status in ('|| WIP_CONSTANTS.RUNNING||
19 ','||WIP_CONSTANTS.PENDING||
20 ','||WIP_CONSTANTS.WARNING ||') and '||
21 replace(p_where_clause, ' ',' ');
22
23 x_cursor_id integer;
24 n_rows_fetched integer;
25 x_interface_id number;
26 x_error_type number;
27 x_error_msg varchar2(500);
28
29 begin
30 if (p_error_type = MSG_COLUMN) then
31
32 -- Fetch the invalid-column message.
33 fnd_message.set_name('WIP', 'WIP_ML_FIELD_INVALID');
34 fnd_message.set_token('COLUMN', p_error_msg, false);
35 x_error_type := MSG_ERROR;
36
37 elsif (p_error_type = MSG_CONC) then
38
39 -- Use the message that is already on the stack;
40 -- there is no need to fetch it.
41 x_error_type := MSG_ERROR;
42
43 else
44
45 x_error_type := p_error_type;
46
47 end if;
48
49 -- Execute dynamic sql.
50
51 x_cursor_id := dbms_sql.open_cursor ;
52 dbms_sql.parse(x_cursor_id, x_statement, dbms_sql.native) ;
53 dbms_sql.define_column(x_cursor_id, 1, x_interface_id);
54 dbms_sql.bind_variable(x_cursor_id, ':x_group_id', p_group_id);
55 n_rows_fetched := dbms_sql.execute(x_cursor_id) ;
56
57 LOOP
58 n_rows_fetched := dbms_sql.fetch_rows(x_cursor_id) ;
59
60 if (n_rows_fetched = 0) then
61 dbms_sql.close_cursor(x_cursor_id);
62 exit;
63 end if;
64
65 dbms_sql.column_value(x_cursor_id, 1, x_interface_id);
66
67 -- Fetch the requested error message.
68
69 fnd_message.set_name('EAM', p_error_msg) ;
70 fnd_message.set_token('INTERFACE', ' '|| x_interface_id, FALSE);
71 x_error_msg :=substr(fnd_message.get, 1, 500);
72
73 eam_int_utils.add_error(x_interface_id,
74 x_error_msg,
75 x_error_type);
76 END LOOP;
77
78 -- Update process_status of the records.
79
80 /*
81 x_statement :=
82 ' UPDATE eam_meter_readings_interface mri'||
83 ' SET PROCESS_STATUS = ' ||P_New_Process_Status|| '
84 WHERE GROUP_ID = ' || P_Group_Id || '
85 AND PROCESS_PHASE = ' || WIP_CONSTANTS.ML_VALIDATION || '
86 AND PROCESS_STATUS IN ('|| WIP_CONSTANTS.RUNNING||
87 ','||WIP_CONSTANTS.PENDING||
88 ','||WIP_CONSTANTS.WARNING ||')'||
89 ' AND ' || replace(p_where_clause, ' ',' ');
90 */
91
92 x_statement :=
93 ' UPDATE eam_meter_readings_interface mri'||
94 ' SET PROCESS_STATUS = :process_status
95 WHERE GROUP_ID = :group_id
96 AND PROCESS_PHASE = WIP_CONSTANTS.ML_VALIDATION
97 AND PROCESS_STATUS IN (WIP_CONSTANTS.RUNNING,
98 WIP_CONSTANTS.PENDING,
99 WIP_CONSTANTS.WARNING)
100 AND ' || replace(p_where_clause, ' ',' ');
101
102
103 begin
104 x_cursor_id := dbms_sql.open_cursor;
105 dbms_sql.parse(x_cursor_id, x_statement, dbms_sql.v7);
106 dbms_sql.bind_variable(x_cursor_id, ':process_status', P_New_Process_Status);
107 dbms_sql.bind_variable(x_cursor_id, ':group_id', P_Group_Id);
108 n_rows_fetched := dbms_sql.execute(x_cursor_id);
109 dbms_sql.close_cursor(x_cursor_id);
110 end;
111
112 end error_if_batch;
113
114
115 procedure error_if(p_current_rowid in rowid,
116 p_interface_id in number,
117 p_condition in varchar2,
118 p_product_short_name in varchar2,
119 p_message_name in varchar2) is
120 begin
121 if ( eam_int_utils.request_matches_condition(
122 p_current_rowid,
123 p_interface_id,
124 'eam_meter_readings_interface mri',
125 p_condition) ) then
126 FND_Message.set_name(p_product_short_name, p_message_name);
127 eam_int_utils.record_error(p_interface_id, FND_Message.get, FALSE);
128 end if;
129 end error_if;
130
131
132 END eam_mri_utils;