1 PACKAGE BODY OE_Default_Line_Scredit AS
2 /* $Header: OEXDLSCB.pls 120.0 2005/06/01 00:04:30 appldev noship $ */
3
4 -- Global constant holding the package name
5 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OE_Default_Line_Scredit';
6
7 g_line_scredit_rec OE_ORDER_PUB.Line_Scredit_Rec_Type;
8
9 FUNCTION Get_Sales_Credit
10 RETURN NUMBER
11 IS
12 l_id number;
13 --
14 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
15 --
16 BEGIN
17 select OE_SALES_CREDITS_S.nextval
18 into l_id
19 from dual;
20 return l_id;
21 END Get_Sales_Credit;
22
23
24 FUNCTION Get_Header
25 RETURN NUMBER
26 IS
27 l_id number;
28 --
29 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
30 --
31 BEGIN
32 IF g_line_scredit_rec.header_id IS NULL OR
33 g_line_scredit_rec.header_id = FND_API.G_MISS_NUM THEN
34 select header_id
35 into l_id
36 from oe_order_lines_all where
37 line_id = g_line_scredit_rec.line_id;
38 return l_id;
39 ELSE
40 return g_line_scredit_rec.header_id;
41 END IF;
42 exception
43
44 when no_data_found then
45 return null;
46
47 END Get_header;
48
49
50 PROCEDURE Attributes
51 ( p_x_Line_Scredit_rec IN OUT NOCOPY OE_Order_PUB.Line_Scredit_Rec_Type
52 , p_old_Line_Scredit_rec IN OE_Order_PUB.Line_Scredit_Rec_Type
53 , p_iteration IN NUMBER := 1
54 )
55 IS
56 --l_old_line_scredit_rec OE_AK_LINE_SCREDITS_V%ROWTYPE;
57 l_operation VARCHAR2(30);
58 --
59 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
60 --
61 BEGIN
62 IF l_debug_level > 0 THEN
63 oe_debug_pub.add( 'ENTER OE_DEFAULT_LINE_SCREDIT.ATTRIBUTES' ) ;
64 END IF;
65
66 -- Due to incompatibilities in the record type structure
67 -- Copy the data to a rowtype record format
68 IF l_debug_level > 0 THEN
69 oe_debug_pub.add( 'DEFAULT ATTRIBUTES 1' ) ;
70 END IF;
71
72 /* Commented the following code to fix the bug 2044438
73
74 OE_Line_Scredit_UTIL.API_Rec_To_Rowtype_Rec
75 (p_line_scredit_rec => p_x_line_scredit_rec
76 ,x_rowtype_rec => g_line_scredit_rec);
77
78 oe_debug_pub.add('Default attributes 1.1');
79 OE_Line_Scredit_UTIL.API_Rec_To_Rowtype_Rec
80 (p_line_scredit_rec => p_old_line_scredit_rec
81 ,x_rowtype_rec => l_old_line_scredit_rec);
82
83 oe_debug_pub.add('Default attributes 2');
84
85 End Comment for bug 2044438 */
86
87 g_line_scredit_rec := p_x_line_scredit_rec;
88
89 IF g_line_scredit_rec.sales_credit_id = FND_API.G_MISS_NUM THEN
90 g_line_scredit_rec.sales_credit_id := Get_Sales_Credit;
91 IF l_debug_level > 0 THEN
92 oe_debug_pub.add( 'SALES_CREDIT_ID = '||G_LINE_SCREDIT_REC.SALES_CREDIT_ID ) ;
93 END IF;
94 END IF;
95
96 IF g_line_scredit_rec.line_id IS NOT NULL AND
97 g_line_scredit_rec.line_id <> FND_API.G_MISS_NUM THEN
98 g_line_scredit_rec.header_id := Get_Header;
99 END IF;
100
101 IF l_debug_level > 0 THEN
102 oe_debug_pub.add( 'DEFAULT ATTRIBUTES 3' ) ;
103 END IF;
104
105
106 /* Commented the following code to fix the bug 2044438
107
108 -- Call the default handler framework to default the missing attributes
109 oe_debug_pub.add('Default attributes 4');
110 ONT_LINE_SCREDIT_Def_Hdlr.Default_Record
111 (p_x_rec => g_line_scredit_rec
112 ,p_in_old_rec => l_old_line_scredit_rec);
113
114 -- copy the data back to a format that is compatible with the API architecture
115 oe_debug_pub.add('Default attributes 5');
116 OE_Line_Scredit_UTIL.RowType_Rec_to_API_Rec
117 (p_record => g_line_scredit_rec
118 ,x_api_rec => p_x_line_scredit_rec);
119
120 End Comment for bug 2044438 */
121
122 /* Added the following code to fix the bug 2044438 */
123
124 p_x_line_scredit_rec := g_line_scredit_rec;
125
126 IF l_debug_level > 0 THEN
127 oe_debug_pub.add( 'CALL CONVERT_MISS_TO_NULL' ) ;
128 END IF;
129 OE_LINE_SCREDIT_UTIL.Convert_Miss_To_Null
130 (p_x_line_scredit_rec);
131
132 /* End of the code added to fix the bug 2044438 */
133
134
135 /* 1581620 start */
136
137 IF (p_x_Line_Scredit_rec.lock_control = FND_API.G_MISS_NUM) THEN
138 p_x_Line_Scredit_rec.lock_control := NULL;
139 END IF;
140
141 IF l_debug_level > 0 THEN
142 oe_debug_pub.add( 'ORIG_SYS_CREDIT_REF = '||NVL ( P_X_LINE_SCREDIT_REC.ORIG_SYS_CREDIT_REF , 'G_MISS_CHAR' ) ) ;
143 END IF;
144 IF (p_x_Line_Scredit_rec.orig_sys_credit_ref = FND_API.G_MISS_CHAR) THEN
145 p_x_Line_Scredit_rec.orig_sys_credit_ref := 'OE_SALES_CREDITS'||p_x_Line_Scredit_rec.sales_credit_id;
146 END IF;
147
148 /* 1581620 end */
149
150 IF l_debug_level > 0 THEN
151 oe_debug_pub.add( 'DEFAULT ATTRIBUTES 6' ) ;
152 END IF;
153 IF l_debug_level > 0 THEN
154 oe_debug_pub.add( 'EXIT OE_DEFAULT_LINE_SCREDIT.ATTRIBUTES' ) ;
155 END IF;
156
157 EXCEPTION
158
159 WHEN FND_API.G_EXC_ERROR THEN
160
161 RAISE FND_API.G_EXC_ERROR;
162
163 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
164
165 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
166
167 WHEN OTHERS THEN
168
169 IF OE_MSG_PUB.Check_Msg_Level (OE_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
170 THEN
171 OE_MSG_PUB.Add_Exc_Msg
172 ( G_PKG_NAME ,
173 'Attributes'
174 );
175 END IF;
176
177 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
178
179 End Attributes;
180
181 END OE_Default_Line_Scredit ;