DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_PICK_SLIP_REPORT

Source


1 PACKAGE BODY inv_pick_slip_report AS
2   /* $Header: INVPKSLB.pls 120.6.12010000.2 2008/07/29 12:53:37 ptkumar ship $ */
3 
4   g_pkg_name CONSTANT VARCHAR2(30) := 'INV_PICK_SLIP_REPORT';
5 
6   PROCEDURE mydebug(p_message VARCHAR2, p_api_name VARCHAR2) IS
7   BEGIN
8     inv_log_util.trace(p_message, g_pkg_name || '.' || p_api_name, 9);
9   END;
10 
11   FUNCTION chk_wms_install(p_organization_id IN NUMBER)
12     RETURN VARCHAR2 IS
13     l_msg_count         NUMBER;
14     l_msg_data          VARCHAR2(2000);
15     l_api_name CONSTANT VARCHAR(30)    := 'CHK_WMS_INSTALL';
16     l_return_status     VARCHAR2(1);
17   BEGIN
18     IF wms_install.check_install(x_return_status => l_return_status, x_msg_count => l_msg_count, x_msg_data => l_msg_data
19        , p_organization_id            => p_organization_id) THEN
20       RETURN 'TRUE';
21     ELSE
22       RETURN 'FALSE';
23     END IF;
24   EXCEPTION
25     WHEN OTHERS THEN
26       IF (fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)) THEN
27         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
28       END IF;
29 
30       RETURN 'FALSE';
31   END chk_wms_install;
32 
33   PROCEDURE run_detail_engine(
34     x_return_status           OUT NOCOPY    VARCHAR2
35   , p_org_id                                NUMBER
36   , p_move_order_type                       NUMBER
37   , p_move_order_from                       VARCHAR2
38   , p_move_order_to                         VARCHAR2
39   , p_source_subinv                         VARCHAR2
40   , p_source_locator_id                     NUMBER
41   , p_dest_subinv                           VARCHAR2
42   , p_dest_locator_id                       NUMBER
43   , p_sales_order_from                      VARCHAR2
44   , p_sales_order_to                        VARCHAR2
45   , p_freight_code                          VARCHAR2
46   , p_customer_id                           NUMBER
47   , p_requested_by                          NUMBER
48   , p_date_reqd_from                        DATE
49   , p_date_reqd_to                          DATE
50   , p_plan_tasks                            BOOLEAN
51   , p_pick_slip_group_rule_id               NUMBER
52   , p_request_id                            NUMBER
53   ) IS
54   /***************************************************************************
55   Created By :
56   Date Created on :
57   Purpose : This procedure will be called from Move Order Pick Slip Report.
58   Change History
59   Who             When            What
60   ------------------------------------------------------------------------
61   Nalin Kumar     22-Nov-2004     Modified the Procedure and added parameter p_request_id
62                                   to fix Bug# 4003379.
63   ------------------------------------------------------------------------
64     Reason why the p_request_id parameter has been introduced into this procedure:
65       Assume that
66        o CURSOR c_move_order_lines has 97 records
67        o 'INV: Pick Slip Batch Size' profile value is set to 10
68     - Basically to eliminate already processed records from getting selected again and again into
69       c_move_order_lines CURSOR the request_id has be introduced in this procedure.
70     - Once the number of records processed becomes equal to the value specified in 'INV: Pick Slip Batch Size'
71       profile (10) then a COMMIT is issued and the c_move_order_lines is CLOSED and OPENED once again
72       (to eliminate the 'ORA-01002: fetch out of sequence' Error). When the c_move_order_lines CURSOR
73       is OPENED for the second time then the CURSOR MAY fetch the already processed records. But the
74       idea is to process only unprocessed records and after CLOSING the CURSOR there was no pointer to
75       find out that which all records have been already processed. So to identify the processed records
76       we are updating the request_id column in mtl_txn_request_lines along with quantity_detailed. And
77       the same (request_id) column is now being used to identify unprocessed records.
78   *****************************************************************************/
79     l_api_name               VARCHAR2(30);
80 
81     l_msg_data               VARCHAR2(2000);
82     l_msg_count              NUMBER;
83 
84     l_max_batch              NUMBER;
85     l_batch_size             NUMBER;
86 
87     l_num_of_rows            NUMBER         := 0;
88     l_detailed_qty           NUMBER         := 0;
89     l_secondary_detailed_qty NUMBER         := NULL; -- INVCONV
90     l_revision               VARCHAR2(3)  := NULL;
91     l_from_loc_id            NUMBER         := 0;
92     l_to_loc_id              NUMBER         := 0;
93 -- Increased lot size to 80 Char - Mercy Thomas - B4625329
94     l_lot_number             VARCHAR2(80);
95     l_expiration_date        DATE;
96     l_transaction_temp_id    NUMBER;
97     l_txn_header_id          NUMBER;
98     l_serial_flag            VARCHAR2(1);
99 
100     l_pick_slip_no           NUMBER;
101     l_prev_header_id         NUMBER         := 0;
102     l_req_msg                VARCHAR2(30)   := NULL;
103 
104     /*CURSOR c_move_order_lines IS
105       SELECT mtrh.header_id
106            , mtrh.move_order_type
107            , mtrl.line_id
108            , mtrl.inventory_item_id
109            , mtrl.to_account_id
110            , mtrl.project_id
111            , mtrl.task_id
112         FROM mtl_txn_request_lines mtrl
113            , mtl_txn_request_headers mtrh
114        WHERE mtrl.line_status IN (3, 7)
115          AND mtrh.organization_id = p_org_id
116          AND (p_move_order_from IS NULL OR mtrh.request_number >= p_move_order_from)
117          AND (p_move_order_to IS NULL OR mtrh.request_number <= p_move_order_to)
118          AND (    (p_move_order_type = 99 AND mtrh.move_order_type IN (1,2,3,5))
119                OR (p_move_order_type = 1  AND mtrh.move_order_type = 3)
120                OR (p_move_order_type = 2  AND mtrh.move_order_type = 5)
121                OR (p_move_order_type = 4  AND mtrh.move_order_type IN (1,2))
122              )
123          AND mtrl.header_id = mtrh.header_id
124          AND mtrl.organization_id = p_org_id
125          AND mtrl.quantity > NVL(mtrl.quantity_detailed, 0)
126          AND (p_requested_by IS NULL OR mtrl.created_by = p_requested_by)
127          AND (p_source_subinv IS NULL OR mtrl.from_subinventory_code = p_source_subinv)
128          AND (p_source_locator_id IS NULL OR mtrl.from_locator_id = p_source_locator_id)
129          AND (p_dest_subinv IS NULL OR mtrl.to_subinventory_code = p_dest_subinv)
130          AND (p_dest_locator_id IS NULL OR mtrl.to_locator_id = p_dest_locator_id)
131          AND ((p_sales_order_from IS NULL AND p_sales_order_to IS NULL AND p_customer_id IS NULL AND p_freight_code IS NULL)
132                OR EXISTS (SELECT 1
133                             FROM wsh_delivery_details wdd
134                            WHERE wdd.organization_id = p_org_id
135                              AND wdd.move_order_line_id = mtrl.line_id
136                              AND (p_sales_order_from IS NULL OR wdd.source_header_number >= p_sales_order_from)
137                              AND (p_sales_order_to IS NULL OR wdd.source_header_number <= p_sales_order_to)
138                              AND (p_customer_id IS NULL OR wdd.customer_id = p_customer_id)
139                              AND (p_freight_code IS NULL OR wdd.ship_method_code = p_freight_code))
140               )
141        ORDER BY mtrl.header_id; Commented for bug 3772012 */
142 
143     CURSOR c_move_order_lines (l_header_id NUMBER, l_move_order_type NUMBER,
144                                l_profile_value NUMBER /* Added to fix Bug# 4003379 */) IS
145       SELECT l_header_id header_id
146            , l_move_order_type move_order_type
147            , mtrl.line_id
148            , mtrl.inventory_item_id
149            , mtrl.to_account_id
150            , mtrl.project_id
151            , mtrl.task_id
152            , mtrl.quantity_detailed
153         FROM mtl_txn_request_lines mtrl
154        WHERE mtrl.line_status IN (3, 7)
155          AND mtrl.organization_id = p_org_id
156          AND mtrl.header_id =  l_header_id
157          AND mtrl.quantity > NVL(mtrl.quantity_detailed, 0)
158          AND (p_requested_by IS NULL OR mtrl.created_by = p_requested_by)
159          AND (p_source_subinv IS NULL OR mtrl.from_subinventory_code = p_source_subinv)
160          AND (p_source_locator_id IS NULL OR mtrl.from_locator_id = p_source_locator_id)
161          AND (p_dest_subinv IS NULL OR mtrl.to_subinventory_code = p_dest_subinv)
162          AND (p_dest_locator_id IS NULL OR mtrl.to_locator_id = p_dest_locator_id)
163          AND (p_date_reqd_from IS NULL OR mtrl.date_required >= p_date_reqd_from) /* Added to fix Bug# 4078103 */
164  --bug 6850379
165          AND (p_date_reqd_to IS NULL OR (mtrl.date_required <= trunc(p_date_reqd_to+1)-0.00001))    /* Added to fix Bug# 4078103 */
166  --bug 6850379
167          AND ((p_sales_order_from IS NULL AND p_sales_order_to IS NULL AND p_customer_id IS NULL AND p_freight_code IS NULL)
168                OR EXISTS (SELECT 1
169                             FROM wsh_delivery_details wdd
170                            WHERE wdd.organization_id = p_org_id
171                              AND wdd.move_order_line_id = mtrl.line_id
172                              AND (p_sales_order_from IS NULL OR wdd.source_header_number >= p_sales_order_from)
173                              AND (p_sales_order_to IS NULL OR wdd.source_header_number <= p_sales_order_to)
174                              AND (p_customer_id IS NULL OR wdd.customer_id = p_customer_id)
175                              AND (p_freight_code IS NULL OR wdd.ship_method_code = p_freight_code))
176               )
177          AND NVL(mtrl.request_id, 0) < p_request_id
178              /* Added to fix Bug# 4003379; If the record does not have any request_id or
179                 it is less than current request_id that means- that record has not been
180                 processed by this request so select that record for processing. */
181          AND rownum < l_profile_value +1
182              /* Added to fix Bug# 4003379; ROWNUM is introduced to fetch and lock only
183                 that many records which has to be processed in a single go based on the
184                 value of the 'INV: Pick Slip Batch Size' profile. */
185        FOR UPDATE OF mtrl.quantity_detailed NOWAIT; -- Added 3772012
186 
187     CURSOR c_move_order_header IS
188       SELECT mtrh.header_id
189            , mtrh.move_order_type
190         FROM mtl_txn_request_headers mtrh
191        WHERE mtrh.organization_id = p_org_id
192          AND (p_move_order_from IS NULL OR mtrh.request_number >= p_move_order_from)
193          AND (p_move_order_to IS NULL OR mtrh.request_number <= p_move_order_to)
194          AND (    (p_move_order_type = 99 AND mtrh.move_order_type IN (1,2,3,5))
195                OR (p_move_order_type = 1  AND mtrh.move_order_type = 3)
196                OR (p_move_order_type = 2  AND mtrh.move_order_type = 5)
197 	       OR (p_move_order_type = 3  AND mtrh.move_order_type = 5) --Bug #4700988 MFG Pick
198                OR (p_move_order_type = 4  AND mtrh.move_order_type IN (1,2))
199              );
200 
201     CURSOR c_mmtt(p_mo_line_id NUMBER) IS
202       SELECT transaction_temp_id
203            , subinventory_code
204            , locator_id
205            , transfer_subinventory
206            , transfer_to_location
207            , revision
208         FROM mtl_material_transactions_temp
209        WHERE move_order_line_id = p_mo_line_id
210          AND pick_slip_number IS NULL;
211 
212     l_debug NUMBER;
213     record_locked EXCEPTION; -- bug 3772012
214     PRAGMA EXCEPTION_INIT(record_locked, -54); -- bug 3772012
215     v_mo_line_rec c_move_order_lines%ROWTYPE;
216   BEGIN
217     /* Initializing the default values */
218     l_api_name := 'RUN_DETAIL_ENGINE';
219     l_serial_flag := 'F';
220     l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
221 
222     IF l_debug = 1 THEN
223       mydebug('Running Detail Engine with Parameters...', l_api_name);
224       mydebug('  Organization ID     = ' || p_org_id, l_api_name);
225       mydebug('  Move Order Type     = ' || p_move_order_type, l_api_name);
226       mydebug('  Move Order From     = ' || p_move_order_from, l_api_name);
227       mydebug('  Move Order To       = ' || p_move_order_to, l_api_name);
228       mydebug('  Source Subinventory = ' || p_source_subinv, l_api_name);
229       mydebug('  Source Locator      = ' || p_source_locator_id, l_api_name);
230       mydebug('  Dest Subinventory   = ' || p_dest_subinv, l_api_name);
231       mydebug('  Dest Locator        = ' || p_dest_locator_id, l_api_name);
232       mydebug('  Sales Order From    = ' || p_sales_order_from, l_api_name);
233       mydebug('  Sales Order To      = ' || p_sales_order_to, l_api_name);
234       mydebug('  Freight Code        = ' || p_freight_code, l_api_name);
235       mydebug('  Customer ID         = ' || p_customer_id, l_api_name);
236       mydebug('  Requested By        = ' || p_requested_by, l_api_name);
237       mydebug('  Date Required From  = ' || p_date_reqd_from, l_api_name);
238       mydebug('  Date Required To    = ' || p_date_reqd_to, l_api_name);
239       mydebug('  PickSlip Group Rule = ' || p_pick_slip_group_rule_id, l_api_name);
240       mydebug('  Request ID          = ' || p_request_id, l_api_name);
241     END IF;
242 
243     l_max_batch   := TO_NUMBER(fnd_profile.VALUE('INV_PICK_SLIP_BATCH_SIZE'));
244 
245     IF (l_debug = 1) THEN
246       mydebug('Maximum Batch Size = ' || l_max_batch, l_api_name);
247     END IF;
248 
249     IF l_max_batch IS NULL OR l_max_batch <= 0 THEN
250       l_max_batch  := 20;
251 
252       IF (l_debug = 1) THEN
253         mydebug('Using Default Batch Size 20', l_api_name);
254       END IF;
255     END IF;
256 
257     l_batch_size  := 0;
258 
259     --device integration starts
260     IF (inv_install.adv_inv_installed(p_org_id) = TRUE) THEN --for WMS org
261        IF wms_device_integration_pvt.wms_call_device_request IS NULL THEN
262 
263     IF (l_debug = 1) THEN
264        mydebug('Setting global variable for device integration call', l_api_name);
265     END IF;
266     wms_device_integration_pvt.is_device_set_up(p_org_id,wms_device_integration_pvt.WMS_BE_MO_TASK_ALLOC,x_return_status);
267        END IF;
268     END IF;
269     --device integration end
270 
271     FOR v_mo_header_rec IN c_move_order_header LOOP  -- Added 3772012
272     BEGIN
273 /*    FOR v_mo_line_rec IN c_move_order_lines(v_mo_header_rec.header_id, v_mo_header_rec.move_order_type) LOOP */
274      --Start of new code to fix Bug# 4003379
275      OPEN c_move_order_lines(v_mo_header_rec.header_id,
276                              v_mo_header_rec.move_order_type,
277                              l_max_batch); /* Changed from FOR loop Bug# 4003379 */
278        LOOP
279          FETCH c_move_order_lines INTO v_mo_line_rec;
280          IF c_move_order_lines%NOTFOUND THEN
281            CLOSE c_move_order_lines;
282            COMMIT;
283            l_batch_size := 0;
284            EXIT;
285          END IF;
286      --END of new code added to fix Bug# 4003379
287          l_batch_size       := l_batch_size + 1;
288          IF v_mo_line_rec.header_id <> l_prev_header_id THEN
289            l_prev_header_id := v_mo_line_rec.header_id;
290            IF p_pick_slip_group_rule_id IS NOT NULL AND v_mo_line_rec.move_order_type IN (1,2) THEN
291              IF l_debug = 1 THEN
292                mydebug('New Header ID... So updating Pick Slip Grouping Rule', l_api_name);
293              END IF;
294              UPDATE mtl_txn_request_headers
295              SET grouping_rule_id = p_pick_slip_group_rule_id
296              WHERE header_id = v_mo_line_rec.header_id;
297            END IF;
298          END IF;
299 
300          SELECT decode(serial_number_control_code, 1, 'F', 'T') INTO l_serial_flag
301          FROM mtl_system_items
302          WHERE inventory_item_id = v_mo_line_rec.inventory_item_id
303          AND organization_id = p_org_id;
304 
305          SELECT mtl_material_transactions_s.NEXTVAL INTO l_txn_header_id FROM DUAL;
306 
307          inv_replenish_detail_pub.line_details_pub(
308            x_return_status              => x_return_status
309            , x_msg_count                  => l_msg_count
310            , x_msg_data                   => l_msg_data
311            , x_number_of_rows             => l_num_of_rows
312            , x_detailed_qty               => l_detailed_qty
313            , x_detailed_qty2              => l_secondary_detailed_qty --INVCONV
314            , x_revision                   => l_revision
315            , x_locator_id                 => l_from_loc_id
316            , x_transfer_to_location       => l_to_loc_id
317            , x_lot_number                 => l_lot_number
318            , x_expiration_date            => l_expiration_date
319            , x_transaction_temp_id        => l_transaction_temp_id
320            , p_line_id                    => v_mo_line_rec.line_id
321            , p_transaction_header_id      => l_txn_header_id
322            , p_transaction_mode           => NULL
323            , p_move_order_type            => v_mo_line_rec.move_order_type
324            , p_serial_flag                => l_serial_flag
325            , p_plan_tasks                 => p_plan_tasks
326            , p_auto_pick_confirm          => FALSE
327            );
328 
329          --Bug #4155230
330          UPDATE mtl_txn_request_lines
331          SET quantity_detailed = (NVL(quantity_delivered, 0) + l_detailed_qty),
332              secondary_quantity_detailed = decode(l_secondary_detailed_qty, 0, NULL, l_secondary_detailed_qty), --INVCONV
333              request_id = p_request_id /* Added the updation of request_id to fix Bug# 4003379 */
334          WHERE line_id = v_mo_line_rec.line_id
335          AND organization_id = p_org_id;
336 
337          IF l_debug = 1 THEN
338            mydebug('Allocated MO Line = ' || v_mo_line_rec.line_id || ' : Qty Detailed = ' || l_detailed_qty, l_api_name);
339          END IF;
340 
341          IF p_pick_slip_group_rule_id IS NOT NULL AND v_mo_line_rec.move_order_type IN (1,2) THEN
342            -- Looping for each allocation of the MO Line for which Pick Slip Number is not stamped.
343            FOR v_mmtt IN c_mmtt(v_mo_line_rec.line_id) LOOP
344              inv_pr_pick_slip_number.get_pick_slip_number(
345                x_api_status                 => x_return_status
346              , x_error_message              => l_msg_data
347              , x_pick_slip_number           => l_pick_slip_no
348              , p_pick_grouping_rule_id      => p_pick_slip_group_rule_id
349              , p_org_id                     => p_org_id
350              , p_inventory_item_id          => v_mo_line_rec.inventory_item_id
351              , p_revision                   => v_mmtt.revision
352              , p_lot_number                 => NULL
353              , p_src_subinventory           => v_mmtt.subinventory_code
354              , p_src_locator_id             => v_mmtt.locator_id
355              , p_supply_subinventory        => v_mmtt.transfer_subinventory
356              , p_supply_locator_id          => v_mmtt.transfer_to_location
357              , p_project_id                 => v_mo_line_rec.project_id
358              , p_task_id                    => v_mo_line_rec.task_id
359              , p_wip_entity_id              => NULL
360              , p_rep_schedule_id            => NULL
361              , p_operation_seq_num          => NULL
362              , p_dept_id                    => NULL
363              , p_push_or_pull               => NULL
364              );
365 
366              UPDATE mtl_material_transactions_temp
367              SET pick_slip_number = l_pick_slip_no
368              WHERE transaction_temp_id = v_mmtt.transaction_temp_id;
369            END LOOP;
370          END IF;
371 
372       /*Bug#5140639. Commented the updation of 'distribution_account_id' in MMTT as
373          it is already done in 'INV_Replenish_Detail_PUB.Line_Details_PUB' */
374 
375 	/* IF v_mo_line_rec.to_account_id IS NOT NULL THEN
376            UPDATE mtl_material_transactions_temp
377            SET distribution_account_id = v_mo_line_rec.to_account_id
378            WHERE move_order_line_id = v_mo_line_rec.line_id;
379          END IF;*/
380 
381          IF l_batch_size >= l_max_batch THEN
382            IF (l_debug = 1) THEN
383              mydebug('Current Batch Completed... Committing.',l_api_name);
384            END IF;
385            IF c_move_order_lines%ISOPEN THEN  --Added to fix Bug# 4003379
386              CLOSE c_move_order_lines;
387            END IF;
388            COMMIT;
389            OPEN c_move_order_lines(v_mo_header_rec.header_id,
390                                    v_mo_header_rec.move_order_type,
391                                    l_max_batch); --Changed from FOR loop bug 4003379
392 
393            l_batch_size  := 0;
394          END IF;
395        END LOOP;
396      EXCEPTION -- Added 3772012
397        WHEN record_locked THEN
398          fnd_message.set_name('INV', 'INV_MO_LOCKED_SO');
399          IF (l_debug = 1 ) THEN
400            inv_log_util.TRACE('Lines for header '||v_mo_header_rec.header_id||' are locked', 'INV_UTILITIES', 9);
401          END IF;
402          fnd_msg_pub.ADD;
403        END;
404     END LOOP;
405 
406     IF (l_debug = 1) THEN
407       inv_log_util.TRACE('calling Device Integration',l_api_name);
408     END IF;
409     -- Call Device Integration API to send the details of this
410     -- PickRelease Wave for Move Order Allocation to devices, if it is a WMS organization.
411     -- Note: We don't check for the return condition of this API as
412     -- we let the Move Order Allocation  process succeed
413     -- irrespective of DeviceIntegration succeed or fail.
414     IF (wms_install.check_install(
415       x_return_status   => x_return_status,
416       x_msg_count       => l_msg_count,
417       x_msg_data        => l_msg_data,
418       p_organization_id => p_org_id
419       ) = TRUE  ) THEN
420        wms_device_integration_pvt.device_request(
421          p_bus_event      => WMS_DEVICE_INTEGRATION_PVT.WMS_BE_MO_TASK_ALLOC,
422          p_call_ctx       => WMS_Device_integration_pvt.DEV_REQ_AUTO,
423          p_task_trx_id    => NULL,
424          x_request_msg    => l_req_msg,
425          x_return_status  => x_return_status,
426          x_msg_count      => l_msg_count,
427          x_msg_data       => l_msg_data);
428 
429        IF (l_debug = 1) THEN
430          inv_log_util.TRACE('Device_API: returned status:'||x_return_status, l_api_name);
431        END IF;
432     END IF;
433 
434     IF c_move_order_lines%ISOPEN THEN  --Added to fix Bug# 4003379
435       CLOSE c_move_order_lines;
436     END IF;
437 
438     COMMIT;
439   EXCEPTION
440     WHEN OTHERS THEN
441       x_return_status := fnd_api.g_ret_sts_unexp_error;
442       IF c_move_order_lines%ISOPEN THEN  --Added to fix Bug# 4003379
443         CLOSE c_move_order_lines;
444       END IF;
445   END run_detail_engine;
446 
447   FUNCTION print_pick_slip(
448     p_organization_id         VARCHAR2
449   , p_move_order_from         VARCHAR2
450   , p_move_order_to           VARCHAR2
451   , p_pick_slip_number_from   VARCHAR2
452   , p_pick_slip_number_to     VARCHAR2
453   , p_source_subinv           VARCHAR2
454   , p_source_locator          VARCHAR2
455   , p_dest_subinv             VARCHAR2
456   , p_dest_locator            VARCHAR2
457   , p_requested_by            VARCHAR2
458   , p_date_reqd_from          VARCHAR2
459   , p_date_reqd_to            VARCHAR2
460   , p_print_option            VARCHAR2
461   , p_print_mo_type           VARCHAR2
462   , p_sales_order_from        VARCHAR2
463   , p_sales_order_to          VARCHAR2
464   , p_ship_method_code        VARCHAR2
465   , p_customer_id             VARCHAR2
466   , p_auto_allocate           VARCHAR2
467   , p_plan_tasks              VARCHAR2
468   , p_pick_slip_group_rule_id VARCHAR2
469   ) RETURN NUMBER IS
470     l_msg_data   VARCHAR2(1000);
471     l_msg_count  NUMBER;
472     l_api_name   VARCHAR2(30);
473     l_debug      NUMBER;
474     l_request_id NUMBER;
475   BEGIN
476     /* Initializing the default values */
477     l_api_name := 'PRINT_PICK_SLIP';
478     l_debug := NVL(fnd_profile.VALUE('INV_DEBUG_TRACE'), 0);
479 
480     l_request_id  := fnd_request.submit_request(
481                        application => 'INV'
482                      , program     => 'INVTOPKL'
483                      , description => NULL
484                      , start_time  => NULL
485                      , sub_request => FALSE
486                      , argument1   => p_organization_id
487                      , argument2   => p_move_order_from
488                      , argument3   => p_move_order_to
489                      , argument4   => p_pick_slip_number_from
490                      , argument5   => p_pick_slip_number_to
491                      , argument6   => p_source_subinv
492                      , argument7   => p_source_locator
493                      , argument8   => p_dest_subinv
494                      , argument9   => p_dest_locator
495                      , argument10  => p_requested_by
496                      , argument11  => p_date_reqd_from
497                      , argument12  => p_date_reqd_to
498                      , argument13  => p_print_option
499                      , argument14  => p_print_mo_type
500                      , argument15  => p_sales_order_from
501                      , argument16  => p_sales_order_to
502                      , argument17  => p_ship_method_code
503                      , argument18  => p_customer_id
504                      , argument19  => p_auto_allocate
505                      , argument20  => p_plan_tasks
506                      , argument21  => p_pick_slip_group_rule_id
507                      );
508 
509     IF l_debug = 1 THEN
510       mydebug('Request ID = ' || l_request_id, l_api_name);
511     END IF;
512 
513     IF l_request_id = 0 THEN
514        fnd_msg_pub.count_and_get(p_encoded=>fnd_api.g_false,p_data=>l_msg_data, p_count=>l_msg_count);
515        IF l_debug = 1 THEN
516          mydebug('Unable to submit the MO Pick Slip Request - ' || l_msg_data, l_api_name);
517        END IF;
518     END IF;
519 
520     RETURN l_request_id;
521   END print_pick_slip;
522 
523 END inv_pick_slip_report;