1 PACKAGE BODY GR_DISPATCH_HISTORY_PUB AS
2 /* $Header: GRPDSPHB.pls 120.0 2005/08/04 08:27:10 mgrosser noship $ */
3
4 G_PKG_NAME CONSTANT varchar2(30) := 'GR_DISPATCH_HISTORY_PUB';
5
6 g_log_head CONSTANT VARCHAR2(50) := 'gr.plsql.'|| G_PKG_NAME || '.';
7
8 --------------------------------------------------------------------------------
9 --Start of Comments
10 --Name: create_dispatch_history
11 --Pre-reqs:
12 -- None.
13 --Modifies:
14 -- None.
15 --Locks:
16 -- None.
17 --Function:
18 -- This procedure inserts records in the dispatch history table after validations.
19 --Parameters:
20 --IN:
21 -- Version of API to validate compatibility
22 --p_api_version IN NUMBER,
23 -- Initialize message stack (TRUE or FALSE)
24 --p_init_msg_list IN VARCHAR2,
25 -- Issue database commit after update (TRUE or FALSE)
26 --p_commit IN VARCHAR2,
27 -- Item/product that document is related to
28 --p_item IN VARCHAR2,
29 -- CAS # of item/product that document is related to
30 --p_cas_number IN VARCHAR2,
31 -- Document recipient ID
32 --p_recipient_id IN NUMBER,
33 -- Document recipient site ID
34 --p_recipient_site_id IN NUMBER,
35 -- Date document was sent to recipient
36 --p_date_sent IN DATE,
37 -- Method used to send the document to recipient
38 --p_dispatch_method_code IN NUMBER,
39 -- ID of saved document (document is already in the system)
40 --p_document_id IN NUMBER,
41 -- Physical Location of the document
42 --p_document_location IN VARCHAR2,
43 -- Actual name of File
44 --p_document_name IN VARCHAR2,
45 -- Version of document
46 --p_document_version IN VARCHAR2,
47 -- Category to assign document to
48 --p_document_category IN VARCHAR2,
49 -- Format of file - e.g. XML, pdf, etc
50 --p_file_format IN VARCHAR2,
51 -- Description of document
52 --p_file_description IN VARCHAR2,
53 -- Type of regulatory document - e.g. US16, CA16, etc.
54 --p_document_code IN VARCHAR2,
55 -- Disclosure code used to generate the document
56 --p_disclosure_code IN VARCHAR2,
57 -- Language that document was generated in
58 --p_language IN VARCHAR2,
59 -- Organization document was created for
60 --p_organization_code IN VARCHAR2,
61 -- User id to use for who columns
62 --p_user_id IN NUMBER,
63 -- Specifies the application calling this API
64 -- (0 - External application ,1- Internal application, 2 - Form)
65 --p_creation_source IN NUMBER,
66
67 --OUT:
68 --x_return_status
69 -- FND_API.G_RET_STS_SUCCESS if API succeeds
70 -- FND_API.G_RET_STS_ERROR if API fails
71 -- FND_API.G_RET_STS_UNEXP_ERROR if unexpected error occurs
72 --x_msg_count Number of error message in the error message
73 -- list
74 --
75 --x_msg_data If the number of error message in the error
76 -- message list is one, the error message
77 -- is in this output parameter
78 --Testing:
79 --
80 --End of Comments
81 -------------------------------------------------------------------------------
82 PROCEDURE CREATE_DISPATCH_HISTORY(
83 p_api_version IN NUMBER,
84 p_init_msg_list IN VARCHAR2,
85 p_commit IN VARCHAR2,
86 p_item IN VARCHAR2,
87 p_organization_id IN NUMBER,
88 p_inventory_item_id IN NUMBER,
89 p_cas_number IN VARCHAR2,
90 p_recipient_id IN NUMBER,
91 p_recipient_site_id IN NUMBER,
92 p_date_sent IN DATE,
93 p_dispatch_method_code IN NUMBER,
94 p_document_id IN NUMBER,
95 p_document_location IN VARCHAR2,
96 p_document_name IN VARCHAR2,
97 p_document_version IN VARCHAR2,
98 p_document_category IN VARCHAR2,
99 p_file_format IN VARCHAR2,
100 p_file_description IN VARCHAR2,
101 p_document_code IN VARCHAR2,
102 p_disclosure_code IN VARCHAR2,
103 p_language IN VARCHAR2,
104 p_organization_code IN VARCHAR2,
105 p_user_id IN NUMBER,
106 p_creation_source IN NUMBER,
107 x_return_status OUT NOCOPY VARCHAR2 ,
108 x_msg_count OUT NOCOPY NUMBER ,
109 x_msg_data OUT NOCOPY VARCHAR2
110 )
111 IS
112
113 l_api_version NUMBER := 1.0;
114 l_api_name VARCHAR2(60) := 'CREATE_DISPATCH_HISTORY';
115 l_log_head CONSTANT varchar2(100) := g_log_head || l_api_name;
116 l_progress VARCHAR2(3) := '000';
117
118 ITEM_OR_CAS_REQ EXCEPTION;
119 NO_DOCUMENT EXCEPTION;
120
121 BEGIN
122 -- Standard call to check for call compatibility
123 IF NOT fnd_api.compatible_api_call( l_api_version
124 , p_api_version
125 , l_api_name
126 , G_PKG_NAME
127 ) THEN
128 RAISE fnd_api.g_exc_unexpected_error;
129 END IF;
130
131 -- Initialize message list.
132 IF fnd_api.to_boolean(p_init_msg_list) THEN
133 fnd_msg_pub.initialize;
134 END IF;
135
136 -- Initialize API return status to sucess
137 x_return_status := FND_API.G_RET_STS_SUCCESS;
138
139 l_progress := 10;
140
141 --Make sure either CAS # or item has been sent in
142 IF p_item IS NULL and p_cas_number IS NULL THEN
143 RAISE ITEM_OR_CAS_REQ;
144 END IF;
145
146 --If neither document id nor document name is sent in
147 IF p_document_id IS NULL AND p_document_name IS NULL THEN
148 RAISE NO_DOCUMENT;
149 END IF;
150
151
152 --Insert record into the Dispatch History table
153 GR_DISPATCH_HISTORY_PVT.create_dispatch_history_rec
154 ( p_item ,
155 p_organization_id,
156 p_inventory_item_id,
157 p_cas_number ,
158 p_recipient_id ,
159 p_recipient_site_id ,
160 p_date_sent ,
161 p_dispatch_method_code ,
162 p_document_id ,
163 p_document_location ,
164 p_document_name ,
165 p_document_version ,
166 p_document_category ,
167 p_file_format ,
168 p_file_description ,
169 p_document_code ,
170 p_disclosure_code ,
171 p_language ,
172 p_organization_code ,
173 p_user_id ,
174 p_creation_source ,
175 x_return_status ,
176 x_msg_count ,
177 x_msg_data );
178
179
180 IF (x_return_status = FND_API.G_RET_STS_ERROR)
181 THEN
182 RAISE FND_API.G_EXC_ERROR;
183 ELSIF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR)
184 THEN
185 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
186 END IF;
187
188 --Issue commit if required
189 -- Standard Check of p_commit.
190 IF FND_API.to_boolean(p_commit)
191 THEN
192 COMMIT;
193 END IF;
194
195 x_return_status := FND_API.G_RET_STS_SUCCESS;
196
197 FND_MSG_PUB.Count_AND_GET ( p_count => x_msg_count,
198 p_data => x_msg_data
199 );
200
201 EXCEPTION
202 WHEN ITEM_OR_CAS_REQ THEN
203 FND_MESSAGE.SET_NAME('GR', 'GR_NO_ITEM_OR_CAS');
204 FND_MSG_PUB.Add;
205 x_return_status := FND_API.G_RET_STS_ERROR;
206 FND_MSG_PUB.Count_And_Get (
207 p_count => x_msg_count,
208 p_data => x_msg_data );
209
210 WHEN NO_DOCUMENT THEN
211 FND_MESSAGE.SET_NAME('GR', 'GR_NO_DOCUMENT');
212 FND_MSG_PUB.Add;
213 x_return_status := FND_API.G_RET_STS_ERROR;
214 FND_MSG_PUB.Count_And_Get (
215 p_count => x_msg_count,
216 p_data => x_msg_data );
217
218
219 WHEN FND_API.G_EXC_ERROR THEN
220 x_return_status := FND_API.G_RET_STS_ERROR;
221 FND_MSG_PUB.Count_AND_GET ( p_count => x_msg_count,
222 p_data => x_msg_data);
223
224 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
225 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
226 FND_MSG_PUB.Count_AND_GET ( p_count => x_msg_count,
227 p_data => x_msg_data);
228
229 WHEN OTHERS THEN
230 fnd_msg_pub.add_exc_msg (G_PKG_NAME, l_api_name);
231 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
232 FND_MSG_PUB.Count_And_Get (
233 p_count => x_msg_count,
234 p_data => x_msg_data );
235
236 END CREATE_DISPATCH_HISTORY;
237
238
239
240 END GR_DISPATCH_HISTORY_PUB; -- Package body