DBA Data[Home] [Help]

PACKAGE BODY: APPS.AHL_PRD_PRINT_CUHK

Source


1 Package Body AHL_PRD_PRINT_CUHK AS
2 /*$Header: AHLCPPRB.pls 120.1.12020000.2 2012/12/12 06:30:42 kasridha ship $*/
3 
4 G_PKG_NAME VARCHAR2(30) := 'AHL_PRD_PRINT_CUHK';
5 
6  --  Start of Comments  --
7  --
8  --  Procedure name      : Generate_JCG_XML_PRE
9  --  Type                : Public
10  --  Function            : Provide User Hooks for the customer to add validations
11  --                        before Enigma work card request is processed.
12  --
13  --  Standard IN  Parameters :
14  --
15  --  Standard OUT Parameters :
16  --    x_return_status                 OUT     VARCHAR2              Required
17  --    x_msg_count                     OUT     NUMBER                Required
18  --    x_msg_data                      OUT     VARCHAR2              Required
19  --
20  --  Generate_JCG_XML_PRE  Parameters :
21  --    p_object_type: Entity Type of the workcard request
22  --                   p_object_type = 'VST' if work card request is for a Visit.
23  --                   p_object_type = 'MR'  if work card request is for a Maintenance Requirement.
24  --                   p_object_type = 'WO'  if work card request is for a work order.
25  --
26  --    p_object_id  : Object ID.
27  --                   p_object_id = ahl_visits_b.visit_id if work card request is for a Visit.
28  --                   p_object_id = ahl_unit_effectivities_b.unit_effectivity_id if work card request is for a Maintenance Requirement.
29  --                   p_object_id = ahl_workorders.workorder_id if work card request is for a work order.
30  --
31  --    p_split_flag : Valid values are 'Y' or 'N'. Indicates if separate work cards for work orders also need to be generated along with
32  --                   MR and Visit bundle. Valid only when p_object_type: is MR or VST.
33  --
34  --  Version :
35  --      Initial Version   1.0
36  --
37  --  End of Comments  --
38 
39  PROCEDURE Generate_JCG_XML_PRE ( p_object_type   IN VARCHAR2,
40                                   p_object_id     IN NUMBER,
41                                   p_split_flag    IN VARCHAR2,
42                                   x_msg_count     IN OUT NOCOPY VARCHAR2,
43                                   x_msg_data      IN OUT NOCOPY VARCHAR2,
44                                   x_return_status IN OUT NOCOPY VARCHAR2)
45  IS
46     l_api_name          VARCHAR2(30) := 'Generate_JCG_XML_PRE';
47 
48  BEGIN
49    SAVEPOINT Generate_JCG_XML_PRE_CUHK;
50 
51    x_return_status:=FND_API.G_RET_STS_SUCCESS;
52 
53    IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)THEN
54         fnd_log.string
55     (
56       fnd_log.level_procedure,
57       'ahl.plsql.'||g_pkg_name||'.'||l_api_name||'.begin',
58       'At the start of Generate_JCG_XML_PRE'
59     );
60 
61    END IF;
62 
63    -- customer to add the customization code here
64    -- for pre processing
65    --
66    --
67 
68    IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)THEN
69 
70     fnd_log.string
71     (
72       fnd_log.level_procedure,
73       'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
74       'x_return_status:' || x_return_status
75     );
76 
77     fnd_log.string
78     (
79       fnd_log.level_procedure,
80       'ahl.plsql.'||g_pkg_name||'.'||l_api_name||'.end',
81       'At the end of Generate_JCG_XML_PRE'
82     );
83 
84    END IF;
85 
86  EXCEPTION
87    WHEN FND_API.G_EXC_ERROR THEN
88     ROLLBACK TO Generate_JCG_XML_PRE_CUHK;
89     x_return_status := FND_API.G_RET_STS_ERROR;
90     FND_MSG_PUB.count_and_get(
91       p_encoded  => FND_API.G_FALSE,
92       p_count    => x_msg_count,
93       p_data     => x_msg_data);
94 
95   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
96     ROLLBACK TO Generate_JCG_XML_PRE_CUHK;
97     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
98     FND_MSG_PUB.count_and_get(
99       p_encoded  => FND_API.G_FALSE,
100       p_count    => x_msg_count,
101       p_data     => x_msg_data);
102 
103   WHEN OTHERS THEN
104     ROLLBACK TO Generate_JCG_XML_PRE_CUHK;
105     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
106     IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
107       FND_MSG_PUB.add_exc_msg(
108         p_pkg_name         => G_PKG_NAME,
109         p_procedure_name   => l_api_name,
110         p_error_text       => SUBSTRB(SQLERRM,1,240));
111     END IF;
112     FND_MSG_PUB.count_and_get(
113       p_encoded  => FND_API.G_FALSE,
114       p_count    => x_msg_count,
115       p_data     => x_msg_data);
116 
117  END Generate_JCG_XML_PRE;
118 
119 
120 
121  --Start of Comments  --
122  --
123  --  Procedure name      : Generate_JCG_XML_POST
124  --  Type                : Public
125  --  Function            : Provide User Hooks for the customer for post-processing
126  --                        after work card request data file(XML) is created. Customer
127  --                        can modify input filename or output a new filename altogether that
128  --                        contains all information (in the XML specification that Enigma JCG server is expecting)
129  --                        needed for Enigma JCG server to generate the job card.
130  --
131  --  Standard IN  Parameters :
132  --
133  --  Standard OUT Parameters :
134  --      x_return_status                 OUT     VARCHAR2              Required
135  --      x_msg_count                     OUT     NUMBER                Required
136  --      x_msg_data                      OUT     VARCHAR2              Required
137  --
138  --  PERFORM_MTLTXN_POST Parameters :
139  --    p_object_type: Entity Type of the workcard request
140  --                   p_object_type = 'VST' if work card request is for a Visit.
141  --                   p_object_type = 'MR'  if work card request is for a Maintenance Requirement.
142  --                   p_object_type = 'WO'  if work card request is for a work order.
143  --
144  --    p_object_id  : Object ID.
145  --                   p_object_id = ahl_visits_b.visit_id if work card request is for a Visit.
146  --                   p_object_id = ahl_unit_effectivities_b.unit_effectivity_id if work card request is for a Maintenance Requirement.
147  --                   p_object_id = ahl_workorders.workorder_id if work card request is for a work order.
148  --
149  --    p_split_flag : Valid values are 'Y' or 'N'. Indicates if separate work cards for work orders also need to be generated along with
150  --                   MR and Visit bundle. Valid only when p_object_type: is MR or VST.
151  --
152  --    p_ahl_wrkpkg_xml : Input XML CLOB generated by caller API that is based on the CMRO-JCG WorkPackage XSD definition
153  --                       documented in CMRO-Enigma JCG Setup document. This XSD is different than the one required by Enigma to generate
154  --                       the job card. This CLOB contains various CMRO/Oracle EBS attributes related to the work orders, MR and Visit
155  --                       for the input object_type and object_id.
156  --
157  --    p_jcg_wrkpkg_location : directory on the DB server where the XML file to be processed by the Enigma JCG server needs to be created.
158  --
159  --    x_jcg_wrkpkg_file  : The custom hook code is expected to generate this file as per the Enigma JCG DTD. The caller API will
160  --                         will invoke the Enigma JCG Web Service with this filename information.
161  --                         Custom XML for Enigma JCG can be created by combining the information provided in p_ahl_wrkpkg_xml and
162  --                         adding custom attributes.
163  --                         When generating XML using custom code, it will be customer's responsibility to ensure that the right file
164  --                         adhering to Enigma DTD format is generated, saved in the directoty p_jcg_wrkpkg_location and filename
165  --                         is returned to the caller API in variable p_x_xml_filename.
166  --                         Following rules need to be followed when creating this XML file to make the CMRO-Enigma JCG integration
167  --                         work:
168  --                         1) workpackage:
169  --                              @id should be formed as a concatenation of p_object_type, hyphen and p_object_id. No spaces must be
170  --                                  embedded. Example: VST-10023 or MR-34828 or WO-83773
171  --                                  If any other custom identifications are needed, then they can be appended after this string.
172  --                         2) job_card:
173  --                              @id should be mapped to CMRO-JCG WorkPackage jobcard[@workorderid]
174  --
175  --                         Any errors related to data in the XML file have to be addressed by the Customer.
176  --
177  --  Version :
178  --      Initial Version   1.0
179  --
180  --  End of Comments  --
181 
182  PROCEDURE Generate_JCG_XML_POST ( p_object_type         IN VARCHAR2,
183                                    p_object_id           IN NUMBER,
184                                    p_split_flag          IN VARCHAR2,
185                                    p_ahl_wrkpkg_xml      IN CLOB,
186                                    p_jcg_wrkpkg_location IN VARCHAR2,
187                                    x_msg_count           OUT NOCOPY VARCHAR2,
188                                    x_msg_data            OUT NOCOPY VARCHAR2,
189                                    x_return_status       OUT NOCOPY VARCHAR2,
190                                    x_jcg_wrkpkg_file     OUT NOCOPY VARCHAR2)
191  IS
192     l_api_name          VARCHAR2(30) := 'Generate_JCG_XML_POST';
193 
194  BEGIN
195    SAVEPOINT Generate_JCG_XML_POST_CUHK;
196 
197    IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)THEN
198 
199     fnd_log.string
200     (
201       fnd_log.level_procedure,
202       'ahl.plsql.'||g_pkg_name||'.'||l_api_name||'.begin',
203       'At the start of Generate_JCG_XML_POST'
204     );
205 
206     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
207                     'Input p_object_type:' || p_object_type);
208     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
209                     'Input p_object_id:' || p_object_id);
210     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
211                     'Input p_split_flag:' || p_split_flag);
212     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
213                     'Input p_jcg_wrkpkg_location:' || p_jcg_wrkpkg_location);
214 
215    END IF;
216 
217    x_return_status:=FND_API.G_RET_STS_SUCCESS;
218 
219    /* For more information on out of the box transformation provided, customer can
220     * review following procedures and function -
221 
222       1. AHL_PRD_PRINT_PVT.get_xsl_clob : this function returns the default transformation(xsl) defined between CMRO workpackage xsd
223                                           and Enigma JCG xsd.
224 
225       2. AHL_PRD_PRINT_PVT.APPLY_TRANSFORMATION : This procedure applies a given xsl transformation on the input XML based on
226                                                   CMRO workpackage xsd and generates a output XML file based on Enigma JCG xsd.
227 
228    */
229    -- customer to add the customization code here
230    -- for pre processing
231    --
232    --
233    --
234    -- end custom code
235 
236    IF (fnd_log.level_procedure >= fnd_log.g_current_runtime_level)THEN
237 
238     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
239                     'Output x_return_status:' || x_return_status);
240     fnd_log.string (fnd_log.level_procedure, 'ahl.plsql.'||g_pkg_name||'.'||l_api_name,
241                     'Output x_jcg_wrkpkg_file:' || x_jcg_wrkpkg_file);
242     fnd_log.string
243     (
244       fnd_log.level_procedure,
245       'ahl.plsql.'||g_pkg_name||'.'||l_api_name||'.end',
246       'At the end of Generate_JCG_XML_POST'
247     );
248    END IF;
249 
250  EXCEPTION
251    WHEN FND_API.G_EXC_ERROR THEN
252     ROLLBACK TO Generate_JCG_XML_POST_CUHK;
253     x_return_status := FND_API.G_RET_STS_ERROR;
254     FND_MSG_PUB.count_and_get(
255       p_encoded  => FND_API.G_FALSE,
256       p_count    => x_msg_count,
257       p_data     => x_msg_data);
258 
259   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
260     ROLLBACK TO Generate_JCG_XML_POST_CUHK;
261     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
262     FND_MSG_PUB.count_and_get(
263       p_encoded  => FND_API.G_FALSE,
264       p_count    => x_msg_count,
265       p_data     => x_msg_data);
266 
267  WHEN OTHERS THEN
268     ROLLBACK TO Generate_JCG_XML_POST_CUHK;
269     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
270     IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
271       FND_MSG_PUB.add_exc_msg(
272         p_pkg_name         => G_PKG_NAME,
273         p_procedure_name   => l_api_name,
274         p_error_text       => SUBSTRB(SQLERRM,1,240));
275     END IF;
276     FND_MSG_PUB.count_and_get(
277       p_encoded  => FND_API.G_FALSE,
278       p_count    => x_msg_count,
279       p_data     => x_msg_data);
280 
281  END Generate_JCG_XML_POST;
282 
283 
284 
285 END AHL_PRD_PRINT_CUHK;