DBA Data[Home] [Help]

PACKAGE BODY: APPS.IEU_MSG_PRODUCER_PUB

Source


1 PACKAGE BODY IEU_MSG_PRODUCER_PUB AS
2 /* $Header: IEUPMSGB.pls 120.0 2005/06/02 15:56:07 appldev noship $ */
3 	G_PKG_NAME CONSTANT VARCHAR2(30) := 'IEU_MSG_PRODUCER_PUB';
4 PROCEDURE SEND_PLAIN_TEXT_MSG (
5   p_api_version      IN NUMBER,
6   p_init_msg_list    IN VARCHAR2  DEFAULT FND_API.G_FALSE,
7   p_commit           IN VARCHAR2  DEFAULT FND_API.G_FALSE,
8   p_application_id   IN NUMBER,
9   p_resource_id      IN NUMBER,
10   p_resource_type    IN VARCHAR2  DEFAULT 'RS_INDIVIDUAL',
11   p_title            IN VARCHAR2,
12   p_body             IN VARCHAR2,
13   p_workitem_obj_code IN VARCHAR2,
14   p_workitem_pk_id    IN NUMBER,
15   x_message_id      OUT NOCOPY NUMBER,
16   x_return_status   OUT NOCOPY VARCHAR2,
17   x_msg_count       OUT NOCOPY NUMBER,
18   x_msg_data        OUT NOCOPY VARCHAR2
19   )
20 AS
21   -- done temporarily, once tables are in place we should use % directive
22   -- to refer to table definition for the column size if possible.
23 
24   t_max NUMBER := 240;
25   b_max NUMBER := 1990;
26 
27   l_api_name  CONSTANT VARCHAR2(30) := 'SEND_PLAIN_TEXT_MSG';
28   l_api_version CONSTANT NUMBER := 1.0;
29   l_msg_count               NUMBER;
30   l_msg_data                VARCHAR2(2000);
31   l_msg_index              number;
32   l_msg_param              varchar2(2000);
33   l_param_max              varchar2(2000);
34 
35 BEGIN
36   --
37   -- !!! WARNING !!!
38   --
39   -- This implementation is NOT STANDARDS compliant yet... just enough to
40   -- get people using it and catching errors in their logic.  To be standards
41   -- compliant, you must consider the exception handling further, and deal
42   -- with X_RETURN_STATUS appropriately, etc.
43   --
44   -- Ray Cardillo (06-18-01)
45   --
46   -- !!! WARNING !!!
47   --
48   -- this implementation only does validation at this point, so the users
49   -- can verify that the logic they intend to write will work correctly.
50   -- it is strongly recommended to leave this validation in place, and
51   -- make any appropriate updates as things change, because the users are
52   -- very likely to attempt things that aren't valid or supported.
53   -- Ray Cardillo (06-15-201)
54 
55   Savepoint SEND_PLAIN_TEXT_PUB;
56 
57   IF NOT FND_API.Compatible_API_Call (l_api_version, p_api_version, l_api_name, G_PKG_NAME)
58   then
59      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
60   END IF;
61 
62   IF fnd_api.to_boolean(p_init_msg_list)
63   then
64     FND_MSG_PUB.initialize;
65   end if;
66 
67   x_return_status := FND_API.G_RET_STS_SUCCESS;
68 
69   IF ( (p_api_version IS NULL) OR
70        (p_commit is NULL) OR
71        (p_application_id is NULL) OR
72        (p_resource_id is NULL) OR
73        (p_title is NULL) OR
74        (p_body is NULL) )
75   THEN
76        IF P_API_VERSION IS NULL THEN
77 --          l_msg_param := 'p_api_version = ' || p_api_version;
78         l_msg_param := ' P_API_VERSION';
79        END IF;
80        If p_commit is null then
81 --          l_msg_param := l_msg_param||' p_commit = ' || p_commit;
82           l_msg_param := l_msg_param||' P_COMMIT:';
83        END IF;
84        if p_application_id is null then
85 --          l_msg_param := l_msg_param||' p_application_id = ' || p_application_id;
86           l_msg_param := l_msg_param||' P_APPLICATION_ID';
87        END IF;
88        if p_resource_id is null then
89 --          l_msg_param := l_msg_param||' p_resource_id = ' || p_resource_id;
90           l_msg_param := l_msg_param||' P_RESOURCE_ID';
91        END IF;
92        if p_title is null then
93 --          l_msg_param := l_msg_param||' p_title = ' || p_title ;
94           l_msg_param := l_msg_param||' P_TITLE';
95        END IF;
96        if p_body is null then
97 --          l_msg_param := l_msg_param||' p_body = ' || p_body ;
98           l_msg_param := l_msg_param||' P_BODY';
99        end if;
100        x_return_status := FND_API.G_RET_STS_ERROR;
101        fnd_message.set_name('IEU','IEU_UWQ_REQUIRED_PARAM_NULL');
102        FND_MESSAGE.SET_TOKEN('PACKAGE_NAME','IEU_MSG_PRODUCER_PUB.SEND_PLAIN_TEXT_MSG');
103        FND_MESSAGE.SET_TOKEN('IEU_UWQ_REQ_PARAM',l_msg_param);
104        fnd_msg_pub.add;
105   END IF;
106 
107   IF ( (LENGTH(p_title) > t_max) OR (LENGTH(p_body) > b_max) )
108   THEN
109 
110      if length(p_title) > t_max then
111          l_param_max := 'LENGTH(P_TITLE) = ' || LENGTH(P_TITLE) || ' MAX for Title = ' || t_max ;
112      end if;
113 
114      if length(p_body) > b_max then
115          l_param_max := l_param_max||' LENGTH(P_BODY) = ' || LENGTH(P_BODY) || ' MAX for Body = ' || b_max ;
116      end if;
117 
118       x_return_status := FND_API.G_RET_STS_ERROR;
119      fnd_message.set_name('IEU','IEU_UWQ_PARAM_EXCEED_MAX');
120      FND_MESSAGE.SET_TOKEN('PACKAGE_NAME','IEU_MSG_PRODUCER_PUB.SEND_PLAIN_TEXT_MSG');
121      FND_MESSAGE.SET_TOKEN('IEU_UWQ_PARAM_MAX',l_param_max);
122      fnd_msg_pub.add;
123 --     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
124   END IF;
125 
126   IF p_resource_TYPE = 'RS_GROUP' or p_resource_TYPE = 'RS_TEAM'
127   THEN
128     x_return_status := FND_API.G_RET_STS_ERROR;
129     fnd_message.set_name('IEU','IEU_UWQ_INVALID_RESOURCE_TYPE');
130     FND_MESSAGE.SET_TOKEN('IEU_UWQ_RESOURCE_TYPE',P_RESOURCE_TYPE);
131     fnd_msg_pub.add;
132 --    fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
133   END IF;
134 
135   if x_return_status = FND_API.G_RET_STS_ERROR THEN
136       raise FND_API.G_EXC_ERROR;
137   ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
138       raise FND_API.G_EXC_UNEXPECTED_ERROR;
139   END IF;
140 
141   select IEU_MSG_MESSAGES_S1.NEXTVAL into x_message_id from dual;
142   INSERT INTO
143     IEU_MSG_MESSAGES
144     (
145       MESSAGE_ID,
146       OBJECT_VERSION_NUMBER,
147       CREATED_BY,
148       CREATION_DATE,
149       LAST_UPDATED_BY,
150       LAST_UPDATE_DATE,
151       LAST_UPDATE_LOGIN,
152       APPLICATION_ID,
153       RESOURCE_TYPE,
154       RESOURCE_ID,
155       STATUS_ID,
156       TITLE,
157       BODY,
158       WORKITEM_OBJ_CODE,
159       WORKITEM_PK_ID
160     )
161     VALUES
162     (
163       x_message_id,
164       1,
165       FND_GLOBAL.USER_ID,
166       SYSDATE,
167       FND_GLOBAL.USER_ID,
168       SYSDATE,
169       FND_GLOBAL.LOGIN_ID,
170       p_application_id,
171       'RS_INDIVIDUAL',
172       p_resource_id,
173       1,   -- just assuming 1 for now...
174       p_title,
175       p_body,
176       p_workitem_obj_code,
177       p_workitem_pk_id
178     );
179   -- Standard check of p_commit
180   IF FND_API.To_Boolean(p_commit) THEN
181      COMMIT WORK;
182   END IF;
183   FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
184   -- Standard call to get message count and if count is 1, get message info
185 EXCEPTION
186      WHEN FND_API.G_EXC_ERROR THEN
187           ROLLBACK TO SEND_PLAIN_TEXT_PUB;
188           x_return_status := FND_API.G_RET_STS_ERROR;
189           FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
190      WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
191           ROLLBACK TO SEND_PLAIN_TEXT_PUB;
192           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
193           FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
194      WHEN OTHERS THEN
195           ROLLBACK TO SEND_PLAIN_TEXT_PUB;
196           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
197           IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
198                FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
199           END IF;
200           FND_MSG_PUB.Count_And_Get(p_count => x_msg_count, p_data => x_msg_data);
201 
202 END SEND_PLAIN_TEXT_MSG;
203 
204 END IEU_MSG_PRODUCER_PUB;