1 PACKAGE BODY RCV_SHIPMENT_LINE_SV AS
2 /* $Header: RCVTHCB.pls 115.4 2004/06/30 23:55:42 wkunz ship $ */
3
4 -- Read the profile option that enables/disables the debug log
5 g_asn_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('RCV_DEBUG_MODE'),'N');
6
7 /*===========================================================================+
8 | |
9 | PROCEDURE NAME: create_shipment_line() |
10 | |
11 +===========================================================================*/
12
13 PROCEDURE create_shipment_line
14 (X_cascaded_table IN OUT NOCOPY rcv_shipment_object_sv.cascaded_trans_tab_type,
15 n IN OUT NOCOPY binary_integer,
16 X_header_id IN rcv_headers_interface.header_interface_id%type,
17 X_asn_type IN rcv_headers_interface.asn_type%type,
18 V_header_record IN OUT NOCOPY rcv_shipment_header_sv.headerrectype) IS
19
20 x_parent_id number;
21 X_progress varchar2(3);
22 X_error_record rcv_shipment_object_sv.errorrectype;
23 x_start_indice binary_integer := null;
24 i binary_integer := null;
25 used_for_cascaded_rows rcv_shipment_object_sv.cascaded_trans_tab_type;
26
27
28 BEGIN
29
30 IF (g_asn_debug = 'Y') THEN
31 ASN_DEBUG.PUT_LINE('Enter create shipment line');
32 END IF;
33
34 IF (g_asn_debug = 'Y') THEN
35 ASN_DEBUG.PUT_LINE('Initialize the table structure used for storing the cascaded rows');
36 END IF;
37
38 -- delete all records from used_for_cascaded_rows
39
40 for m in 1..used_for_cascaded_rows.count loop
41
42 used_for_cascaded_rows.delete(m);
43
44 end loop;
45
46 X_progress := '000';
47 x_start_indice := n;
48
49 -- derive IDs and also explode rows
50
51 rcv_transactions_interface_sv.derive_shipment_line (X_cascaded_table, n, used_for_cascaded_rows, V_header_record);
52
53 IF (g_asn_debug = 'Y') THEN
54 ASN_DEBUG.PUT_LINE('Back from derive routine with ' || to_char(used_for_cascaded_rows.count) || ' rows');
55 ASN_DEBUG.PUT_LINE('Error Status ' || x_cascaded_table(n).error_status);
56 ASN_DEBUG.PUT_LINE('Error Message ' || x_cascaded_table(n).error_message);
57 END IF;
58
59 X_progress := '010';
60
61 if (X_cascaded_table(n).error_status in ('S','W')) and
62 used_for_cascaded_rows.count > 0 then -- we have returned with a cascaded table
63
64 for i in 1..used_for_cascaded_rows.count loop
65
66 IF (g_asn_debug = 'Y') THEN
67 ASN_DEBUG.PUT_LINE('Defaulting for cascaded row ' || to_char(i));
68 END IF;
69 rcv_transactions_interface_sv.default_shipment_line (used_for_cascaded_rows, i, X_header_id, V_header_record);
70
71 X_progress := '020';
72
73 used_for_cascaded_rows(i).error_status := 'S';
74 used_for_cascaded_rows(i).error_message := null;
75
76 rcv_transactions_interface_sv.validate_shipment_line (used_for_cascaded_rows, i, X_asn_type, V_header_record);
77
78 X_progress := '030';
79
80 if (used_for_cascaded_rows(i).error_status not in ('S','W')) then
81 used_for_cascaded_rows(i).processing_status_code := 'ERROR';
82 X_cascaded_table(n).processing_status_code := 'ERROR';
83 X_cascaded_table(n).error_status := used_for_cascaded_rows(i).error_status;
84 X_cascaded_table(n).error_message := used_for_cascaded_rows(i).error_message;
85
86 IF (g_asn_debug = 'Y') THEN
87 ASN_DEBUG.PUT_LINE('Have hit error condition in validation');
88 ASN_DEBUG.PUT_LINE('Mark needed flags and error message');
89 ASN_DEBUG.PUT_LINE('Delete the cascaded rows');
90 END IF;
91
92 for j in 1..used_for_cascaded_rows.count loop
93
94 used_for_cascaded_rows.delete(j);
95
96 end loop;
97
98 exit;
99 end if;
100
101 end loop;
102
103 IF X_cascaded_table(n).processing_status_code = 'ERROR' THEN
104
105 IF (g_asn_debug = 'Y') THEN
106 ASN_DEBUG.PUT_LINE('Have hit error condition in validation');
107 ASN_DEBUG.PUT_LINE('Mark needed flags and error message');
108 ASN_DEBUG.PUT_LINE('Delete the cascaded rows');
109 END IF;
110
111 for j in 1..used_for_cascaded_rows.count loop
112
113 used_for_cascaded_rows.delete(j);
114
115 end loop;
116
117 ELSE
118
119 IF (g_asn_debug = 'Y') THEN
120 ASN_DEBUG.PUT_LINE('Have finished default and validation');
121 ASN_DEBUG.PUT_LINE('Process has encountered no fatal errors');
122 ASN_DEBUG.PUT_LINE('Will write the cascaded rows into actual table');
123 ASN_DEBUG.PUT_LINE('Count of cascaded rows ' || to_char(used_for_cascaded_rows.count));
124 END IF;
125
126 for j in 1..used_for_cascaded_rows.count loop
127
128 IF (g_asn_debug = 'Y') THEN
129 ASN_DEBUG.PUT_LINE('Current counter in actual table is at ' || to_char(n));
130 END IF;
131 X_cascaded_table(n) := used_for_cascaded_rows(j);
132 used_for_cascaded_rows.delete(j);
133 n := n + 1;
134
135 end loop;
136
137 IF (g_asn_debug = 'Y') THEN
138 ASN_DEBUG.PUT_LINE('Current counter before decrementing in actual table is at ' || to_char(n));
139 END IF;
140 n := n -1; -- Get the counter in sync
141 IF (g_asn_debug = 'Y') THEN
142 ASN_DEBUG.PUT_LINE('Current counter in actual table is at ' || to_char(n));
143 END IF;
144
145 END IF;
146
147
148 else
149 X_cascaded_table(n).processing_status_code := 'ERROR'; -- changed (i) -> (n)
150 return;
151 end if;
152
153 IF (g_asn_debug = 'Y') THEN
154 ASN_DEBUG.PUT_LINE('Exit create shipment line');
155 END IF;
156
157 END create_shipment_line;
158
159 END RCV_SHIPMENT_LINE_SV;
160