17:
18: --*********************** Public procedures ******************************--
19:
20: PROCEDURE do_unit_adjustment(p_api_version IN NUMBER,
21: p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
22: p_commit IN VARCHAR2 := FND_API.G_FALSE,
23: p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
24: p_calling_fn IN VARCHAR2,
25: x_return_status OUT NOCOPY VARCHAR2,
18: --*********************** Public procedures ******************************--
19:
20: PROCEDURE do_unit_adjustment(p_api_version IN NUMBER,
21: p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
22: p_commit IN VARCHAR2 := FND_API.G_FALSE,
23: p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
24: p_calling_fn IN VARCHAR2,
25: x_return_status OUT NOCOPY VARCHAR2,
26: x_msg_count OUT NOCOPY NUMBER,
19:
20: PROCEDURE do_unit_adjustment(p_api_version IN NUMBER,
21: p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
22: p_commit IN VARCHAR2 := FND_API.G_FALSE,
23: p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
24: p_calling_fn IN VARCHAR2,
25: x_return_status OUT NOCOPY VARCHAR2,
26: x_msg_count OUT NOCOPY NUMBER,
27: x_msg_data OUT NOCOPY VARCHAR2,
55: if (not g_log_level_rec.initialized) then
56: if (NOT fa_util_pub.get_log_level_rec (
57: x_log_level_rec => g_log_level_rec
58: )) then
59: raise FND_API.G_EXC_ERROR;
60: end if;
61: end if;
62:
63: IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
59: raise FND_API.G_EXC_ERROR;
60: end if;
61: end if;
62:
63: IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
64: l_api_name, G_PKG_NAME) then
65: RAISE FND_API.G_EXC_ERROR;
66: END IF;
67:
61: end if;
62:
63: IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
64: l_api_name, G_PKG_NAME) then
65: RAISE FND_API.G_EXC_ERROR;
66: END IF;
67:
68: if (p_init_msg_list = FND_API.G_TRUE) then
69: fa_srvr_msg.Init_Server_Message;
64: l_api_name, G_PKG_NAME) then
65: RAISE FND_API.G_EXC_ERROR;
66: END IF;
67:
68: if (p_init_msg_list = FND_API.G_TRUE) then
69: fa_srvr_msg.Init_Server_Message;
70: fa_debug_pkg.Initialize;
71: end if;
72:
75: calling_fn => 'FA_UNIT_ADJ_PUB.valid_input',
76: name => 'FA_SHARED_ITEM_NULL',
77: token1 => 'ITEM',
78: value1 => 'Asset Id', p_log_level_rec => g_log_level_rec);
79: RAISE FND_API.G_EXC_ERROR;
80: end if;
81:
82: -- Bug 8252607/5475276 Get the book_type_code if it is not supplied.
83: if (px_asset_hdr_rec.book_type_code is null) then
88: if px_asset_hdr_rec.book_type_code is null then
89: fa_srvr_msg.add_message
90: (calling_fn => 'FA_UNIT_ADJ_PUB.do_unit_adjustment',
91: name => 'FA_EXP_GET_ASSET_INFO', p_log_level_rec => g_log_level_rec);
92: raise FND_API.G_EXC_ERROR;
93: end if;
94: end if;
95:
96: -- call the cache for the primary transaction book
94: end if;
95:
96: -- call the cache for the primary transaction book
97: if NOT fa_cache_pkg.fazcbc(X_book => px_asset_hdr_rec.book_type_code, p_log_level_rec => g_log_level_rec) then
98: RAISE FND_API.G_EXC_ERROR;
99: end if;
100:
101: -- validate book if corporate, validate asset
102:
104: (p_transaction_type_code => 'UNIT ADJUSTMENT',
105: p_book_type_code => px_asset_hdr_rec.book_type_code,
106: p_asset_id => px_asset_hdr_rec.asset_id,
107: p_calling_fn => 'FA_UNIT_ADJ_PUB.valid_input', p_log_level_rec => g_log_level_rec) then
108: raise FND_API.G_EXC_ERROR;
109: end if;
110:
111: px_trans_rec.transaction_type_code := 'UNIT ADJUSTMENT';
112: IF NOT FA_TRX_APPROVAL_PKG.faxcat(
114: X_asset_id =>px_asset_hdr_rec.asset_id,
115: X_trx_type =>'TRANSFER',
116: X_trx_date =>px_trans_rec.transaction_date_entered,
117: X_init_message_flag=> 'NO', p_log_level_rec => g_log_level_rec) then
118: raise FND_API.G_EXC_ERROR;
119: end if;
120:
121: if not fa_asset_val_pvt.validate_period_of_addition
122: (px_asset_hdr_rec.asset_id,
122: (px_asset_hdr_rec.asset_id,
123: px_asset_hdr_rec.book_type_code,
124: 'ABSOLUTE',
125: l_period_addition, p_log_level_rec => g_log_level_rec) then
126: RAISE FND_API.G_EXC_ERROR;
127: end if;
128: px_asset_hdr_rec.period_of_addition := l_period_addition;
129:
130:
131: -- validate input
132: if not valid_input(px_trans_rec,
133: px_asset_hdr_rec,
134: g_log_level_rec) then
135: raise FND_API.G_EXC_ERROR;
136: end if;
137:
138:
139: -- BUG# 3325400
151: px_trans_rec => px_trans_rec,
152: px_asset_hdr_rec => px_asset_hdr_rec,
153: px_asset_cat_rec_new => l_asset_cat_rec,
154: px_asset_dist_tbl => px_asset_dist_tbl, p_log_level_rec => g_log_level_rec) then
155: raise FND_API.G_EXC_ERROR;
156: end if;
157:
158: /*
159: * Code hook for IAC
162: if not FA_IGI_EXT_PKG.Do_Unit_Adjustment(
163: p_trans_rec => px_trans_rec,
164: p_asset_hdr_rec => px_asset_hdr_rec,
165: p_asset_cat_rec => l_asset_cat_rec,
166: p_calling_function => 'FA_UNIT_ADJ_PUB.DO_UNIT_ADJUSTMENT') then raise FND_API.G_EXC_ERROR;
167: end if;
168: end if; -- (FA_IGI_EXT_PKG.IAC_Enabled)
169:
170: if fa_cse_callouts_pvt.is_oat_enabled then
171: if not fa_cse_callouts_pvt.unit_adjustment(
172: p_trans_rec => px_trans_rec,
173: p_asset_hdr_rec => px_asset_hdr_rec,
174: p_asset_dist_tbl => px_asset_dist_tbl) then
175: raise FND_API.G_EXC_ERROR;
176: end if;
177: end if;
178:
179: if (p_commit = FND_API.G_TRUE) then
175: raise FND_API.G_EXC_ERROR;
176: end if;
177: end if;
178:
179: if (p_commit = FND_API.G_TRUE) then
180: COMMIT WORK;
181: end if;
182:
183: FND_MSG_PUB.Count_And_Get(
185: p_data => x_msg_data
186: );
187:
188: -- Return the status.
189: x_return_status := FND_API.G_RET_STS_SUCCESS;
190:
191:
192: EXCEPTION
193: WHEN FND_API.G_EXC_ERROR THEN
189: x_return_status := FND_API.G_RET_STS_SUCCESS;
190:
191:
192: EXCEPTION
193: WHEN FND_API.G_EXC_ERROR THEN
194: FA_SRVR_MSG.Add_Message(
195: calling_fn => 'FA_UNIT_ADJ_PUB.do_unit_adjustment', p_log_level_rec => g_log_level_rec);
196:
197: FND_MSG_PUB.Count_And_Get(
198: p_count => x_msg_count,
199: p_data => x_msg_data
200: );
201: ROLLBACK TO unit_adj_pub;
202: x_return_status := FND_API.G_RET_STS_ERROR;
203:
204: WHEN OTHERS THEN
205: FA_SRVR_MSG.Add_Sql_Error(
206: calling_fn => 'FA_UNIT_ADJ_PUB.do_unit_adjustment', p_log_level_rec => g_log_level_rec);
209: p_count => x_msg_count,
210: p_data => x_msg_data
211: );
212: ROLLBACK TO unit_adj_pub;
213: x_return_status := FND_API.G_RET_STS_ERROR;
214:
215: END;
216:
217: FUNCTION valid_input(px_trans_rec IN OUT NOCOPY fa_api_types.trans_rec_type,