[Home] [Help]
PACKAGE BODY: APPS.AP_WEB_DFLEX_PKG
Source
1 PACKAGE BODY AP_WEB_DFLEX_PKG AS
2 /* $Header: apwdflxb.pls 120.14.12020000.3 2012/10/25 07:01:47 preshukl ship $ */
3
4 --
5 -- Record definition for ap_expense_report_params.
6 -- Used locally to this file.
7 --
8
9 TYPE ParameterRec IS RECORD (
10 parameter_id NUMBER,
11 prompt AP_WEB_DB_EXPTEMPLATE_PKG.expTempl_webFriendlyPrompt,
12 prompt_code AP_WEB_DB_EXPTEMPLATE_PKG.expTempl_prompt,
13 calculate_amount_flag VARCHAR2(1),
14 pa_expenditure_type VARCHAR2(30),
15 amount_includes_tax VARCHAR2(1));
16
17 TYPE ParameterRec_A IS TABLE OF ParameterRec
18 INDEX BY BINARY_INTEGER;
19
20 --
21 -- Constants
22 --
23
24
25 C_FuncCode CONSTANT VARCHAR2(50) := 'AP_WEB_EXPENSES';
26 C_AppShortName CONSTANT VARCHAR2(10) := 'SQLAP';
27 C_LinesDescFlexName CONSTANT VARCHAR2(50) := 'AP_EXPENSE_REPORT_LINES';
28 C_SpecialCheckboxValueSet CONSTANT VARCHAR2(100) := 'AP_SRS_YES_NO_MAND';
29
30 C_DefaultTextSize CONSTANT NUMBER := 15;
31 C_MaxTextSize CONSTANT NUMBER := 20;
32 C_DefaultTextMaxLength CONSTANT NUMBER := 0;
33 C_ProjectNumberMaxLength CONSTANT NUMBER := 30;
34 c_taskNumberMaxLength CONSTANT NUMBER := 25;
35
36 C_InputObjectPrefix CONSTANT VARCHAR2(10) := 'FLEX';
37 C_InputPseudoObjectPrefix
38 CONSTANT VARCHAR2(10) := 'PFLEX';
39
40 C_ValidIndependent CONSTANT VARCHAR2(50) := 'I';
41 C_ValidNone CONSTANT VARCHAR2(50) := 'N';
42 C_ValidTable CONSTANT VARCHAR2(50) := 'F';
43
44 C_DefaultTypeConstant CONSTANT VARCHAR2(50) := 'C';
45
46 C_ValidFormatTypeNum CONSTANT VARCHAR2(50) := 'N';
47 C_ValidFormatTypeChar CONSTANT VARCHAR2(50) := 'C';
48
49
50 C_CheckboxInputObject CONSTANT VARCHAR2(20) := 'CHECKBOX';
51 C_HiddenInputObject CONSTANT VARCHAR2(20) := 'HIDDEN';
52 C_SelectInputObject CONSTANT VARCHAR2(20) := 'SELECT';
53 C_TextInputObject CONSTANT VARCHAR2(20) := 'TEXT';
54
55 C_Yes CONSTANT VARCHAR2(1) := 'Y';
56 C_No CONSTANT VARCHAR2(1) := 'N';
57
58
59 C_AttributeColSize CONSTANT NUMBER := 150;
60
61 C_GLOBAL CONSTANT varchar2(6):='GLOBAL';
62
63 C_CalcAmount_Prompt CONSTANT NUMBER := 30;
64 C_TaxName_Prompt CONSTANT NUMBER := 32;
65 C_TaxNameIncl_Prompt CONSTANT NUMBER := 33;
66 C_TaxNameExcl_Prompt CONSTANT NUMBER := 34;
67 C_ProjectNumber_Prompt CONSTANT NUMBER := 35;
68 C_TaskNumber_Prompt CONSTANT NUMBER := 36;
69
70 -- Number of pseudo context flexfields (amount includes tax, tax name)
71 C_PseudoSegProjectNumberOffset CONSTANT NUMBER := 1;
72 C_PseudoSegTaskNumberOffset CONSTANT NUMBER := 2;
73 C_PseudoSegAmtInclTaxOffset CONSTANT NUMBER := 1;
74 C_PseudoSegTaxNameOffset CONSTANT NUMBER := 2;
75 C_NumMaxPseudoFlexField CONSTANT NUMBER := 4;
76 C_NumTaxPseudoFlexField CONSTANT NUMBER := 2;
77 C_NumProjectPseudoFlexField CONSTANT NUMBER := 2;
78
79 FUNCTION BOOL2STRING(p_bBool IN BOOLEAN)
80 RETURN VARCHAR2
81 IS
82 BEGIN
83 IF p_bBool THEN
84 RETURN('true');
85 ELSE
86 RETURN('false');
87 END IF;
88 RETURN ('""');
89 END Bool2String;
90
91
92 -------------------------------------------------------------------------------
93 FUNCTION Minimum(A IN NUMBER, B IN NUMBER) RETURN NUMBER
94 -------------------------------------------------------------------------------
95 IS
96 BEGIN
97 IF A < B THEN
98 RETURN A;
99 ELSE
100 RETURN B;
101 END IF;
102 END Minimum;
103
104 ------------------------------------------------------------------------------
105 FUNCTION ParameterRecAContains(
106 P_Prompt IN VARCHAR2,
107 P_PromptArray IN ParameterRec_A,
108 P_PromptArraySize IN NUMBER)
109 RETURN BOOLEAN
110 ------------------------------------------------------------------------------
111 IS
112 I NUMBER;
113 BEGIN
114 FOR I IN 1 .. P_PromptArraySize LOOP
115 IF P_Prompt = P_PromptArray(I).prompt THEN
116 RETURN TRUE;
117 END IF;
118 END LOOP;
119 RETURN FALSE;
120 END ParameterRecAContains;
121
122 -------------------------------------------------------------------------------
123 FUNCTION IsSegmentWebEnabled(P_Segments IN FND_DFLEX.SEGMENTS_DR,
124 P_Index IN NUMBER)
125 RETURN BOOLEAN
126 -------------------------------------------------------------------------------
127 IS
128 BEGIN
129 RETURN(P_Segments.description(P_Index) IS NOT NULL);
130 END IsSegmentWebEnabled;
131
132 -------------------------------------------------------------------------------
133 FUNCTION IsSegmentValidType(P_ValueSetInfo IN FND_VSET.VALUESET_R)
134 RETURN BOOLEAN
135 -------------------------------------------------------------------------------
136 IS
137 BEGIN
138 RETURN P_ValueSetInfo.validation_type = C_ValidIndependent OR
139 P_ValueSetInfo.validation_type = C_ValidNone OR
140 P_ValueSetInfo.validation_type = C_ValidTable;
141 END IsSegmentValidType;
142
143 -------------------------------------------------------------------------------
144 FUNCTION IsSegmentRendered(P_Segments IN FND_DFLEX.SEGMENTS_DR,
145 P_SegIndex IN NUMBER,
146 P_ValueSetInfo IN FND_VSET.VALUESET_R)
147 RETURN BOOLEAN
148 -------------------------------------------------------------------------------
149 IS
150 BEGIN
151 RETURN P_Segments.is_displayed(P_SegIndex) AND
152 IsSegmentWebEnabled(P_Segments, P_SegIndex) AND
153 IsSegmentValidType(P_ValueSetInfo);
154 END IsSegmentRendered;
155
156
157 -------------------------------------------------------------------------------
158 PROCEDURE GetEnabledSegments(P_Segments FND_DFLEX.SEGMENTS_DR,
159 Map_Array OUT NOCOPY AP_WEB_PARENT_PKG.Number_Array,
160 P_NumOfEnabledSegments OUT NOCOPY NUMBER)
161 -------------------------------------------------------------------------------
162 IS
163 --
164 -- Returns the indexes of the enabled segments from P_Segments in Map_Array
165 -- and the number of enabled segments are returned in P_NumOfEnabledSegments.
166 --
167
168 I NUMBER;
169 V_NumElem NUMBER;
170 BEGIN
171
172 V_NumElem := 0;
173 FOR I IN 1..P_Segments.nsegments LOOP
174 IF P_Segments.is_enabled(I) THEN
175 V_NumElem := V_NumElem + 1;
176 Map_Array(V_NumElem) := I;
177 END IF;
178 END LOOP;
179 P_NumOfEnabledSegments := V_NumElem;
180
181 END GetEnabledSegments;
182
183 -------------------------------------------------------------------------------
184 PROCEDURE GetIndepSegmentEnabledValues(P_ValueSetInfo IN FND_VSET.VALUESET_R,
185 P_NumOfTableElem IN OUT NOCOPY NUMBER,
186 P_PoplistArray IN OUT NOCOPY PoplistValues_A)
187 -------------------------------------------------------------------------------
188 IS
189 --
190 -- Returns the enabled independent validation values for the given
191 -- valueset in the P_PoplistArray.
192 --
193
194 V_ValueInfo FND_VSET.VALUE_DR;
195 V_NumValueSetValue NUMBER;
196 V_Found BOOLEAN;
197 V_CurrentCallingSequence VARCHAR2(100);
198 V_DebugInfo VARCHAR2(100);
199 BEGIN
200
201 V_CurrentCallingSequence := 'AP_WEB_FLEX_PKG.GetIndepSegmentEnabledValues';
202
203 P_NumOfTableElem := 0;
204 FND_VSET.get_value_init(P_ValueSetInfo, TRUE);
205
206 FND_VSET.get_value(P_ValueSetInfo, V_NumValueSetValue, V_Found, V_ValueInfo);
207 WHILE V_Found LOOP
208
209 IF (trunc(nvl(V_ValueInfo.start_date_active,sysdate)) <= trunc(sysdate)
210 AND trunc(nvl(V_ValueInfo.end_date_active,sysdate)) >= trunc(sysdate))
211 THEN
212 P_NumOfTableElem := P_NumOfTableElem + 1;
213
214 P_PoplistArray(P_NumOfTableElem).InternalValue := V_ValueInfo.value;
215 P_PoplistArray(P_NumOfTableElem).DisplayText := V_ValueInfo.value;
216 END IF;
217
218 FND_VSET.get_value(P_ValueSetInfo, V_NumValueSetValue, V_Found, V_ValueInfo);
219
220 END LOOP;
221
222 FND_VSET.get_value_end(P_ValueSetInfo);
223 EXCEPTION
224 WHEN OTHERS THEN
225 BEGIN
226 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
227 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
228 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
229 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
230 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
231 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
232 END;
233
234 END GetIndepSegmentEnabledValues;
235
236 -------------------------------------------------------------------------------
237 PROCEDURE GetValueSet(P_ValueSetID IN NUMBER,
238 P_ValueSetInfo OUT NOCOPY FND_VSET.VALUESET_R,
239 P_ValueSetFormat OUT NOCOPY FND_VSET.VALUESET_DR)
240 -------------------------------------------------------------------------------
241 IS
242 -- Since segments without value sets are allowed, we're setting the
243 -- values in P_ValueSetInfo and P_ValueSetFormat used throughout the
244 -- dflex code.
245 BEGIN
246
247 IF (P_ValueSetID IS NOT NULL) THEN
248
249 -- If value set assigned to segment, then get appropriate information
250 -- from Get_valueset output. The V_ValueSetInfo will only be referenced
251 -- if it is an independent-validated type value set.
252
253 FND_VSET.Get_valueset(P_ValueSetID, P_ValueSetInfo, P_ValueSetFormat);
254
255 ELSE
256
257 -- If no value set assigned to segment, treat it as a none-validated
258 -- value set.
259
260 P_ValueSetInfo.validation_type := C_ValidNone;
261 -- P_ValueSetFormat.longlist_enabled := FALSE;
262 P_ValueSetFormat.max_size := C_AttributeColSize;
263 P_ValueSetInfo.name := NULL;
264 P_ValueSetFormat.alphanumeric_allowed_flag := C_Yes;
265 P_ValueSetFormat.uppercase_only_flag := C_No;
266 P_ValueSetFormat.format_type := NULL;
267
268 END IF;
269
270 END GetValueSet;
271
272 -------------------------------------------------------------------------------
273 FUNCTION GenFlexSegmentPrompt(P_Segments IN FND_DFLEX.SEGMENTS_DR,
274 P_SegIndex IN NUMBER) RETURN VARCHAR2
275 -------------------------------------------------------------------------------
276 IS
277 --
278 -- Returns the prompt for the given segment.
279 --
280
281 BEGIN
282 RETURN P_Segments.row_prompt(P_SegIndex);
283 END GenFlexSegmentPrompt;
284
285 -------------------------------------------------------------------------------
286 FUNCTION GenFlexSegWizText(P_Segments IN FND_DFLEX.SEGMENTS_DR,
287 P_SegIndex IN NUMBER) RETURN VARCHAR2
288 -------------------------------------------------------------------------------
289 IS
290 --
291 -- Returns the prompt for the given segment.
292 --
293
294 BEGIN
295 RETURN P_Segments.description(P_SegIndex);
296 END GenFlexSegWizText;
297
298
299 -------------------------------------------------------------------------------
300 PROCEDURE GetTaxPseudoSegmentDefaults(
301 P_ExpTypeID IN AP_EXPENSE_REPORT_PARAMS.parameter_id%TYPE,
302 P_ExpTypeTaxCodeUpdateable IN OUT NOCOPY VARCHAR2,
303 P_ExpTypeDefaultTaxCode IN OUT NOCOPY ZX_WEBEXP_CLASSIFICATIONS_V.LOOKUP_CODE%TYPE,--bug#14798565
304 P_OrgId IN NUMBER)
305 -------------------------------------------------------------------------------
306 IS
307
308 V_ExpTypeRec AP_WEB_DB_EXPTEMPLATE_PKG.ExpTypeInfoRec;
309
310 V_DefaultTaxID NUMBER(15);
311 V_DefaultTaxType VARCHAR2(25);
312 V_DefaultTaxDesc VARCHAR2(240);
313
314 V_DefaultTaxCode VARCHAR2(30);
315
316
317 BEGIN
318
319 IF P_ExpTypeID IS NULL THEN
320 P_ExpTypeTaxCodeUpdateable := C_No;
321 P_ExpTypeDefaultTaxCode := NULL;
322 RETURN;
323 END IF;
324
325 -- Get information about the expense type
326 IF (NOT AP_WEB_DB_EXPTEMPLATE_PKG.GetExpTypeInfo(P_ExpTypeID, V_ExpTypeRec)) THEN
327 NULL;
328 END IF;
329
330
331 -- Get tax code information
332 BEGIN
333 ZX_AP_TAX_CLASSIFICATN_DEF_PKG.get_default_tax_classification
334 (--p_line_location_id => null,
335 p_ref_doc_application_id => null,
336 p_ref_doc_entity_code => null,
337 p_ref_doc_event_class_code => null,
338 p_ref_doc_trx_id => null,
339 p_ref_doc_line_id => null,
340 p_ref_doc_trx_level_type => null,
341 p_vendor_id => null,
342 p_vendor_site_id => null,
343 p_code_combination_id => null,
344 p_concatenated_segments => V_ExpTypeRec.flex_concat,
345 p_templ_tax_classification_cd => V_ExpTypeRec.vat_code,
346 p_ship_to_location_id => null,
347 p_ship_to_loc_org_id => null,
348 p_inventory_item_id => null,
349 p_item_org_id => null,
350 p_tax_classification_code => P_ExpTypeDefaultTaxCode,
351 p_allow_tax_code_override_flag => P_ExpTypeTaxCodeUpdateable,
352 APPL_SHORT_NAME => 'SQLAP',
353 FUNC_SHORT_NAME => 'NONE',
354 p_calling_sequence => 'APXXXEER',
355 p_event_class_code => 'EXPENSE REPORTS',
356 p_entity_code => 'AP_INVOICES',
357 p_application_id => 200,
358 p_internal_organization_id => P_OrgId);
359
360 EXCEPTION
361 WHEN NO_DATA_FOUND THEN
362 BEGIN
363 P_ExpTypeDefaultTaxCode := NULL;
364 END;
365 END;
366
367 -- Clear out the default tax if it is not web enabled. This is a setup
368 -- error.
369 IF (NOT AP_WEB_DB_ETAX_INT_PKG.IsTaxCodeWebEnabled(P_ExpTypeDefaultTaxCode)) THEN
370 P_ExpTypeDefaultTaxCode := NULL;
371 END IF;
372
373 -- If TaxCodeUpdateable is NULL then set to Yes by default.
374 P_ExpTypeTaxCodeUpdateable := NVL(P_ExpTypeTaxCodeUpdateable, C_Yes);
375
376
377 END GetTaxPseudoSegmentDefaults;
378
379 -------------------------------------------------------------------------------
380 FUNCTION GetSegmentDefault(P_ContextValue IN VARCHAR2,
381 P_Segments IN FND_DFLEX.SEGMENTS_DR,
382 P_SegIndex IN NUMBER)
383 RETURN VARCHAR2
384 -------------------------------------------------------------------------------
385 IS
386 --
387 -- Returns the default value for the segment as determined by the default
388 -- specified in the 10SC form and the custom default procedure.
389 --
390
391 V_DefaultValue VARCHAR2(240);
392 V_DefaultValueSet BOOLEAN;
393
394 V_CurrentCallingSequence VARCHAR2(100);
395 V_DebugInfo VARCHAR2(100);
396
397 BEGIN
398
399 V_CurrentCallingSequence := 'AP_WEB_FLEX_PKG.GetSegmentDefault';
400
401 IF (P_SegIndex > P_Segments.nsegments) THEN
402 RETURN '';
403 END IF;
404
405 -- Get custom values here
406 V_DebugInfo := 'Get custom values here';
407 AP_WEB_CUST_DFLEX_PKG.CustomPopulateDefault(
408 P_ContextValue,
409 P_Segments.segment_name(P_SegIndex), V_DefaultValue);
410
411 -- If no custom values set, then use defaults
412 V_DebugInfo := 'Get default value';
413 IF V_DefaultValue IS NULL THEN
414
415 -- htp.p('P_Segments.default_value(P_SegIndex)=' || P_Segments.default_value(P_SegIndex) || 'P_SegIndex=' || to_char(P_SegIndex));
416 IF P_Segments.default_type(P_SegIndex) = C_DefaultTypeConstant THEN
417 V_DefaultValue := P_Segments.default_value(P_SegIndex);
418 END IF;
419 END IF;
420
421 RETURN V_DefaultValue;
422 EXCEPTION
423 WHEN OTHERS THEN
424 BEGIN
425 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
426 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
427 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
428 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
429 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
430 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
431 END;
432
433 END GetSegmentDefault;
434
435 -------------------------------------------------------------------------------
436 FUNCTION GenInputObjectName(P_ObjectIndex IN NUMBER) RETURN VARCHAR2
437 -------------------------------------------------------------------------------
438 IS
439 --
440 -- Returns the name of the input objects used in the flex frame.
441 --
442 BEGIN
443 RETURN C_InputObjectPrefix || TO_CHAR(P_ObjectIndex);
444 END GenInputObjectName;
445
446 -------------------------------------------------------------------------------
447 FUNCTION GenInputPseudoObjectName(P_ObjectIndex IN NUMBER) RETURN VARCHAR2
448 -------------------------------------------------------------------------------
449 IS
450 --
451 -- Returns the name of the input objects used in the flex frame.
452 --
453 BEGIN
454 RETURN C_InputPseudoObjectPrefix || TO_CHAR(P_ObjectIndex);
455 END GenInputPseudoObjectName;
456
457 -------------------------------------------------------------------------------
458 FUNCTION GenHiddenInput(P_InputName IN VARCHAR2,
459 P_Value IN VARCHAR2)
460 RETURN VARCHAR2
461 -------------------------------------------------------------------------------
462 IS
463 BEGIN
464 RETURN '<INPUT TYPE=\"hidden\" NAME=\"' || P_InputName || '\" VALUE=\"' || P_Value || '\">';
465 END GenHiddenInput;
466
467 -------------------------------------------------------------------------------
468 FUNCTION GenTextInput(P_InputName IN VARCHAR2,
469 P_Value IN VARCHAR2,
470 P_Size IN NUMBER,
471 P_MaxLength IN NUMBER) RETURN VARCHAR2
472 -------------------------------------------------------------------------------
473 IS
474 V_ValidSize VARCHAR2(100);
475 V_ValidMaxLength VARCHAR2(100);
476 BEGIN
477 V_ValidSize := TO_CHAR(NVL(P_Size, C_DefaultTextSize));
478 -- to fix bug#1079905, we do not limit the size of the flexfield
479 /*
480 IF V_ValidSize > C_MaxTextSize THEN
481 V_ValidSize := C_MaxTextSize;
482 END IF;
483 */
484 V_ValidMaxLength := TO_CHAR(NVL(P_MaxLength, C_DefaultTextMaxLength));
485
486 RETURN '<FONT class=promptblack><INPUT TYPE=\"text\" NAME=\"' || P_InputName || '\" VALUE=\"' || P_Value ||
487 '\" SIZE=' || V_ValidSize || ' MAXLENGTH=' || V_ValidMaxLength || '></FONT>';
488 END GenTextInput;
489
490 -------------------------------------------------------------------------------
491 FUNCTION GenCheckboxInput(P_InputName IN VARCHAR2,
492 P_Checked IN VARCHAR2)
493 RETURN VARCHAR2
494 -------------------------------------------------------------------------------
495 IS
496 V_Value VARCHAR2(10);
497 C_CheckboxChecked CONSTANT VARCHAR2(50) := 'CHECKED';
498 BEGIN
499 V_Value := '';
500 IF P_Checked = C_Yes THEN
501 V_Value := C_CheckboxChecked;
502 END IF;
503 RETURN '<INPUT TYPE=\"checkbox\" NAME=\"' || P_InputName || '\" ' || V_Value || '>';
504 END GenCheckboxInput;
505
506
507
508 -------------------------------------------------------------------------------
509 function LOVButton (c_attribute_app_id in number,
510 c_attribute_code in varchar2,
511 c_region_app_id in number,
512 c_region_code in varchar2,
513 c_form_name in varchar2,
514 c_frame_name in varchar2 default null,
515 c_where_clause in varchar2 default null,
516 c_js_where_clause in varchar2 default null,
517 c_image_align in varchar2 default 'CENTER')
518 return varchar2 is
519 -------------------------------------------------------------------------------
520 temp varchar2(2000);
521 temp1 varchar2(2000);
522 c_language varchar2(30);
523 l_prompts AP_WEB_UTILITIES_PKG.prompts_table;
524 l_title AK_REGIONS_VL.NAME%TYPE;
525 l_where_clause varchar2(2000);
526
527 begin
528 c_language := icx_sec.getID(icx_sec.PV_LANGUAGE_CODE);
529 AP_WEB_DISC_PKG.getPrompts(601,'ICX_LOV',l_title,l_prompts);
530 l_where_clause := icx_call.encrypt2(c_where_clause);
531 temp1 := 'javascript:top.opener.top.framMain.lines.setProjectNumberBindValue();';
532 temp := htf.anchor(temp1||'LOV('''||c_attribute_app_id||''','''||c_attribute_code||''','''||c_region_app_id||''','''||c_region_code||''','''||c_form_name||''','''||c_frame_name||''','''||l_where_clause||''','''||c_js_where_clause||''')',
533
534 htf.img(AP_WEB_INFRASTRUCTURE_PKG.getImagePath||'FNDILOV.gif',c_image_align,icx_util.replace_alt_quotes(l_title),'','BORDER=0 WIDTH=23 HEIGHT=21'),'','');
535 return temp;
536 end;
537
538
539
540 -------------------------------------------------------------------------------
541 PROCEDURE GetSegmentType( P_ContextValue IN VARCHAR2,
542 P_Segments IN FND_DFLEX.SEGMENTS_DR,
543 P_SegIndex IN NUMBER,
544 P_InputObjectType OUT NOCOPY VARCHAR2
545 )
546 -------------------------------------------------------------------------------
547 IS
548 --
549 -- Generates the HTML input objects (SELECT, TEXT, HIDDEN, CHECKBOX) for the
550 -- particular flexfield segment.
551 --
552
553 V_ValueSetInfo FND_VSET.VALUESET_R;
554 V_ValueSetFormat FND_VSET.VALUESET_DR;
555 V_PoplistArray PoplistValues_A;
556 V_SegDefaultValue VARCHAR2(240);
557 V_NumOfTableElem NUMBER;
558 V_CheckboxChecked VARCHAR2(100);
559
560 V_CurrentCallingSequence VARCHAR2(100);
561 V_DebugInfo VARCHAR2(100);
562
563 BEGIN
564
565 V_CurrentCallingSequence := 'AP_WEB_FLEX_PKG.GetSegmentType';
566
567 -- Just define an input object stub only
568 V_DebugInfo := 'Generate segment stub';
569
570
571 -- Get Value Set
572 GetValueSet(P_Segments.value_set(P_SegIndex),V_ValueSetInfo, V_ValueSetFormat);
573
574
575 IF NOT IsSegmentRendered(P_Segments, P_SegIndex, V_ValueSetInfo) THEN
576 -- Segment is hidden
577 P_InputObjectType := C_HiddenInputObject;
578
579 ELSE
580
581 -- If long list is enabled, then the segment is always rendered as a
582 -- text box
583 IF (NOT AP_WEB_WRAPPER_PKG.isPopList(V_ValueSetFormat)) THEN
584 -- Text input
585 P_InputObjectType := C_TextInputObject;
586 ELSIF (V_ValueSetInfo.validation_type = C_ValidIndependent) THEN
587
588 -- try to populate with custom routines
589 V_DebugInfo := 'Get poplist input values';
590 AP_WEB_CUST_DFLEX_PKG.CustomPopulatePoplist(
591 P_ContextValue,
592 P_Segments.segment_name(P_SegIndex), V_NumOfTableElem,
593 V_PoplistArray);
594
595 IF V_NumOfTableElem = 0 THEN
596 -- Poplist input
597 V_DebugInfo := 'Generate poplist input';
598 GetIndepSegmentEnabledValues(V_ValueSetInfo, V_NumOfTableElem,
599 V_PoplistArray);
600 END IF;
601
602
603 -- If there are poplist values then create a poplist item, otherwise
604 -- create a textfield.
605 IF V_NumOfTableElem <> 0 THEN
606 P_InputObjectType := C_SelectInputObject;
607
608 ELSE
609
610 P_InputObjectType := C_TextInputObject;
611
612 END IF;
613
614 ELSIF (V_ValueSetInfo.validation_type = C_ValidNone) THEN
615
616 -- Text input
617 P_InputObjectType := C_TextInputObject;
618
619 ELSIF (V_ValueSetInfo.validation_type = C_ValidTable) THEN
620
621 IF (V_ValueSetInfo.name = C_SpecialCheckboxValueSet) THEN
622
623 -- Checkbox input
624
625
626 P_InputObjectType := C_CheckboxInputObject;
627
628 ELSE
629
630 -- Bug Fix 1790945, added AP_WEB_CUST_DFLEX_PKG.CustomPopulatePoplist
631 -- and if condition below
632 AP_WEB_CUST_DFLEX_PKG.CustomPopulatePoplist(
633 P_ContextValue,
634 P_Segments.segment_name(P_SegIndex), V_NumOfTableElem,
635 V_PoplistArray);
636
637 IF V_NumOfTableElem = 0 THEN
638 -- Poplist input
639 V_DebugInfo := 'Generate poplist input';
640 GetIndepSegmentEnabledValues(V_ValueSetInfo, V_NumOfTableElem,
641 V_PoplistArray);
642 END IF;
643
644 IF V_NumOfTableElem <> 0 THEN
645
646 -- Poplist input
647
648 P_InputObjectType := C_SelectInputObject;
649
650 ELSE
651
652 -- Text input
653
654 P_InputObjectType := C_TextInputObject;
655
656 END IF;
657
658 END IF;
659
660 END IF;
661
662 END IF;
663 EXCEPTION
664 WHEN OTHERS THEN
665 BEGIN
666 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
667 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
668 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
669 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
670 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
671 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
672 END;
673
674 END GetSegmentType;
675
676
677
678 FUNCTION GetContextSensitiveOffset(P_Contexts IN FND_DFLEX.CONTEXTS_DR,
679 P_Prompt IN VARCHAR2)
680 RETURN NUMBER
681 IS
682 I NUMBER;
683 BEGIN
684
685 -- For each ENABLED context, not including the global data elements
686 FOR I IN 1..P_Contexts.ncontexts LOOP
687 IF (P_Contexts.context_code(I) = P_Prompt) AND
688 (P_Contexts.global_context <> I) AND
689 (P_Contexts.is_enabled(I)) THEN
690 RETURN I;
691 END IF;
692
693 END LOOP;
694
695 RETURN -1;
696 END GetContextSensitiveOffset;
697
698
699
700 -------------------------------------------------------------------------------
701 FUNCTION GenSegmentDefaultValue(SegmentDefaultValue_A IN AP_WEB_PARENT_PKG.MedString_Array,
702 P_InputObjectPrefix IN VARCHAR2,
703 P_NumOfFlexField IN NUMBER)
704 -------------------------------------------------------------------------------
705 RETURN VARCHAR2
706 IS
707 I NUMBER;
708 RetString VARCHAR2(2000);
709
710 V_CurrentCallingSequence VARCHAR2(100);
711 V_DebugInfo VARCHAR2(100);
712 BEGIN
713
714 V_CurrentCallingSequence := 'GenSegmentDefaultValue';
715
716 RetString := 'var ' || P_InputObjectPrefix || 'DefaultValue = new Array(' || TO_CHAR(P_NumOfFlexField+1) || ');';
717
718 FOR I IN 1..P_NumOfFlexField LOOP
719
720 RetString := RetString ||
721 P_InputObjectPrefix || 'DefaultValue[' || TO_CHAR(I) || ']=\"' || SegmentDefaultValue_A(I) || '\";';
722 END LOOP;
723
724 RETURN RetString;
725
726 EXCEPTION
727 WHEN OTHERS THEN
728 BEGIN
729 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
730 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
731 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
732 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
733 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
734 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
735 END;
736
737 END GenSegmentDefaultValue;
738
739
740
741 ------------------------------------------------------------------------
742 FUNCTION GetMaxNumSegmentsUsed (p_user_id IN NUMBER DEFAULT NULL) -- added argument for 2242176
743 RETURN NUMBER
744 -------------------------------------------------------------------------------
745 IS
746 V_DFlexField FND_DFLEX.DFLEX_R;
747 V_DFlexInfo FND_DFLEX.DFLEX_DR;
748 V_Contexts FND_DFLEX.CONTEXTS_DR;
749 V_Context FND_DFLEX.CONTEXT_R;
750 V_Segments FND_DFLEX.SEGMENTS_DR;
751 V_IsFlexFieldUsed BOOLEAN;
752
753 V_CurrentCallingSequence VARCHAR2(100);
754 V_DebugInfo VARCHAR2(100);
755
756 V_NumOfGlobalSegments NUMBER ;
757 V_NumOfContextSegments NUMBER;
758 V_NumOfMaxContextSegments NUMBER := 0;
759
760 BEGIN
761 -- Get descriptive flexfield info
762 V_DebugInfo := 'Get descriptive flexfield info';
763 GetExpenseLineDFlexInfo(p_user_id,
764 V_DFlexField,
765 V_DFlexInfo,
766 V_Contexts,
767 V_IsFlexFieldUsed);
768 IF V_IsFlexFieldUsed THEN
769 -- Get information about the global context
770 V_Context.flexfield := V_DFlexField;
771 V_Context.context_code := V_Contexts.context_code(V_Contexts.global_context);
772 FND_DFLEX.Get_Segments(V_Context, V_Segments, TRUE);
773 V_NumOfGlobalSegments := GetNumOfEnabledSegments(V_Segments);
774
775 V_NumOfMaxContextSegments := 0;
776 -- For each ENABLED context, not including the global data elements
777 FOR I IN 1..V_Contexts.ncontexts LOOP
778
779 IF (V_Contexts.global_context <> I) AND (V_Contexts.is_enabled(I)) THEN
780
781 -- Get segment information
782 V_Context.flexfield := V_DFlexField;
783 V_Context.context_code := V_Contexts.context_code(I);
784 FND_DFLEX.Get_Segments(V_Context, V_Segments, TRUE);
785 V_NumOfContextSegments := GetNumOfEnabledSegments(V_Segments);
786 IF (V_NumOfContextSegments > V_NumOfMaxContextSegments) THEN
787 V_NumOfMaxContextSegments := V_NumOfContextSegments;
788 END IF;
789
790 END IF;
791 END LOOP;
792
793 RETURN MINIMUM(V_NumOfGlobalSegments + V_NumOfMaxContextSegments, C_AbsoluteMaxFlexField);
794
795 ELSE
796
797 RETURN 0;
798
799 END IF;
800 END GetMaxNumSegmentsUsed;
801
802 PROCEDURE IsSessionTaxEnabled(P_Result OUT NOCOPY VARCHAR2,
803 P_User_Id IN NUMBER DEFAULT NULL)
804
805 -- Sets P_Result = 'Y' if tax is enabled otherwise sets P_Result = 'N'
806 IS
807 BEGIN
808
809 P_Result := AP_WEB_UTILITIES_PKG.VALUE_SPECIFIC(
810 p_name => 'AP_WEB_TAX_ENABLE',
811 p_user_id => P_User_Id,
812 p_resp_id => null,
813 p_apps_id => null);
814 P_Result := NVL(P_Result, 'N');
815
816 END IsSessionTaxEnabled;
817
818 ------------------------------------------------------------------------
819 FUNCTION GetMaxNumPseudoSegmentsUsed(
820 P_IsSessionProjectEnabled IN VARCHAR2)
821 RETURN NUMBER
822 -------------------------------------------------------------------------------
823 IS
824 V_NumPseudoFlexField INTEGER := 0;
825 BEGIN
826
827
828 IF P_IsSessionProjectEnabled = C_Yes THEN
829 V_NumPseudoFlexField := V_NumPseudoFlexField + C_NumProjectPseudoFlexField;
830 END IF;
831
832 RETURN V_NumPseudoFlexField;
833 END GetMaxNumPseudoSegmentsUsed;
834
835 ------------------------------------------------------------------------
836 FUNCTION IsFlexFieldUsed(
837 P_CustomField IN CustomFieldRec)
838 RETURN BOOLEAN
839 ------------------------------------------------------------------------
840 IS
841 BEGIN
842 RETURN (P_CustomField.column_mapping IS NOT NULL);
843 END IsFlexFieldUsed;
844
845 ------------------------------------------------------------------------
846 FUNCTION IsFlexFieldPopulated(
847 P_CustomField IN CustomFieldRec)
848 RETURN BOOLEAN
849 ------------------------------------------------------------------------
850 IS
851 BEGIN
852 RETURN (P_CustomField.value IS NOT NULL);
853 END IsFlexFieldPopulated;
854
855 ------------------------------------------------------------------------
856 PROCEDURE ClearCustomFieldRec(
857 P_CustomField OUT NOCOPY CustomFieldRec)
858 ------------------------------------------------------------------------
859 IS
860 BEGIN
861 P_CustomField.prompt := NULL;
862 P_CustomField.value := NULL;
863 P_CustomField.column_mapping := NULL;
864 P_CustomField.displayed_flag := NULL;
865 P_CustomField.required_flag := NULL;
866 P_CustomField.display_size := NULL;
867 P_CustomField.value_set := NULL;
868 END ClearCustomFieldRec;
869
870 ------------------------------------------------------------------------
871 FUNCTION IsCustomFieldPopulated(P_ReceiptIndex IN NUMBER,
872 Custom1_Array IN CustomFields_A,
873 Custom2_Array IN CustomFields_A,
874 Custom3_Array IN CustomFields_A,
875 Custom4_Array IN CustomFields_A,
876 Custom5_Array IN CustomFields_A,
877 Custom6_Array IN CustomFields_A,
878 Custom7_Array IN CustomFields_A,
879 Custom8_Array IN CustomFields_A,
880 Custom9_Array IN CustomFields_A,
881 Custom10_Array IN CustomFields_A,
882 Custom11_Array IN CustomFields_A,
883 Custom12_Array IN CustomFields_A,
884 Custom13_Array IN CustomFields_A,
885 Custom14_Array IN CustomFields_A,
886 Custom15_Array IN CustomFields_A)
887 RETURN BOOLEAN
888 ------------------------------------------------------------------------
889 IS
890 BEGIN
891 RETURN IsFlexFieldPopulated(Custom1_Array(P_ReceiptIndex)) OR
892 IsFlexFieldPopulated(Custom2_Array(P_ReceiptIndex)) OR
893 IsFlexFieldPopulated(Custom3_Array(P_ReceiptIndex)) OR
894 IsFlexFieldPopulated(Custom4_Array(P_ReceiptIndex)) OR
895 IsFlexFieldPopulated(Custom5_Array(P_ReceiptIndex)) OR
896 IsFlexFieldPopulated(Custom6_Array(P_ReceiptIndex)) OR
897 IsFlexFieldPopulated(Custom7_Array(P_ReceiptIndex)) OR
898 IsFlexFieldPopulated(Custom8_Array(P_ReceiptIndex)) OR
899 IsFlexFieldPopulated(Custom9_Array(P_ReceiptIndex)) OR
900 IsFlexFieldPopulated(Custom10_Array(P_ReceiptIndex)) OR
901 IsFlexFieldPopulated(Custom11_Array(P_ReceiptIndex)) OR
902 IsFlexFieldPopulated(Custom12_Array(P_ReceiptIndex)) OR
903 IsFlexFieldPopulated(Custom13_Array(P_ReceiptIndex)) OR
904 IsFlexFieldPopulated(Custom14_Array(P_ReceiptIndex)) OR
905 IsFlexFieldPopulated(Custom15_Array(P_ReceiptIndex));
906 END IsCustomFieldPopulated;
907
908 ------------------------------------------------------------------------
909 PROCEDURE PopulateCustomDefaultValues(
910 P_User_Id IN NUMBER,
911 P_ExpReportHeaderInfo IN ExpReportHeaderRec,
912 ExpReportLinesInfo IN OUT NOCOPY ExpReportLines_A,
913 P_ReceiptCount IN NUMBER,
914 Custom1_Array IN OUT NOCOPY CustomFields_A,
915 Custom2_Array IN OUT NOCOPY CustomFields_A,
916 Custom3_Array IN OUT NOCOPY CustomFields_A,
917 Custom4_Array IN OUT NOCOPY CustomFields_A,
918 Custom5_Array IN OUT NOCOPY CustomFields_A,
919 Custom6_Array IN OUT NOCOPY CustomFields_A,
920 Custom7_Array IN OUT NOCOPY CustomFields_A,
921 Custom8_Array IN OUT NOCOPY CustomFields_A,
922 Custom9_Array IN OUT NOCOPY CustomFields_A,
923 Custom10_Array IN OUT NOCOPY CustomFields_A,
924 Custom11_Array IN OUT NOCOPY CustomFields_A,
925 Custom12_Array IN OUT NOCOPY CustomFields_A,
926 Custom13_Array IN OUT NOCOPY CustomFields_A,
927 Custom14_Array IN OUT NOCOPY CustomFields_A,
928 Custom15_Array IN OUT NOCOPY CustomFields_A,
929 P_NumMaxFlexField IN NUMBER,
930 P_DataDefaultedUpdateable IN OUT NOCOPY BOOLEAN)
931 ------------------------------------------------------------------------
932 IS
933 CustomForOneReceipt CustomFields_A;
934 V_ContextIndex NUMBER;
935 I NUMBER;
936 CustomIndex NUMBER;
937 V_SegMapIndex NUMBER;
938 V_SegIndex NUMBER;
939 V_NumOfEnabledContSeg NUMBER;
940 V_NumOfGlobalFlexField NUMBER;
941 V_SegDefaultValue VARCHAR2(240);
942 Map_Array AP_WEB_PARENT_PKG.Number_Array;
943 V_ContextValue VARCHAR2(100);
944
945 V_DFlexField FND_DFLEX.DFLEX_R;
946 V_DFlexInfo FND_DFLEX.DFLEX_DR;
947 V_Contexts FND_DFLEX.CONTEXTS_DR;
948 V_Context FND_DFLEX.CONTEXT_R;
949 V_Segments FND_DFLEX.SEGMENTS_DR;
950 V_IsFlexFieldUsed BOOLEAN;
951
952 V_ValueSetInfo FND_VSET.VALUESET_R;
953 V_ValueSetFormat FND_VSET.VALUESET_DR;
954
955 V_CurrentCallingSequence VARCHAR2(100) := 'PopulateCustomDefaultValues';
956 V_DebugInfo VARCHAR2(100);
957 TEST EXCEPTION;
958
959 b varchar2(100);
960 BEGIN
961
962 -- Initialize
963 FOR I IN 1..15 LOOP
964 CustomForOneReceipt(I).value := NULL;
965 END LOOP;
966 P_DataDefaultedUpdateable := FALSE;
967
968 -- Don't do anything if flexfields are not used
969 IF P_NumMaxFlexField > 0 THEN
970
971 -- Get flexfield info and contexts for the flexfield
972 V_DebugInfo := 'Get descriptive flexfield info and contexts for the flexfield';
973 GetExpenseLineDFlexInfo(P_User_Id,
974 V_DFlexField,
975 V_DFlexInfo,
976 V_Contexts,
977 V_IsFlexFieldUsed);
978
979 -- Get information about the global context
980 V_DebugInfo := 'Get information about the global context';
981 V_Context.flexfield := V_DFlexField;
982 V_Context.context_code := V_Contexts.context_code(V_Contexts.global_context);
983 FND_DFLEX.Get_Segments(V_Context, V_Segments, TRUE);
984 V_NumOfGlobalFlexField := GetNumOfEnabledSegments(V_Segments);
985
986 -- Map segments so that only enabled ones are sorted
987 GetEnabledSegments(V_Segments, Map_Array, V_NumOfEnabledContSeg);
988
989 -- Fill in the global data element info which will be used by each receipt
990 -- These values will be copied into each receipt
991 CustomIndex := 1;
992 FOR V_SegMapIndex IN 1..MINIMUM(V_NumOfEnabledContSeg, C_AbsoluteMaxFlexField) LOOP
993
994 -- Map segments here
995 V_SegIndex := Map_Array(V_SegMapIndex);
996
997 -- Get segment default
998 CustomForOneReceipt(CustomIndex).value :=
999 GetSegmentDefault(V_Context.context_code,
1000 V_Segments, V_SegIndex);
1001
1002 -- Determine whether a value has been defaulted and can be overwritten
1003 -- by the user. Getting the value set can be expensive, so only do that
1004 -- when we know that there are still no defaulted/modifiable values.
1005 IF CustomForOneReceipt(CustomIndex).value IS NOT NULL AND
1006 NOT P_DataDefaultedUpdateable THEN
1007
1008 -- Get value set
1009 V_DebugInfo := 'Get value set';
1010 GetValueSet(V_Segments.value_set(V_SegIndex),
1011 V_ValueSetInfo, V_ValueSetFormat);
1012
1013 -- Check if segment is enabled, but not displayed
1014 V_DebugInfo := 'Check if segment is enabled, but not displayed';
1015 IF IsSegmentRendered(V_Segments, V_SegIndex, V_ValueSetInfo) THEN
1016 P_DataDefaultedUpdateable := TRUE;
1017 END IF;
1018
1019 END IF;
1020
1021 CustomIndex := CustomIndex + 1;
1022
1023 END LOOP;
1024
1025 -- Get expense type prompts and codes
1026
1027 -- For each receipt, we will get the context value and fill in the default context
1028 -- values appropriately.
1029 V_DebugInfo := 'Fill in receipt custom default values info';
1030 FOR I IN 1..P_ReceiptCount LOOP
1031
1032 IF ExpReportLinesInfo(I).parameter_id IS NOT NULL THEN
1033
1034 CustomIndex := V_NumOfGlobalFlexField + 1;
1035 -- This should already be set
1036 -- PopulateExpTypeInLineRec(ExpReportLinesInfo(I));
1037
1038 V_DebugInfo := 'GetDFlexContextIndex "'
1039 || ExpReportLinesInfo(I).expense_type || '"';
1040 GetDFlexContextIndex(ExpReportLinesInfo(I).expense_type,
1041 V_Contexts,
1042 V_ContextIndex);
1043 V_DebugInfo := 'ContextIndex = ' || V_ContextIndex ;
1044
1045 -- Check whether there are context sensitive fields for the expense type
1046 IF (V_ContextIndex IS NOT NULL) THEN
1047
1048 V_Context.context_code := V_Contexts.context_code(V_ContextIndex);
1049 V_DebugInfo := 'context_code = ' || V_Context.context_code ;
1050 FND_DFLEX.Get_Segments(V_Context, V_Segments, TRUE);
1051
1052 -- Map segments so that only enabled ones are sorted
1053 V_DebugInfo := 'Map segments so that only enabled ones are sorted';
1054 GetEnabledSegments(V_Segments, Map_Array, V_NumOfEnabledContSeg);
1055
1056 V_DebugInfo := 'Set context sensitive segments';
1057 FOR V_SegMapIndex IN 1..MINIMUM(V_NumOfEnabledContSeg, C_AbsoluteMaxFlexField) LOOP
1058
1059 -- Map segments here
1060 V_SegIndex := Map_Array(V_SegMapIndex);
1061
1062 -- Get segment default
1063 CustomForOneReceipt(CustomIndex).value :=
1064 GetSegmentDefault(V_Context.context_code, V_Segments, V_SegIndex);
1065
1066 -- Determine whether a value has been defaulted and can be
1067 -- overwritten by the user. Getting the value set can be
1068 -- expensive, so only do that when we know that there are still
1069 -- no defaulted/modifiable values.
1070 IF CustomForOneReceipt(CustomIndex).value IS NOT NULL AND
1071 NOT P_DataDefaultedUpdateable THEN
1072
1073 -- Get value set
1074 V_DebugInfo := 'Get value set';
1075 GetValueSet(V_Segments.value_set(V_SegIndex),
1076 V_ValueSetInfo, V_ValueSetFormat);
1077
1078 -- Check if segment is enabled, but not displayed
1079 V_DebugInfo := 'Check if segment is enabled, but not displayed';
1080 IF IsSegmentRendered(V_Segments, V_SegIndex, V_ValueSetInfo) THEN
1081 P_DataDefaultedUpdateable := TRUE;
1082 END IF;
1083
1084 END IF;
1085
1086 CustomIndex := CustomIndex + 1;
1087
1088 END LOOP;
1089
1090 END IF;
1091
1092 V_DebugInfo := 'Clear out nocopy unused segments';
1093 FOR V_SegIndex IN CustomIndex..C_AbsoluteMaxFlexField LOOP
1094
1095 -- Get segment default
1096 CustomForOneReceipt(V_SegIndex).value := NULL;
1097
1098 END LOOP;
1099
1100 -- Copy CustomForOneReceipt contents into the customN_arrays
1101 PropogateReceiptCustFldsInfo(CustomForOneReceipt,
1102 I,
1103 Custom1_Array,
1104 Custom2_Array,
1105 Custom3_Array,
1106 Custom4_Array,
1107 Custom5_Array,
1108 Custom6_Array,
1109 Custom7_Array,
1110 Custom8_Array,
1111 Custom9_Array,
1112 Custom10_Array,
1113 Custom11_Array,
1114 Custom12_Array,
1115 Custom13_Array,
1116 Custom14_Array,
1117 Custom15_Array);
1118
1119 END IF;
1120 END LOOP;
1121 END IF;
1122
1123 EXCEPTION
1124 WHEN OTHERS THEN
1125 BEGIN
1126 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1127 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1128 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
1129 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
1130 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
1131 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1132 END;
1133
1134 END PopulateCustomDefaultValues;
1135
1136 ------------------------------------------------------------------------
1137 PROCEDURE PopulatePseudoDefaultValues(
1138 P_ExpReportHeaderInfo IN ExpReportHeaderRec,
1139 ExpReportLinesInfo IN OUT NOCOPY ExpReportLines_A,
1140 P_ReceiptCount IN NUMBER,
1141 P_DataDefaultedUpdateable IN OUT NOCOPY BOOLEAN)
1142 ------------------------------------------------------------------------
1143 IS
1144
1145 V_DefaultTaxCodeUpdateable VARCHAR2(1);
1146 V_DefaultTaxCode ZX_WEBEXP_CLASSIFICATIONS_V.LOOKUP_CODE%TYPE;--bug#14798565
1147 V_ValueSetInfo FND_VSET.VALUESET_R;
1148 V_ValueSetFormat FND_VSET.VALUESET_DR;
1149
1150 V_CurrentCallingSequence VARCHAR2(100) := 'PopulatePseudoDefaultValues';
1151 V_DebugInfo VARCHAR2(100);
1152 l_OrgId ap_expense_report_headers_all.org_id%TYPE;
1153
1154 BEGIN
1155
1156 P_DataDefaultedUpdateable := FALSE;
1157
1158 --Bug#7172212 - vat_code field not being populated for Spread-Sheet Import.
1159 l_OrgId := nvl(TO_NUMBER(rtrim(substrb(USERENV('CLIENT_INFO'), 1, 10))),-99);
1160
1161 AP_WEB_UTILITIES_PKG.logProcedure('AP_WEB_DFLEX_PKG','Org_id used to default the tax codes'||To_Char(l_OrgId));
1162
1163 FOR I IN 1..P_ReceiptCount LOOP
1164
1165 /* Bug 2844544: Initializing the variables before calling the
1166 function to retrieve the tax values. */
1167 V_DefaultTaxCodeUpdateable := NULL;
1168 V_DefaultTaxCode := NULL;
1169
1170 GetTaxPseudoSegmentDefaults(ExpReportLinesInfo(I).parameter_id,
1171 V_DefaultTaxCodeUpdateable,
1172 V_DefaultTaxCode,
1173 l_OrgId);
1174
1175 -- Set default and mark whether it is defaulted and modifiable
1176
1177 P_DataDefaultedUpdateable := TRUE;
1178
1179 -- vat code
1180 ExpReportLinesInfo(I).tax_code := V_DefaultTaxCode;
1181 IF V_DefaultTaxCode IS NOT NULL AND V_DefaultTaxCodeUpdateable = C_Yes THEN
1182 P_DataDefaultedUpdateable := TRUE;
1183 END IF;
1184
1185 END LOOP;
1186
1187 EXCEPTION
1188 WHEN OTHERS THEN
1189 BEGIN
1190 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1191 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1192 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', V_CurrentCallingSequence);
1193 FND_MESSAGE.SET_TOKEN('PARAMETERS','');
1194 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',V_DebugInfo);
1195 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1196 END;
1197
1198 END PopulatePseudoDefaultValues;
1199
1200 -----------------------------------------------------------------------------
1201 FUNCTION IsCustomFieldsFeatureUsed
1202 RETURN BOOLEAN
1203 -----------------------------------------------------------------------------
1204 IS
1205 l_dflex_name VARCHAR2(30) := NULL;
1206 BEGIN
1207
1208 FND_PROFILE.GET('AP_WEB_DESC_FLEX_NAME', l_dflex_name);
1209
1210 RETURN (l_dflex_name IS NOT NULL);
1211
1212 END IsCustomFieldsFeatureUsed;
1213
1214 -----------------------------------------------------------------------------
1215 PROCEDURE GetExpenseLineDFlexInfo(p_user_id IN NUMBER,
1216 p_flexfield IN OUT NOCOPY FND_DFLEX.DFLEX_R,
1217 p_flexinfo IN OUT NOCOPY FND_DFLEX.DFLEX_DR,
1218 p_contexts IN OUT NOCOPY FND_DFLEX.CONTEXTS_DR,
1219 p_is_custom_fields_feat_used IN OUT NOCOPY BOOLEAN)
1220 -----------------------------------------------------------------------------
1221 IS
1222 l_debug_info VARCHAR2(2000);
1223 l_curr_calling_sequence VARCHAR2(200) := 'GetExpenseLineDFlexInfo';
1224 l_is_dflex_enabled VARCHAR2(1) := NULL;
1225 BEGIN
1226 l_debug_info := 'Get profile option';
1227 l_is_dflex_enabled := AP_WEB_UTILITIES_PKG.VALUE_SPECIFIC(
1228 p_name => 'AP_WEB_DESC_FLEX_NAME',
1229 p_user_id => p_user_id,
1230 p_resp_id => null,
1231 p_apps_id => null);
1232
1233 -- is web descriptive flexfields enabled
1234 -- Bug 3985122 Y-Lines Only, B - Both Header and Lines
1235 -- p_is_custom_fields_feat_used := (NVL(l_is_dflex_enabled, 'N') = 'Y');
1236 p_is_custom_fields_feat_used := ((NVL(l_is_dflex_enabled, 'N') = 'Y') OR (NVL(l_is_dflex_enabled, 'N') = 'B'));
1237
1238 IF p_is_custom_fields_feat_used THEN
1239
1240 l_debug_info := 'Get flexfield info';
1241 FND_DFLEX.Get_Flexfield('SQLAP',
1242 C_LinesDescFlexname,
1243 p_flexfield,
1244 p_flexinfo);
1245
1246 l_debug_info := 'Get context info';
1247 FND_DFLEX.Get_Contexts(p_flexfield,
1248 p_contexts);
1249
1250 END IF;
1251
1252 EXCEPTION
1253 WHEN OTHERS THEN
1254 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1255 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1256 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1257 l_curr_calling_sequence);
1258 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1259 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1260 END GetExpenseLineDFlexInfo;
1261
1262 -----------------------------------------------------------------------------
1263 PROCEDURE GetDFlexContextSegments(p_flexfield IN FND_DFLEX.DFLEX_R,
1264 p_contexts IN FND_DFLEX.CONTEXTS_DR,
1265 p_context_index IN BINARY_INTEGER,
1266 p_segments IN OUT NOCOPY FND_DFLEX.SEGMENTS_DR)
1267 -----------------------------------------------------------------------------
1268 IS
1269 l_context FND_DFLEX.CONTEXT_R;
1270 l_debug_info VARCHAR2(2000);
1271 l_curr_calling_sequence VARCHAR2(200) := 'GetDFlexContextSegments';
1272 BEGIN
1273
1274 l_context.flexfield := p_flexfield;
1275 l_context.context_code := p_contexts.context_code(p_context_index);
1276
1277 FND_DFLEX.Get_Segments(l_context,
1278 p_segments, TRUE);
1279
1280 EXCEPTION
1281 WHEN OTHERS THEN
1282 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1283 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1284 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1285 l_curr_calling_sequence);
1286 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1287 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1288 END GetDFlexContextSegments;
1289
1290
1291 -----------------------------------------------------------------------------
1292 PROCEDURE GetDFlexContextIndex(p_context_value IN VARCHAR2,
1293 p_dflex_contexts IN FND_DFLEX.CONTEXTS_DR,
1294 p_index IN OUT NOCOPY BINARY_INTEGER) IS
1295 -----------------------------------------------------------------------------
1296 i BINARY_INTEGER := NULL;
1297 l_debug_info VARCHAR2(2000);
1298 l_curr_calling_sequence VARCHAR2(200) := 'GetDFlexContextIndex';
1299 BEGIN
1300
1301 FOR i IN 1..p_dflex_contexts.ncontexts LOOP
1302
1303 IF (p_context_value = p_dflex_contexts.context_code(i)) THEN
1304
1305 p_index := i;
1306 RETURN;
1307
1308 END IF;
1309
1310 END LOOP;
1311
1312 p_index := NULL;
1313
1314 EXCEPTION
1315 WHEN OTHERS THEN
1316 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1317 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1318 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1319 l_curr_calling_sequence);
1320 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1321 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1322 END GetDFlexContextIndex;
1323
1324 -----------------------------------------------------------------------------
1325 PROCEDURE GetIndexRefOrderedArray(p_sequence_array IN FND_DFLEX.SEQUENCE_A,
1326 p_nelements IN NUMBER,
1327 p_index_ref_ordered_array OUT NOCOPY BINARY_INTEGER_A) IS
1328 -----------------------------------------------------------------------------
1329 l_sequence_a FND_DFLEX.SEQUENCE_A := p_sequence_array;
1330 l_lowest_value NUMBER := NULL;
1331 l_lowest_index BINARY_INTEGER := NULL;
1332 i BINARY_INTEGER := NULL;
1333 j BINARY_INTEGER := NULL;
1334 l_debug_info VARCHAR2(2000);
1335 l_curr_calling_sequence VARCHAR2(200) := 'GetIndexRefOrderedArray';
1336 BEGIN
1337
1338 FOR i in 1..p_nelements LOOP
1339 FOR j in 1..p_nelements LOOP
1340
1341 IF ((l_lowest_value IS NULL) OR (l_lowest_value > l_sequence_a(j))) THEN
1342 l_lowest_value := l_sequence_a(j);
1343 l_lowest_index := j;
1344 END IF;
1345
1346 END LOOP;
1347
1348 p_index_ref_ordered_array(i) := l_lowest_index;
1349 l_sequence_a(l_lowest_index) := NULL;
1350 l_lowest_value := NULL;
1351 l_lowest_index := NULL;
1352 END LOOP;
1353
1354 EXCEPTION
1355 WHEN OTHERS THEN
1356 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1357 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1358 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1359 l_curr_calling_sequence);
1360 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1361 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1362 END GetIndexRefOrderedArray;
1363
1364 -----------------------------------------------------------------------------
1365 FUNCTION GetNumOfEnabledSegments(P_Segments IN FND_DFLEX.SEGMENTS_DR) RETURN NUMBER
1366 -----------------------------------------------------------------------------
1367 IS
1368
1369 I NUMBER;
1370 V_NumOfEnabledSegments NUMBER;
1371 l_debug_info VARCHAR2(2000);
1372 l_curr_calling_sequence VARCHAR2(200) := 'GetNumOfEnabledSegments';
1373 BEGIN
1374
1375 V_NumOfEnabledSegments := 0;
1376
1377 FOR I IN 1..P_Segments.nsegments LOOP
1378 IF P_Segments.is_enabled(I) THEN
1379 V_NumOfEnabledSegments := V_NumOfEnabledSegments + 1;
1380 END IF;
1381 END LOOP;
1382
1383 RETURN V_NumOfEnabledSegments;
1384
1385 EXCEPTION
1386 WHEN OTHERS THEN
1387 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1388 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1389 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1390 l_curr_calling_sequence);
1391 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1392 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1393 END GetNumOfEnabledSegments;
1394
1395 ---------------------------------------------------------------------------
1396 PROCEDURE GetReceiptCustomFields(
1397 p_receipt_custom_fields_array IN OUT NOCOPY CustomFields_A,
1398 p_receipt_index IN BINARY_INTEGER,
1399 p_custom1_array IN CustomFields_A,
1400 p_custom2_array IN CustomFields_A,
1401 p_custom3_array IN CustomFields_A,
1402 p_custom4_array IN CustomFields_A,
1403 p_custom5_array IN CustomFields_A,
1404 p_custom6_array IN CustomFields_A,
1405 p_custom7_array IN CustomFields_A,
1406 p_custom8_array IN CustomFields_A,
1407 p_custom9_array IN CustomFields_A,
1408 p_custom10_array IN CustomFields_A,
1409 p_custom11_array IN CustomFields_A,
1410 p_custom12_array IN CustomFields_A,
1411 p_custom13_array IN CustomFields_A,
1412 p_custom14_array IN CustomFields_A,
1413 p_custom15_array IN CustomFields_A)
1414 ---------------------------------------------------------------------------
1415 IS
1416 l_debug_info VARCHAR2(2000);
1417 l_curr_calling_sequence VARCHAR2(200) := 'GetReceiptCustomFields';
1418 BEGIN
1419
1420 BEGIN
1421 p_receipt_custom_fields_array(1) := p_custom1_array(p_receipt_index);
1422 EXCEPTION
1423 WHEN NO_DATA_FOUND THEN
1424 null;
1425 END;
1426 BEGIN
1427 p_receipt_custom_fields_array(2) := p_custom2_array(p_receipt_index);
1428 EXCEPTION
1429 WHEN NO_DATA_FOUND THEN
1430 null;
1431 END;
1432 BEGIN
1433 p_receipt_custom_fields_array(3) := p_custom3_array(p_receipt_index);
1434 EXCEPTION
1435 WHEN NO_DATA_FOUND THEN
1436 null;
1437 END;
1438 BEGIN
1439 p_receipt_custom_fields_array(4) := p_custom4_array(p_receipt_index);
1440 EXCEPTION
1441 WHEN NO_DATA_FOUND THEN
1442 null;
1443 END;
1444 BEGIN
1445 p_receipt_custom_fields_array(5) := p_custom5_array(p_receipt_index);
1446 EXCEPTION
1447 WHEN NO_DATA_FOUND THEN
1448 null;
1449 END;
1450 BEGIN
1451 p_receipt_custom_fields_array(6) := p_custom6_array(p_receipt_index);
1452 EXCEPTION
1453 WHEN NO_DATA_FOUND THEN
1454 null;
1455 END;
1456 BEGIN
1457 p_receipt_custom_fields_array(7) := p_custom7_array(p_receipt_index);
1458 EXCEPTION
1459 WHEN NO_DATA_FOUND THEN
1460 null;
1461 END;
1462 BEGIN
1463 p_receipt_custom_fields_array(8) := p_custom8_array(p_receipt_index);
1464 EXCEPTION
1465 WHEN NO_DATA_FOUND THEN
1466 null;
1467 END;
1468 BEGIN
1469 p_receipt_custom_fields_array(9) := p_custom9_array(p_receipt_index);
1470 EXCEPTION
1471 WHEN NO_DATA_FOUND THEN
1472 null;
1473 END;
1474 BEGIN
1475 p_receipt_custom_fields_array(10) := p_custom10_array(p_receipt_index);
1476 EXCEPTION
1477 WHEN NO_DATA_FOUND THEN
1478 null;
1479 END;
1480 BEGIN
1481 p_receipt_custom_fields_array(11) := p_custom11_array(p_receipt_index);
1482 EXCEPTION
1483 WHEN NO_DATA_FOUND THEN
1484 null;
1485 END;
1486 BEGIN
1487 p_receipt_custom_fields_array(12) := p_custom12_array(p_receipt_index);
1488 EXCEPTION
1489 WHEN NO_DATA_FOUND THEN
1490 null;
1491 END;
1492 BEGIN
1493 p_receipt_custom_fields_array(13) := p_custom13_array(p_receipt_index);
1494 EXCEPTION
1495 WHEN NO_DATA_FOUND THEN
1496 null;
1497 END;
1498 BEGIN
1499 p_receipt_custom_fields_array(14) := p_custom14_array(p_receipt_index);
1500 EXCEPTION
1501 WHEN NO_DATA_FOUND THEN
1502 null;
1503 END;
1504 BEGIN
1505 p_receipt_custom_fields_array(15) := p_custom15_array(p_receipt_index);
1506 EXCEPTION
1507 WHEN NO_DATA_FOUND THEN
1508 null;
1509 END;
1510
1511 EXCEPTION
1512 WHEN OTHERS THEN
1513 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1514 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1515 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1516 l_curr_calling_sequence);
1517 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1518 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1519 END GetReceiptCustomFields;
1520
1521 ---------------------------------------------------------------------------
1522 PROCEDURE PropogateReceiptCustFldsInfo(
1523 p_receipt_custom_fields_array IN CustomFields_A,
1524 p_receipt_index IN BINARY_INTEGER,
1525 p_custom1_array IN OUT NOCOPY CustomFields_A,
1526 p_custom2_array IN OUT NOCOPY CustomFields_A,
1527 p_custom3_array IN OUT NOCOPY CustomFields_A,
1528 p_custom4_array IN OUT NOCOPY CustomFields_A,
1529 p_custom5_array IN OUT NOCOPY CustomFields_A,
1530 p_custom6_array IN OUT NOCOPY CustomFields_A,
1531 p_custom7_array IN OUT NOCOPY CustomFields_A,
1532 p_custom8_array IN OUT NOCOPY CustomFields_A,
1533 p_custom9_array IN OUT NOCOPY CustomFields_A,
1534 p_custom10_array IN OUT NOCOPY CustomFields_A,
1535 p_custom11_array IN OUT NOCOPY CustomFields_A,
1536 p_custom12_array IN OUT NOCOPY CustomFields_A,
1537 p_custom13_array IN OUT NOCOPY CustomFields_A,
1538 p_custom14_array IN OUT NOCOPY CustomFields_A,
1539 p_custom15_array IN OUT NOCOPY CustomFields_A)
1540 ---------------------------------------------------------------------------
1541 IS
1542 l_debug_info VARCHAR2(2000);
1543 l_curr_calling_sequence VARCHAR2(200) := 'PropogateReceiptCustFldsInfo';
1544 BEGIN
1545
1546 BEGIN
1547 p_custom1_array(p_receipt_index) := p_receipt_custom_fields_array(1);
1548 EXCEPTION
1549 WHEN NO_DATA_FOUND THEN
1550 null;
1551 END;
1552 BEGIN
1553 p_custom2_array(p_receipt_index) := p_receipt_custom_fields_array(2);
1554 EXCEPTION
1555 WHEN NO_DATA_FOUND THEN
1556 null;
1557 END;
1558 BEGIN
1559 p_custom3_array(p_receipt_index) := p_receipt_custom_fields_array(3);
1560 EXCEPTION
1561 WHEN NO_DATA_FOUND THEN
1562 null;
1563 END;
1564 BEGIN
1565 p_custom4_array(p_receipt_index) := p_receipt_custom_fields_array(4);
1566 EXCEPTION
1567 WHEN NO_DATA_FOUND THEN
1568 null;
1569 END;
1570 BEGIN
1571 p_custom5_array(p_receipt_index) := p_receipt_custom_fields_array(5);
1572 EXCEPTION
1573 WHEN NO_DATA_FOUND THEN
1574 null;
1575 END;
1576 BEGIN
1577 p_custom6_array(p_receipt_index) := p_receipt_custom_fields_array(6);
1578 EXCEPTION
1579 WHEN NO_DATA_FOUND THEN
1580 null;
1581 END;
1582 BEGIN
1583 p_custom7_array(p_receipt_index) := p_receipt_custom_fields_array(7);
1584 EXCEPTION
1585 WHEN NO_DATA_FOUND THEN
1586 null;
1587 END;
1588 BEGIN
1589 p_custom8_array(p_receipt_index) := p_receipt_custom_fields_array(8);
1590 EXCEPTION
1591 WHEN NO_DATA_FOUND THEN
1592 null;
1593 END;
1594 BEGIN
1595 p_custom9_array(p_receipt_index) := p_receipt_custom_fields_array(9);
1596 EXCEPTION
1597 WHEN NO_DATA_FOUND THEN
1598 null;
1599 END;
1600 BEGIN
1601 p_custom10_array(p_receipt_index) := p_receipt_custom_fields_array(10);
1602 EXCEPTION
1603 WHEN NO_DATA_FOUND THEN
1604 null;
1605 END;
1606 BEGIN
1607 p_custom11_array(p_receipt_index) := p_receipt_custom_fields_array(11);
1608 EXCEPTION
1609 WHEN NO_DATA_FOUND THEN
1610 null;
1611 END;
1612 BEGIN
1613 p_custom12_array(p_receipt_index) := p_receipt_custom_fields_array(12);
1614 EXCEPTION
1615 WHEN NO_DATA_FOUND THEN
1616 null;
1617 END;
1618 BEGIN
1619 p_custom13_array(p_receipt_index) := p_receipt_custom_fields_array(13);
1620 EXCEPTION
1621 WHEN NO_DATA_FOUND THEN
1622 null;
1623 END;
1624 BEGIN
1625 p_custom14_array(p_receipt_index) := p_receipt_custom_fields_array(14);
1626 EXCEPTION
1627 WHEN NO_DATA_FOUND THEN
1628 null;
1629 END;
1630 BEGIN
1631 p_custom15_array(p_receipt_index) := p_receipt_custom_fields_array(15);
1632 EXCEPTION
1633 WHEN NO_DATA_FOUND THEN
1634 null;
1635 END;
1636
1637 EXCEPTION
1638 WHEN OTHERS THEN
1639 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1640 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1641 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1642 l_curr_calling_sequence);
1643 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1644 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1645 END PropogateReceiptCustFldsInfo;
1646
1647 ---------------------------------------------------------------------------
1648 PROCEDURE AssocCustFieldPromptsToValues(
1649 p_dflex_segs IN FND_DFLEX.SEGMENTS_DR,
1650 p_starting_index IN BINARY_INTEGER,
1651 p_ending_index IN BINARY_INTEGER,
1652 p_custom_fields_array IN OUT NOCOPY CustomFields_A)
1653 ---------------------------------------------------------------------------
1654 IS
1655 l_index_ref_ordered_array BINARY_INTEGER_A;
1656 l_debug_info VARCHAR2(2000);
1657 cf_ind BINARY_INTEGER := NULL;
1658 next_seg BINARY_INTEGER := 1;
1659 l_curr_calling_sequence VARCHAR2(200) := 'AssocCustFieldPromptToValues';
1660 TEST EXCEPTION;
1661 BEGIN
1662
1663 FOR cf_ind IN p_starting_index..p_ending_index LOOP
1664
1665 FOR seg_ind IN next_seg..p_dflex_segs.nsegments LOOP
1666
1667 next_seg := next_seg + 1;
1668
1669 IF (p_dflex_segs.is_enabled(seg_ind)) THEN
1670
1671 p_custom_fields_array(cf_ind).prompt :=
1672 p_dflex_segs.segment_name(seg_ind);
1673 p_custom_fields_array(cf_ind).user_prompt :=
1674 p_dflex_segs.row_prompt(seg_ind);
1675 p_custom_fields_array(cf_ind).column_mapping :=
1676 p_dflex_segs.application_column_name(seg_ind);
1677
1678 IF (p_dflex_segs.is_displayed(seg_ind)) THEN
1679 p_custom_fields_array(cf_ind).displayed_flag := 'Y';
1680 ELSE
1681 p_custom_fields_array(cf_ind).displayed_flag := 'N';
1682 END IF;
1683
1684 IF (p_dflex_segs.is_required(seg_ind)) THEN
1685 p_custom_fields_array(cf_ind).required_flag := 'Y';
1686 ELSE
1687 p_custom_fields_array(cf_ind).required_flag := 'N';
1688 END IF;
1689
1690 p_custom_fields_array(cf_ind).display_size :=
1691 to_number(p_dflex_segs.display_size(seg_ind));
1692 p_custom_fields_array(cf_ind).value_set :=
1693 p_dflex_segs.value_set(seg_ind);
1694
1695 EXIT;
1696
1697 END IF;
1698 END LOOP;
1699
1700 END LOOP;
1701 EXCEPTION
1702 WHEN OTHERS THEN
1703 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1704 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1705 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1706 l_curr_calling_sequence);
1707 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1708 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1709 END AssocCustFieldPromptsToValues;
1710
1711 ---------------------------------------------------------------------------
1712 FUNCTION GetCustomFieldValue(p_prompt IN VARCHAR2,
1713 p_custom_fields_array IN CustomFields_A) RETURN VARCHAR2
1714 ---------------------------------------------------------------------------
1715 IS
1716 l_nfields BINARY_INTEGER := p_custom_fields_array.count;
1717 l_curr_calling_sequence VARCHAR2(200) := 'GetCustomFieldValue';
1718 l_debug_info VARCHAR2(2000);
1719 BEGIN
1720 l_debug_info := l_nfields;
1721 FOR i in 1..l_nfields LOOP
1722 IF (upper(p_custom_fields_array(i).prompt) = upper(p_prompt)) THEN
1723 return(p_custom_fields_array(i).value);
1724 END IF;
1725
1726 END LOOP;
1727
1728 EXCEPTION
1729 WHEN OTHERS THEN
1730 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1731 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1732 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1733 l_curr_calling_sequence);
1734 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1735 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1736 END GetCustomFieldValue;
1737
1738 ------------------------------------------------------------------------------
1739 PROCEDURE ProcessDFlexError(
1740 p_custom_fields_array IN CustomFields_A,
1741 p_num_of_global_fields IN BINARY_INTEGER,
1742 p_num_of_context_fields IN BINARY_INTEGER,
1743 p_error IN OUT NOCOPY AP_WEB_UTILITIES_PKG.expError,
1744 p_receipt_index IN BINARY_INTEGER DEFAULT NULL
1745 )
1746 ------------------------------------------------------------------------------
1747 IS
1748 l_error_seg NUMBER := FND_FLEX_DESCVAL.error_segment;
1749 l_debug_info VARCHAR2(2000);
1750 l_curr_calling_sequence VARCHAR2(2000) := 'ProcessDFlexError';
1751 V_MessageText VARCHAR2(2000);
1752
1753 BEGIN
1754
1755 IF (NOT FND_FLEX_DESCVAL.is_valid) THEN
1756
1757 IF (l_error_seg IS NOT NULL) THEN
1758
1759 IF (l_error_seg > (p_num_of_global_fields + 1)) THEN
1760 l_error_seg := l_error_seg - 1;
1761 END IF;
1762
1763
1764
1765 -- !!! Set message with segment num and error_messag
1766 V_MessageText := p_custom_fields_array(l_error_seg).user_prompt ||'-'|| FND_FLEX_DESCVAL.error_Message ;
1767
1768
1769 ELSE
1770
1771 V_MessageText := FND_FLEX_DESCVAL.error_message;
1772
1773
1774 END IF;
1775
1776 AP_WEB_UTILITIES_PKG.AddExpErrorNotEncoded(p_error,v_MessageText,AP_WEB_UTILITIES_PKG.C_ErrorMessageType,'FlexField', p_receipt_index,AP_WEB_UTILITIES_PKG.C_DFFMessageCategory);
1777
1778
1779
1780 END IF;
1781
1782 EXCEPTION
1783 WHEN OTHERS THEN
1784 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1785 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1786 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1787 l_curr_calling_sequence);
1788 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1789 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1790 END ProcessDFlexError;
1791
1792 ------------------------------------------------------------------------------
1793 PROCEDURE CoreValidateDFlexValues(
1794 p_dflex_name IN VARCHAR2,
1795 p_dflex_contexts IN FND_DFLEX.CONTEXTS_DR,
1796 p_context_index IN BINARY_INTEGER,
1797 p_custom_fields_array IN CustomFields_A,
1798 p_num_of_global_fields IN BINARY_INTEGER,
1799 p_num_of_context_fields IN BINARY_INTEGER,
1800 p_receipt_errors IN OUT NOCOPY AP_WEB_UTILITIES_PKG.Receipt_Error_Stack,
1801 p_receipt_index IN BINARY_INTEGER,
1802 p_error IN OUT NOCOPY AP_WEB_UTILITIES_PKG.expError )
1803 ------------------------------------------------------------------------------
1804 IS
1805 l_resp_appl_id NUMBER;
1806 l_resp_id NUMBER;
1807 l_debug_info VARCHAR2(2000);
1808 l_num_of_cust_fields BINARY_INTEGER := p_num_of_global_fields +
1809 nvl(p_num_of_context_fields, 0);
1810 l_curr_calling_sequence VARCHAR2(200) := 'CoreValidateDflexValues';
1811 TEST EXCEPTION;
1812
1813 BEGIN
1814
1815 IF ((p_num_of_context_fields IS NULL) or (p_num_of_context_fields=0)) THEN
1816
1817 FND_FLEX_DESCVAL.Set_Context_Value(null);
1818
1819 ELSE
1820 --------------------------------------------
1821 l_debug_info := 'Setting the Context Value';
1822 --------------------------------------------
1823 FND_FLEX_DESCVAL.Set_Context_Value(p_dflex_contexts.context_code(p_context_index));
1824 END IF;
1825
1826 FOR i in 1..l_num_of_cust_fields LOOP
1827
1828 -----------------------------------------------------------
1829 l_debug_info := 'Inside for loop for index ' || p_custom_fields_array(i).column_mapping || ' ' || p_custom_fields_array(i).value;
1830 -----------------------------------------------------------
1831
1832
1833 FND_FLEX_DESCVAL.Set_Column_Value(p_custom_fields_array(i).column_mapping,
1834 p_custom_fields_array(i).value);
1835
1836 END LOOP;
1837
1838 ------------------------------------------------
1839 l_debug_info := 'Calling FND Validate_Desccols';
1840 ------------------------------------------------
1841 IF (NOT FND_FLEX_DESCVAL.Validate_Desccols('SQLAP',
1842 p_dflex_name,
1843 'I',
1844 sysdate,
1845 TRUE,
1846 l_resp_appl_id,
1847 l_resp_id)) THEN
1848 -------------------------------------------
1849 l_debug_info := 'Calling ProcessDflexError';
1850 -------------------------------------------
1851
1852 ProcessDflexError(p_custom_fields_array,
1853 p_num_of_global_fields,
1854 p_num_of_context_fields,
1855 p_error,
1856 p_receipt_index );
1857
1858 END IF;
1859
1860
1861
1862 EXCEPTION
1863 WHEN OTHERS THEN
1864 FND_MESSAGE.SET_NAME('SQLAemacs P','AP_DEBUG');
1865 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1866 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1867 l_curr_calling_sequence);
1868 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1869 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1870 END CoreValidateDFlexValues;
1871
1872 ------------------------------------------------------------------------------
1873 PROCEDURE ValidateDFlexValues(
1874 p_exp_header_info IN ExpReportHeaderRec,
1875 p_exp_line_info IN ExpReportLineRec,
1876 p_custom_fields_array IN CustomFields_A,
1877 p_num_of_global_fields IN BINARY_INTEGER
1878 , p_num_of_context_fields IN BINARY_INTEGER,
1879 p_dflex_name IN VARCHAR2,
1880 p_dflex_contexts IN FND_DFLEX.CONTEXTS_DR,
1881 p_context_index IN BINARY_INTEGER,
1882 p_receipt_errors IN OUT NOCOPY AP_WEB_UTILITIES_PKG.Receipt_Error_Stack,
1883 p_receipt_index IN BINARY_INTEGER,
1884 p_error IN OUT NOCOPY AP_WEB_UTILITIES_PKG.expError)
1885 ------------------------------------------------------------------------------
1886 IS
1887 l_dummy_field_rec CustomFieldRec;
1888 l_result_message VARCHAR2(2000) := NULL;
1889 l_message_type VARCHAR2(2000) := NULL;
1890 l_num_of_cust_fields BINARY_INTEGER := p_num_of_global_fields +
1891 nvl(p_num_of_context_fields,0);
1892 l_debug_info VARCHAR2(2000);
1893 l_curr_calling_sequence VARCHAR2(200) := 'ValidateDflexValues';
1894 l_error AP_WEB_UTILITIES_PKG.expError;
1895
1896 BEGIN
1897
1898
1899 --------------------------------------------------
1900 l_debug_info := 'Calling CoreValidateDFlexValues';
1901 --------------------------------------------------
1902 CoreValidateDFlexValues(p_dflex_name,
1903 p_dflex_contexts,
1904 p_context_index,
1905 p_custom_fields_array,
1906 p_num_of_global_fields,
1907 p_num_of_context_fields,
1908 p_receipt_errors,
1909 p_receipt_index,
1910 l_error );
1911
1912 --------------------------------------------------
1913 l_debug_info := 'Calling CustomValidateDFlexValues';
1914 --------------------------------------------------
1915 AP_WEB_CUST_DFLEX_PKG.CustomValidateDFlexValues(p_exp_header_info,
1916 p_exp_line_info,
1917 p_custom_fields_array,
1918 l_dummy_field_rec,
1919 'LINE',
1920 l_result_message,
1921 l_message_type,
1922 p_receipt_index);
1923
1924
1925 IF (UPPER(l_message_type) = C_CustValidResMsgTypeError) AND
1926 (l_result_message IS NOT NULL) THEN
1927
1928 ---------------------------------------------------------------
1929 l_debug_info := 'Appending Line Custom Validate Error Message';
1930 ---------------------------------------------------------------
1931
1932
1933 AP_WEB_UTILITIES_PKG.AddExpErrorNotEncoded(p_error,l_result_message,
1934 AP_WEB_UTILITIES_PKG.C_ErrorMessageType,'CustomValidate', p_receipt_index,AP_WEB_UTILITIES_PKG.C_DFFMessageCategory);
1935
1936 END IF;
1937
1938 FOR i IN 1..l_num_of_cust_fields LOOP
1939
1940 ---------------------------------------------------------------------------
1941 l_debug_info := 'Calling CustomValidateDFlexValues for field ' || to_char(i);
1942 --------------------------------------------------------------------------
1943 l_result_message := NULL;
1944 l_message_type := NULL;
1945 AP_WEB_CUST_DFLEX_PKG.CustomValidateDFlexValues(p_exp_header_info,
1946 p_exp_line_info,
1947 p_custom_fields_array,
1948 p_custom_fields_array(i),
1949 'FIELD',
1950 l_result_message,
1951 l_message_type,
1952 p_receipt_index);
1953
1954 IF (UPPER(l_message_type) = C_CustValidResMsgTypeError) AND
1955 (l_result_message IS NOT NULL) THEN
1956
1957 ---------------------------------------------------
1958 l_debug_info := 'Appending Custom Validate errors';
1959 ---------------------------------------------------
1960
1961 AP_WEB_UTILITIES_PKG.AddExpErrorNotEncoded(p_error,l_result_message,AP_WEB_UTILITIES_PKG.C_ErrorMessageType,'AppendingCustomValidate', p_receipt_index,AP_WEB_UTILITIES_PKG.C_DFFMessageCategory);
1962
1963
1964 /* To avoid duplicate messages in the New UI
1965 AP_WEB_UTILITIES_PKG.AddMessage(p_receipt_errors,
1966 p_receipt_index,
1967 AP_WEB_UTILITIES_PKG.C_ErrorMessageType,
1968 l_result_message,
1969 31);
1970 */
1971
1972 END IF;
1973
1974 END LOOP;
1975
1976 --Priyai
1977 AP_WEB_UTILITIES_PKG.MergeExpErrors(p_error,l_error);
1978
1979
1980 EXCEPTION
1981 WHEN OTHERS THEN
1982 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
1983 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
1984 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
1985 l_curr_calling_sequence);
1986 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1987 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
1988 END ValidateDFlexValues;
1989
1990 -----------------------------------------------------------------------------
1991 PROCEDURE PopulateExpTypeInLineRec(p_exp_line_info IN OUT NOCOPY ExpReportLineRec)
1992 -----------------------------------------------------------------------------
1993 IS
1994 l_debug_info VARCHAR2(2000);
1995 l_curr_calling_sequence VARCHAR2(200) := 'PopulateExpTypeInLineRec';
1996 l_exp_prompt AP_WEB_DB_EXPTEMPLATE_PKG.expTempl_webFriendlyPrompt;
1997 BEGIN
1998 IF (AP_WEB_DB_EXPTEMPLATE_PKG.GetExpTypePrompt(
1999 to_number(p_exp_line_info.parameter_id), l_exp_prompt)) THEN
2000 p_exp_line_info.expense_type := l_exp_prompt;
2001 END IF;
2002 EXCEPTION
2003 WHEN OTHERS THEN
2004 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2005 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2006 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2007 l_curr_calling_sequence);
2008 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
2009 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
2010 END PopulateExpTypeInLineRec;
2011
2012 ------------------------------------------------------------------------------
2013 PROCEDURE PopulateCustomFieldsInfo(
2014 p_userId IN NUMBER,
2015 p_exp_line_info IN OUT NOCOPY ExpReportLineRec,
2016 p_custom_fields_array IN OUT NOCOPY CustomFields_A,
2017 p_num_global_enabled_segs IN OUT NOCOPY NUMBER,
2018 p_num_context_enabled_segs IN OUT NOCOPY NUMBER,
2019 p_dflexfield IN OUT NOCOPY FND_DFLEX.DFLEX_R,
2020 p_dflexinfo IN OUT NOCOPY FND_DFLEX.DFLEX_DR,
2021 p_dflexfield_contexts IN OUT NOCOPY FND_DFLEX.CONTEXTS_DR,
2022 p_context_index IN OUT NOCOPY NUMBER)
2023 -------------------------------------------------------------------------------
2024 IS
2025 l_dflexfield_name FND_DESCRIPTIVE_FLEXS.Descriptive_Flexfield_Name%TYPE;
2026 l_dflex_context FND_DFLEX.CONTEXT_R;
2027 l_dflex_global_segs FND_DFLEX.SEGMENTS_DR;
2028 l_dflex_context_segs FND_DFLEX.SEGMENTS_DR;
2029 l_is_dflexfield_used BOOLEAN;
2030
2031 l_debug_info VARCHAR2(2000);
2032 l_curr_calling_sequence VARCHAR2(200) := 'PopulateCustomFieldsInfo';
2033 BEGIN
2034
2035 -------------------------------------------------------
2036 l_debug_info := 'Check whether any expense type is specified';
2037 -------------------------------------------------------
2038 IF p_exp_line_info.parameter_id IS NULL THEN
2039 RETURN;
2040 END IF;
2041
2042 -------------------------------------------------------
2043 l_debug_info := 'Retrieving FND Descriptive Flex Info';
2044 -------------------------------------------------------
2045 GetExpenseLineDFlexInfo(p_userId, -- 2377002
2046 p_dflexfield,
2047 p_dflexinfo,
2048 p_dflexfield_contexts,
2049 l_is_dflexfield_used);
2050
2051 -- No need to populate custom fields with defaults since descriptive
2052 -- flexfield used.
2053 IF NOT l_is_dflexfield_used THEN
2054 RETURN;
2055 END IF;
2056
2057 -------------------------------------------------------------------
2058 l_debug_info := 'Retrieving FND Descriptive Flex Context Segments';
2059 -------------------------------------------------------------------
2060 GetDFlexContextSegments(p_dflexfield,
2061 p_dflexfield_contexts,
2062 p_dflexfield_contexts.global_context,
2063 l_dflex_global_segs);
2064
2065 ----------------------------------------------------------
2066 l_debug_info := 'Retrieve Num of Global Enabled Segments';
2067 ----------------------------------------------------------
2068 p_num_global_enabled_segs :=
2069 GetNumOFEnabledSegments(l_dflex_global_segs);
2070
2071 IF (p_num_global_enabled_segs > 0) THEN
2072
2073 -----------------------------------------------------------------
2074 l_debug_info := 'Associating Global Custom Fields Info to Value';
2075 -----------------------------------------------------------------
2076 AssocCustFieldPromptsToValues(l_dflex_global_segs,
2077 1,
2078 p_num_global_enabled_segs,
2079 p_custom_fields_array);
2080
2081 END IF;
2082
2083 ---------------------------------------------------
2084 l_debug_info := 'Calling PopulateExpTypeInLineRec';
2085 ---------------------------------------------------
2086 PopulateExpTypeInLineRec(p_exp_line_info);
2087
2088 ------------------------------------------------------------
2089 l_debug_info := 'Retrieving Index for DFlex Context Value';
2090 ------------------------------------------------------------
2091 GetDFlexContextIndex(p_exp_line_info.expense_type,
2092 p_dflexfield_contexts,
2093 p_context_index);
2094
2095 IF (p_context_index IS NOT NULL) THEN
2096
2097 -- bug 3597789 - Check if context is Enabled prior to verifying if
2098 -- context segments are enabled.
2099 IF p_dflexfield_contexts.is_enabled(p_context_index) THEN
2100
2101 ----------------------------------------------------
2102 l_debug_info := 'Retrieve FND Dflex Context Values';
2103 ----------------------------------------------------
2104 GetDFlexContextSegments(p_dflexfield,
2105 p_dflexfield_contexts,
2106 p_context_index,
2107 l_dflex_context_segs);
2108
2109 ----------------------------------------------------------
2110 l_debug_info := 'Retrieve Num of Context Enabled Segments';
2111 ----------------------------------------------------------
2112 p_num_context_enabled_segs :=
2113 GetNumOFEnabledSegments(l_dflex_context_segs);
2114
2115 IF (p_num_context_enabled_segs > 0) THEN
2116
2117 -----------------------------------------------------------------
2118 l_debug_info := 'Associating Context Custom Fields Info to Value';
2119 -----------------------------------------------------------------
2120 AssocCustFieldPromptsToValues(l_dflex_context_segs,
2121 p_num_global_enabled_segs+1,
2122 p_num_global_enabled_segs + p_num_context_enabled_segs,
2123 p_custom_fields_array);
2124
2125 END IF; -- l_context_dflex_segs.nsegments > 0
2126 ELSE
2127 p_num_context_enabled_segs := NULL;
2128 END IF;
2129 ELSE
2130
2131 -- p_num_context_enabled_segs equaling NULL means this context is not
2132 -- defined to distinguish the case that context is defined but no segs
2133 -- have been defined.
2134 p_num_context_enabled_segs := NULL;
2135 END IF; -- l_context_index IS NOT NULL
2136
2137 EXCEPTION
2138 WHEN OTHERS THEN
2139 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2140 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2141 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2142 l_curr_calling_sequence);
2143 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
2144 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
2145 END PopulateCustomFieldsInfo;
2146
2147
2148
2149
2150 ------------------------------------------------------------------------------
2151 PROCEDURE ValidateReceiptCustomFields(
2152 p_userId IN NUMBER,
2153 p_exp_header_info IN ExpReportHeaderRec,
2154 p_exp_line_info IN OUT NOCOPY ExpReportLineRec,
2155 p_custom_fields_array IN OUT NOCOPY CustomFields_A,
2156 p_receipt_errors IN OUT NOCOPY AP_WEB_UTILITIES_PKG.Receipt_Error_Stack,
2157 p_receipt_index IN BINARY_INTEGER,
2158 p_error IN OUT NOCOPY AP_WEB_UTILITIES_PKG.expError)
2159 -------------------------------------------------------------------------------
2160 IS
2161 l_dflexfield FND_DFLEX.DFLEX_R;
2162 l_dflexinfo FND_DFLEX.DFLEX_DR;
2163 l_dflexfield_name FND_DESCRIPTIVE_FLEXS.Descriptive_Flexfield_Name%TYPE;
2164 l_dflex_context FND_DFLEX.CONTEXT_R;
2165 l_dflex_contexts FND_DFLEX.CONTEXTS_DR;
2166 l_dflex_global_segs FND_DFLEX.SEGMENTS_DR;
2167 l_dflex_context_segs FND_DFLEX.SEGMENTS_DR;
2168 l_num_global_enabled_segs NUMBER;
2169 l_num_context_enabled_segs NUMBER;
2170 l_context_index BINARY_INTEGER := NULL;
2171 l_debug_info VARCHAR2(2000);
2172 l_curr_calling_sequence VARCHAR2(200) := 'ValidateReceiptCustomFields';
2173 l_dflex_enabled VARCHAR2(1) := NULL;
2174 l_num_of_cust_fields BINARY_INTEGER := NULL;
2175 V_ValueSetInfo FND_VSET.VALUESET_R;
2176 V_ValueSetFormat FND_VSET.VALUESET_DR;
2177 V_Date DATE;
2178 V_Date_Format VARCHAR2(30);
2179 p_format_type VARCHAR2(1);
2180 p_number_precision NUMBER(2);
2181
2182
2183 BEGIN
2184 -- Bug 2188747 we need to able to user the profile option of the employee instead of the preparer
2185 l_debug_info := 'Get AP_WEB_DESC_FLEX_NAME profile option';
2186 if (p_userId is null) then -- user loggon
2187 l_dflex_enabled := FND_PROFILE.VALUE('AP_WEB_DESC_FLEX_NAME');
2188 else
2189 l_dflex_enabled := AP_WEB_UTILITIES_PKG.VALUE_SPECIFIC(
2190 p_name => 'AP_WEB_DESC_FLEX_NAME',
2191 p_user_id => p_userId,
2192 p_resp_id => null,
2193 p_apps_id => null);
2194 end if;
2195
2196 -- if (l_dflex_enabled <> 'Y') then
2197 -- Bug 3985122 Y-Lines Only, B - Both Header and Lines, H - Header Only
2198 if ((nvl(l_dflex_enabled,'N') = 'N') OR (nvl(l_dflex_enabled,'N') = 'H')) then
2199 return;
2200 end if;
2201
2202 -----------------------------------------------
2203 l_debug_info := 'populate custom field array';
2204 -----------------------------------------------
2205 PopulateCustomFieldsInfo(p_userId,
2206 p_exp_line_info,
2207 p_custom_fields_array,
2208 l_num_global_enabled_segs,
2209 l_num_context_enabled_segs,
2210 l_dflexfield,
2211 l_dflexinfo,
2212 l_dflex_contexts,
2213 l_context_index);
2214
2215 -- If there are no segments to validate we will not call the validation
2216 -- routine. There is a bug in validate_desccols that produces a numeric
2217 -- or value error if a context value is defined but no segments are
2218 -- defined. It should produce a warning not cause an error.
2219 IF (l_num_global_enabled_segs + nvl(l_num_context_enabled_segs,0) > 0) THEN
2220
2221 -- Bug# 7650153 - Converting date into canonical date format for dff segments
2222 l_num_of_cust_fields := l_num_global_enabled_segs + nvl(l_num_context_enabled_segs,0);
2223 FOR i in 1..l_num_of_cust_fields LOOP
2224
2225 GetValueSet(p_custom_fields_array(i).value_set,V_ValueSetInfo,V_ValueSetFormat);
2226 IF (V_ValueSetInfo.name = 'FND_STANDARD_DATE') AND (p_custom_fields_array(i).value IS NOT NULL) THEN
2227 V_Date_Format := nvl(icx_sec.g_date_format,icx_sec.getNLS_PARAMETER('NLS_DATE_FORMAT'));
2228 V_Date := FND_DATE.string_to_date(p_custom_fields_array(i).value,V_Date_Format);
2229 IF (V_Date IS NOT NULL) THEN
2230 p_custom_fields_array(i).value := FND_DATE.date_to_canonical(V_Date);
2231 END IF;
2232 -- Bug# 8444154 - Decimal digits of the segment value should be equal to the number precision defined for the value set
2233 ELSIF (p_custom_fields_array(i).value_set IS NOT NULL) THEN
2234 begin
2235 select format_type, number_precision into p_format_type, p_number_precision
2236 from fnd_flex_value_sets where flex_value_set_id = p_custom_fields_array(i).value_set;
2237 exception
2238 when others then
2239 p_format_type := null;
2240 p_number_precision := 0;
2241 end;
2242 IF ((p_format_type = 'N' AND p_number_precision > 0) AND (p_custom_fields_array(i).value IS NOT NULL)) THEN
2243 p_custom_fields_array(i).value := Rtrim(Ltrim(p_custom_fields_array(i).value));
2244 p_custom_fields_array(i).value := Rpad(p_custom_fields_array(i).value, p_number_precision + instr(p_custom_fields_array(i).value,'.'), '0');
2245 END IF;
2246 END IF;
2247
2248 END LOOP;
2249
2250 -----------------------------------------------
2251 l_debug_info := 'Calling ValidateDFlexValues';
2252 -----------------------------------------------
2253 ValidateDFlexValues(p_exp_header_info,
2254 p_exp_line_info,
2255 p_custom_fields_array,
2256 l_num_global_enabled_segs,
2257 l_num_context_enabled_segs,
2258 l_dflexfield.flexfield_name,
2259 l_dflex_contexts,
2260 l_context_index,
2261 p_receipt_errors,
2262 p_receipt_index,
2263 p_error);
2264
2265
2266 END IF;
2267
2268 EXCEPTION
2269 WHEN OTHERS THEN
2270 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2271 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2272 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2273 l_curr_calling_sequence);
2274 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
2275 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
2276 END ValidateReceiptCustomFields;
2277
2278 ----------------------------------------------------------------------------
2279 PROCEDURE PopulateCustomFieldsInfoAll(
2280 p_report_lines_info IN OUT NOCOPY ExpReportLines_A,
2281 p_custom1_array IN OUT NOCOPY CustomFields_A,
2282 p_custom2_array IN OUT NOCOPY CustomFields_A,
2283 p_custom3_array IN OUT NOCOPY CustomFields_A,
2284 p_custom4_array IN OUT NOCOPY CustomFields_A,
2285 p_custom5_array IN OUT NOCOPY CustomFields_A,
2286 p_custom6_array IN OUT NOCOPY CustomFields_A,
2287 p_custom7_array IN OUT NOCOPY CustomFields_A,
2288 p_custom8_array IN OUT NOCOPY CustomFields_A,
2289 p_custom9_array IN OUT NOCOPY CustomFields_A,
2290 p_custom10_array IN OUT NOCOPY CustomFields_A,
2291 p_custom11_array IN OUT NOCOPY CustomFields_A,
2292 p_custom12_array IN OUT NOCOPY CustomFields_A,
2293 p_custom13_array IN OUT NOCOPY CustomFields_A,
2294 p_custom14_array IN OUT NOCOPY CustomFields_A,
2295 p_custom15_array IN OUT NOCOPY CustomFields_A,
2296 p_receipts_count IN BINARY_INTEGER)
2297 ----------------------------------------------------------------------------
2298 IS
2299
2300 l_receipt_custom_fields_array CustomFields_A;
2301 l_receipt_index BINARY_INTEGER := 1;
2302 l_unexp_err VARCHAR2(2000);
2303
2304 l_dflexfield FND_DFLEX.DFLEX_R;
2305 l_dflexinfo FND_DFLEX.DFLEX_DR;
2306 l_dflex_contexts FND_DFLEX.CONTEXTS_DR;
2307 l_num_global_enabled_segs NUMBER;
2308 l_num_context_enabled_segs NUMBER;
2309 l_context_index BINARY_INTEGER := NULL;
2310
2311 l_curr_calling_sequence VARCHAR2(200) := 'PopulateCustomFieldsInfoAll';
2312 l_debug_info VARCHAR2(2000);
2313
2314
2315 BEGIN
2316
2317 FOR l_receipt_index in 1 .. p_receipts_count LOOP
2318
2319 -----------------------------------------------------
2320 l_debug_info := 'GetReceiptCustomFields';
2321 -----------------------------------------------------
2322
2323 AP_WEB_DFLEX_PKG.GetReceiptCustomFields(l_receipt_custom_fields_array,
2324 l_receipt_index,
2325 p_custom1_array,
2326 p_custom2_array,
2327 p_custom3_array,
2328 p_custom4_array,
2329 p_custom5_array,
2330 p_custom6_array,
2331 p_custom7_array,
2332 p_custom8_array,
2333 p_custom9_array,
2334 p_custom10_array,
2335 p_custom11_array,
2336 p_custom12_array,
2337 p_custom13_array,
2338 p_custom14_array,
2339 p_custom15_array);
2340
2341 -----------------------------------------------------
2342 l_debug_info := 'ValidateReceiptCustomFields';
2343 -----------------------------------------------------
2344 PopulateCustomFieldsInfo(null,
2345 p_report_lines_info(l_receipt_index),
2346 l_receipt_custom_fields_array,
2347 l_num_global_enabled_segs,
2348 l_num_context_enabled_segs,
2349 l_dflexfield,
2350 l_dflexinfo,
2351 l_dflex_contexts,
2352 l_context_index);
2353
2354 -----------------------------------------------------
2355 l_debug_info := 'PropogateReceiptCustFldsInfo';
2356 -----------------------------------------------------
2357 AP_WEB_DFLEX_PKG.PropogateReceiptCustFldsInfo(
2358 l_receipt_custom_fields_array,
2359 l_receipt_index,
2360 p_custom1_array,
2361 p_custom2_array,
2362 p_custom3_array,
2363 p_custom4_array,
2364 p_custom5_array,
2365 p_custom6_array,
2366 p_custom7_array,
2367 p_custom8_array,
2368 p_custom9_array,
2369 p_custom10_array,
2370 p_custom11_array,
2371 p_custom12_array,
2372 p_custom13_array,
2373 p_custom14_array,
2374 p_custom15_array);
2375
2376 END LOOP;
2377
2378 EXCEPTION
2379 WHEN OTHERS THEN
2380 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2381 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2382 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2383 l_curr_calling_sequence);
2384 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
2385 AP_WEB_UTILITIES_PKG.DisplayException(fnd_message.get);
2386 END PopulateCustomFieldsInfoAll;
2387
2388
2389 PROCEDURE SetExpReportLineInfo(P_ExpReportLineInfo OUT NOCOPY ExpReportLineRec,
2390 P_receipt_index IN NUMBER,
2391 P_start_date IN DATE,
2392 P_end_date IN DATE,
2393 P_days IN VARCHAR2,
2394 P_daily_amount IN VARCHAR2,
2395 P_receipt_amount IN VARCHAR2,
2396 P_rate IN VARCHAR2,
2397 P_amount IN VARCHAR2,
2398 P_parameter_id IN VARCHAR2,
2399 P_expense_type IN VARCHAR2,
2400 P_currency_code IN VARCHAR2,
2401 P_group_value IN VARCHAR2,
2402 P_justification IN VARCHAR2,
2403 P_receipt_missing_flag IN VARCHAR2,
2404 P_validation_required IN VARCHAR2,
2405 P_calculate_flag IN VARCHAR2,
2406 P_calculated_amount IN VARCHAR2,
2407 P_copy_calc_amt_into_receipt IN VARCHAR2,
2408 P_AmtInclTax IN VARCHAR2,
2409 P_TaxCode IN VARCHAR2,
2410 P_TaxOverrideFlag IN VARCHAR2,
2411 P_TaxId IN VARCHAR2,
2412 P_ProjectID IN VARCHAR2,
2413 P_ProjectNumber IN VARCHAR2,
2414 P_TaskID IN VARCHAR2,
2415 P_TaskNumber IN VARCHAR2,
2416 P_ExpenditureType IN VARCHAR2)
2417
2418 IS
2419 current_calling_sequence varchar2(255) := 'SetExpReportLineInfo';
2420 debug_info varchar2(255) := '';
2421
2422 BEGIN
2423 debug_info := 'Begin SetExpReportLineInfo';
2424 P_ExpReportLineInfo.receipt_index := P_receipt_index;
2425 P_ExpReportLineInfo.start_date := P_start_date;
2426 P_ExpReportLineInfo.end_date := P_end_date;
2427 P_ExpReportLineInfo.days := P_days;
2428 P_ExpReportLineInfo.daily_amount := P_daily_amount;
2429 P_ExpReportLineInfo.receipt_amount := P_receipt_amount;
2430
2431 P_ExpReportLineInfo.rate := P_rate;
2432 P_ExpReportLineInfo.amount := P_amount;
2433 P_ExpReportLineInfo.parameter_id := P_parameter_id;
2434 P_ExpReportLineInfo.expense_type := P_expense_type;
2435 P_ExpReportLineInfo.currency_code := P_currency_code;
2436 P_ExpReportLineInfo.group_value := P_group_value;
2437 P_ExpReportLineInfo.justification := P_justification;
2438 P_ExpReportLineInfo.receipt_missing_flag := P_receipt_missing_flag;
2439 P_ExpReportLineInfo.validation_required := P_validation_required;
2440 P_ExpReportLineInfo.calculate_flag := P_calculate_flag;
2441 P_ExpReportLineInfo.calculated_amount := P_calculated_amount;
2442 P_ExpReportLineInfo.copy_calc_amt_into_receipt_amt := P_copy_calc_amt_into_receipt;
2443 P_ExpReportLineInfo.amount_includes_tax := P_AmtInclTax;
2444 P_ExpReportLineInfo.tax_code := P_TaxCode;
2445 P_ExpReportLineInfo.taxOverrideFlag := P_TaxOverrideFlag;
2446 P_ExpReportLineInfo.taxId := P_TaxId;
2447 P_ExpReportLineInfo.project_id := P_ProjectID;
2448 P_ExpReportLineInfo.project_number := P_ProjectNumber;
2449 P_ExpReportLineInfo.task_id := P_TaskID;
2450 P_ExpReportLineInfo.task_number := P_TaskNumber;
2451 P_ExpReportLineInfo.expenditure_type := P_ExpenditureType;
2452
2453 EXCEPTION
2454 WHEN OTHERS THEN
2455 BEGIN
2456 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2457 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2458 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2459 current_calling_sequence);
2460 FND_MESSAGE.SET_TOKEN('PARAMETERS',
2461 'amount = ' || P_amount ||
2462 'currency_code = ' || P_currency_code ||
2463 'receipt_amount = ' || P_receipt_amount ||
2464 'rate = ' || P_rate ||
2465 'parameter_id = ' || P_parameter_id
2466 );
2467 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
2468 APP_EXCEPTION.RAISE_EXCEPTION;
2469 END;
2470
2471 END SetExpReportLineInfo;
2472
2473 PROCEDURE SetExpReportHeaderInfo(P_ExpReportHeaderInfo OUT NOCOPY ExpReportHeaderRec,
2474 P_employee_id IN VARCHAR2,
2475 P_cost_center IN VARCHAR2,
2476 P_expense_report_id IN VARCHAR2,
2477 P_template_name IN VARCHAR2,
2478 P_purpose IN VARCHAR2,
2479 P_last_receipt_date IN VARCHAR2,
2480 P_receipt_count IN VARCHAR2,
2481 P_transaction_currency_type IN VARCHAR2,
2482 P_reimbursement_currency_code IN VARCHAR2,
2483 P_reimbursement_currency_name IN VARCHAR2,
2484 P_multi_currency_flag IN VARCHAR2,
2485 P_inverse_rate_flag IN VARCHAR2,
2486 P_approver_id IN VARCHAR2,
2487 P_approver_name IN VARCHAR2,
2488 P_expenditure_organization_id IN VARCHAR2 DEFAULT NULL)
2489 IS
2490 current_calling_sequence varchar2(255) := 'SetExpReportHeaderInfo';
2491 debug_info varchar2(255) := '';
2492 BEGIN
2493 debug_info := 'Begin SetExpReportHeaderInfo';
2494
2495 P_ExpReportHeaderInfo.receipt_count := P_receipt_count;
2496 P_ExpReportHeaderInfo.last_receipt_date := P_last_receipt_date;
2497 P_ExpReportHeaderInfo.override_approver_id := P_approver_id;
2498 P_ExpReportHeaderInfo.override_approver_name := P_approver_name;
2499 P_ExpReportHeaderInfo.cost_center := P_cost_center;
2500 P_ExpReportHeaderInfo.employee_id := P_employee_id;
2501 P_ExpReportHeaderInfo.template_id := P_expense_report_id;
2502 P_ExpReportHeaderInfo.template_name := P_template_name;
2503 P_ExpReportHeaderInfo.reimbursement_currency_code := P_reimbursement_currency_code;
2504 P_ExpReportHeaderInfo.reimbursement_currency_name := P_reimbursement_currency_name;
2505 P_ExpReportHeaderInfo.transaction_currency_type := P_transaction_currency_type;
2506 P_ExpReportHeaderInfo.multi_currency_flag := P_multi_currency_flag;
2507 P_ExpReportHeaderInfo.inverse_rate_flag := P_inverse_rate_flag;
2508 P_ExpReportHeaderInfo.purpose := P_purpose;
2509 P_ExpReportHeaderInfo.expenditure_organization_id := P_expenditure_organization_id;
2510
2511 EXCEPTION
2512 WHEN OTHERS THEN
2513 BEGIN
2514 FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2515 FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2516 FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',
2517 current_calling_sequence);
2518 FND_MESSAGE.SET_TOKEN('PARAMETERS',
2519 'employee_id = ' || P_employee_id
2520 );
2521 FND_MESSAGE.SET_TOKEN('DEBUG_INFO',debug_info);
2522 APP_EXCEPTION.RAISE_EXCEPTION;
2523 END;
2524
2525
2526 END SetExpReportHeaderInfo;
2527
2528
2529
2530 END AP_WEB_DFLEX_PKG;