DBA Data[Home] [Help]

PACKAGE BODY: APPS.MTL_ONLINE_TRANSACTION_PUB

Source


1 PACKAGE BODY mtl_online_transaction_pub AS
2 /* $Header: INVTXNB.pls 120.0.12020000.2 2012/07/09 08:19:54 asugandh ship $ */
3 
4 
5   FUNCTION process_online(p_transaction_header_id IN NUMBER,
6                 p_timeout in number default NULL,
7                 p_error_code OUT NOCOPY VARCHAR2,
8                 p_error_explanation OUT NOCOPY VARCHAR2
9                 )
10   RETURN BOOLEAN
11   IS
12      p_success boolean := TRUE;
13 		 p_retval number;
14      l_transaction_header_id number;
15      l_return_status varchar(2);
16      l_msg_cnt number;
17      l_msg_data varchar2(241);
18      l_trans_count number;
19 			l_mti_cnt number;
20 			l_mmtt_cnt number;
21 			l_dbgfile varchar2(240) := 'invtmonl.log';
22 			l_dbgdir  varchar2(240);
23 
24     l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
25   BEGIN
26 
27      l_transaction_header_id := p_transaction_header_id;
28 
29 			/*
30 			 * Lock all the rows corresponding to this batch so that
31 			 * the Background manager does not pick it up
32 			 */
33        UPDATE MTL_TRANSACTIONS_INTERFACE
34         SET LOCK_FLAG = 1
35        WHERE PROCESS_FLAG = 1
36         AND TRANSACTION_HEADER_ID = l_transaction_header_id;
37        COMMIT;
38 
39      -- call to process transactions online
40      /*    p_success := inv_tm.launch
41          (
42           program  => 'INXTCW',
43           args     => to_char(l_transaction_header_id),
44           timeout  => NVL(p_timeout,120),
45           rc_field  => NULL); */
46 
47      -- calling process_transactions() with p_commit = true as otherwise
48      -- error-codes stamped on MTI could get rolled back.
49      p_retval := INV_TXN_MANAGER_PUB.process_Transactions(p_api_version => 1,
50           p_init_msg_list    => fnd_api.g_false     ,
51           p_commit           => fnd_api.g_true     ,
52           p_validation_level => fnd_api.g_valid_level_full  ,
53           x_return_status => l_return_status,
54           x_msg_count  => l_msg_cnt,
55           x_msg_data   => l_msg_data,
56           x_trans_count   => l_trans_count,
57           p_table	   => 1,
58           p_header_id => l_transaction_header_id);
59 
60      -- BUG 2709500 / 2718486 - added commit and changed p_commit above to false
61      COMMIT;
62 
63      -- no need to unlock the records in the interface tables
64      -- as the underlying code has done just that.
65      -- no need to set the error_code and error_explaination
66      -- either as underlying code also has done that.
67      if(p_retval <> 0) THEN
68         p_success := false;
69         select error_code, error_explanation
70           into p_error_code, p_error_explanation
71         from mtl_transactions_interface
72         where transaction_header_id = l_transaction_header_id
73           and rownum = 1;
74 
75         IF (l_debug = 1) THEN
76            inv_log_util.trace('Error from INV worker : error_code : '||
77             p_error_code||', err_expl :'||p_error_explanation,'INVTXNB',1);
78         END IF;
79 
80      end if;
81 
82      return p_success;
83 
84   EXCEPTION
85      -- the underlying code should have provided enough error message
86      -- in the stack. we need not add any additional messages
87 
88      WHEN NO_DATA_FOUND THEN
89         /* Bug 13503144: For IOT/ISO flow, we've made the changes that the MMT will be committed
90          * before calling RCVTM, if INV_RCV_SHIPMENTS_BULK is Y. In this case, The ITS will not
91          * show warning when there's some warning or error returned by RCVTM, due to no MTI existing.
92          * So when INV_RCV_SHIPMENTS_BULK is Y, will return False if the return value of
93          * process_Transactions() is not 0.  */
94         IF (NVL(fnd_profile.VALUE('INV_RCV_SHIPMENTS_BULK'), 0) = 1) AND (p_retval <> 0) THEN
95 
96           p_error_code := 'Transaction processor error';
97           p_error_explanation := l_msg_data;
98 
99           IF (l_debug = 1) THEN
100              inv_log_util.trace('Error from INV worker : error_code : '||
101              p_error_code||', err_expl :'||p_error_explanation,'INVTXNB',1);
102           END IF;
103 
104           RETURN FALSE;
105         ELSE  -- Added by bug 13503144
106 
107           p_error_code := ' ';
108           p_error_explanation := 'No Errors';
109           RETURN TRUE;
110         END IF; -- Added by bug 13503144
111      WHEN TOO_MANY_ROWS THEN
112 	--        dbms_output.put_line('Please specify the correct transaction header');
113         p_error_explanation:=  fnd_message.get;
114      --	p_error_explanation:= 'Please specify the correct transaction header';
115         RETURN false;
116      WHEN OTHERS THEN
117         --commented for testing        ROLLBACK;
118         RETURN FALSE;
119 
120   END;
121 
122 END;