Last week I started to working on an order import pragram. A sample program in our live system does similar thing but it has no price adjustment etc. To have more information when importing the order, I tried the oe_debug_pub using following code:
IF g_debug_flag = 'Y' THEN
oe_debug_pub.initialize;
oe_debug_pub.debug_on;
l_debug_file := oe_debug_pub.set_debug_mode('CONC');
oe_debug_pub.setdebuglevel(5);
--wsh_util_core.Enable_Concurrent_Log_Print;
--wsh_util_core.Set_Log_Level(4);
END IF;
process_order;
IF g_debug_flag = 'Y' THEN
l_msg_count := oe_debug_pub.countdebug;
FOR i IN 1..l_msg_count LOOP
oe_debug_pub.getnext(l_err_msg);
log(l_err_msg);
END LOOP;
END IF;
But the output msg is really ugly and maybe only readable to Oracle Dev guys or support guys. After going through the code in OE_ORDER_PVT etc, I noticed when there are some validation exceptions, it will use OE_MSG_PUB.add like following:
FND_MESSAGE.SET_NAME('ONT','OE_API_INV_PARENT_INDEX');
FND_MESSAGE.SET_TOKEN('ENTITY_NAME','Header_Adj_Attribs');
FND_MESSAGE.SET_TOKEN('ENTITY_INDEX',I);
FND_MESSAGE.SET_TOKEN('PARENT_INDEX',p_x_header_adj_att_tbl(I).adj_index);
OE_MSG_PUB.Add;
This set the message and tokens in message, then it will add the message to OE_MSG_PUB message stack. So I tried to use following in my code:
IF x_msg_count > 0 THEN
FOR i IN 1..x_msg_count LOOP --here x_msg_count is the x_msg_count in process_order api
l_err_msg := oe_msg_pub.get(p_msg_index => i, p_encoded => 'F');
log(l_err_msg);
END LOOP;
END IF;
Well, in my log file , it display neatly the exception message I want , just similar to those displayed in "Order Import Child Req1 (Order Import)" child request spawned by "Order Import" program. And most importantly, it's readable and user friendly.
Later, I remember that I used this in processing constraint API, defaulting rule and workflow program to add msg into OM message stack and it can display message in custom API even in front end UI.
So to be informational in OM, never forget to use OE_MSG_PUB.ADDOrder Import