1 PACKAGE BODY WMS_BARCODE_STUB AS
2 /* $Header: WMSBARCB.pls 115.2 2002/06/13 04:02:06 pkm ship $ */
3
4
5 -- ---------------------------------------------------------------------------------------------------------
6 -- Function: Start_Digit
7 --
8 -- Parameters: 1) BarCode Type
9 -- 2) BarCode font name
10 --
11 -- Description: This Function assigns the Start Character for a specific barcode type
12 --
13 -- ---------------------------------------------------------------------------------------------------------
14
15 FUNCTION Start_Digit(
16 p_barcode_type IN VARCHAR2,
17 p_barcode_font_name IN VARCHAR2
18 ) return VARCHAR2 IS
19 l_barcode_sub_type VARCHAR2(20) := 'CODE A';
20 BEGIN
21 IF p_barcode_type = 'CODE 39' THEN
22 return '*';
23 ELSIF p_barcode_type = 'CODE 128' THEN
24 IF l_barcode_sub_type = 'CODE A' THEN
25 return '{';
26 ELSIF l_barcode_sub_type = 'CODE B' THEN
27 return '|';
28 ELSIF l_barcode_sub_type = 'CODE C' THEN
29 return '}';
30 -- can add code for any other type of barcodes here
31 END IF;
32 END IF;
33 END Start_digit;
34 -- ---------------------------------------------------------------------------------------------------------
35 -- Function: Stop_Digit
36 -- Parameters: 1) BarCode Type
37 -- 2) BarCode font name
38 --
39 -- Description: This Function assigns the Stop Character for a barcode font
40 --
41 -- ---------------------------------------------------------------------------------------------------------
42
43 FUNCTION Stop_Digit(
44 p_barcode_type IN VARCHAR2,
45 p_barcode_font_name IN VARCHAR2
46 ) return VARCHAR2 IS
47 l_barcode_sub_type VARCHAR2(20) := 'CODE A';
48 BEGIN
49 IF p_barcode_type = 'CODE 39' THEN
50 return '*';
51 ELSIF p_barcode_type = 'CODE 128' THEN
52 return '~ ';
53 -- can add code for any other type of barcodes here
54 END IF;
55 END Stop_digit;
56
57 -- ---------------------------------------------------------------------------------------------------------
58 -- Function: CheckSum_Digit
59 -- Parameters: 1) BarCode Type
60 -- 2) BarCode font name
61 -- 3) Input Text which needs to be barcoded
62 --
63 -- Description: This Function Calculates the Checksum for a given text and font and returns it
64 --
65 -- ---------------------------------------------------------------------------------------------------------
66
67 FUNCTION Checksum_Digit(
68 p_barcode_type IN VARCHAR2,
69 p_barcode_font_name IN VARCHAR2,
70 p_barcode_text IN VARCHAR2
71 ) return NUMBER IS
72 l_barcode_sub_type VARCHAR2(20) := 'CODE A';
73 BarCodeOut VARCHAR2(1) := '';
74 BarTextOut VARCHAR2(100) := '';
75 TempString VARCHAR2(100) := '';
76 CheckSum number;
77 barcode_text VARCHAR2(100):= RTrim(LTrim(p_barcode_text));
78 Total NUMBER;
79 ThisChar NUMBER;
80 CharValue NUMBER;
81 CheckSumValue NUMBER;
82 Weighting NUMBER;
83 CNT NUMBER;
84 BEGIN
85 IF p_barcode_type = 'CODE 39' THEN
86 return '';
87 ELSIF p_barcode_type = 'CODE 128' THEN
88 /*-----------------------------------------------------------------------------------------------
89 Convert input string to bar code 128 A or B or C format, Pass Subset 'CODE A','CODE B', 'CODE C'
90 ------------------------------------------------------------------------------------------------*/
91
92 -- Set up for the subset we are in
93 IF l_barcode_sub_type IN ('CODE A','CODE B') then
94 If l_barcode_sub_type = 'CODE A' Then
95 Total := 103;
96 Else
97 Total := 104;
98 End If;
99
100 -- Calculate the checksum, mod 103 and build output string
101 For II IN 1..length(barcode_text) loop
102 --Find the ASCII value of the current character
103 ThisChar := (ascii(substr(barcode_text,II,1)));
104 --Calculate the bar code 128 value
105 If ThisChar < 123 Then
106 CharValue := ThisChar - 32;
107 Else
108 CharValue := ThisChar - 70;
109 End If;
110 --add this value to sum for checksum work
111 Total := Total + (CharValue * II);
112 /*
113 --Now work on output string, no spaces in TrueType fonts
114 If substr(barcode_text,II,1) = ' ' Then
115 BarTextOut := BarTextOut || Chr(174);
116 Else
117 BarTextOut := BarTextOut || substr(barcode_text,II,1);
118 End If; */
119 end loop;
120
121 -- Find the remainder when Sum is divided by 103
122 CheckSumValue := Mod(Total,103);
123 -- Translate that value to an ASCII character
124 If CheckSumValue > 90 Then
125 CheckSum := (CheckSumValue + 70);
126 ElsIf CheckSumValue > 0 Then
127 CheckSum := (CheckSumValue + 32);
128 Else
129 CheckSum := (174);
130 End If;
131
132 ELSE
133 -- generate barcode for Subset C
134 -- Throw away non-numeric data
135 TempString := '';
136 For I in 1..length(barcode_text) loop
137 If ((ascii(substr(barcode_text, I, 1))) > 47 and (ascii(substr(barcode_text, I, 1))) < 58) Then
138 TempString := TempString || substr(barcode_text, I, 1);
139 End If;
140 end loop;
141
142 -- If not an even number of digits, add a leading 0
143 If (Length(TempString) Mod 2) = 1 Then
144 TempString := '0' || TempString;
145 End If;
146
147 Total := 105;
148 Weighting := 1;
149
150 -- Calculate the checksum, mod 103 and build output string
151 CNT := 1;
152 while (CNT <= length(TempString)) loop
153 --Break string into pairs of digits and get value
154 CharValue := substr(TempString, CNT, 2);
155 --Multiply value times weighting and add to sum
156 Total := Total + (CharValue * Weighting);
157 Weighting := Weighting + 1;
158 /*
159 --translate value to ASCII and save in BarTextOut
160 If CharValue < 90 Then
161 BarTextOut := BarTextOut || Chr(CharValue + 33);
162 ElsIf CharValue < 171 Then
163 BarTextOut := BarTextOut || Chr(CharValue + 71);
164 Else
165 BarTextOut := BarTextOut || Chr(CharValue + 76);
166 End If; */
167 CNT := CNT + 2;
168 end loop;
169
170 -- Find the remainder when Sum is divided by 103
171 CheckSumValue := (Total Mod 103);
172 -- Translate that value to an ASCII character
173 If CheckSumValue < 90 Then
174 CheckSum := (CheckSumValue + 33);
175 ElsIf CheckSumValue < 100 Then
176 CheckSum := (CheckSumValue + 71);
177 Else
178 CheckSum := (CheckSumValue + 76);
179 End If;
180
181 End if;
182
183 --BarCodeOut := CheckSum;
184
185 --Return the string
186 return(CheckSum);
187 END IF;
188 END CheckSum_digit;
189
190 -- ---------------------------------------------------------------------------------------------------------
191 -- Function: Additional_CheckSum_Digit
192 -- Parameters: 1) BarCode Type
193 -- 2) BarCode font name
194 -- 3) Input Text which needs to be barcoded
195 --
196 -- Description: This Function Calculates the Optional Second Checksum for a given text and font and returns it
197 --
198 -- ---------------------------------------------------------------------------------------------------------
199
200 FUNCTION Additional_CheckSum_digit(
201 p_barcode_type IN VARCHAR2,
202 p_barcode_font_name IN VARCHAR2,
203 p_barcode_text IN VARCHAR2
204 ) return NUMBER IS
205 l_barcode_sub_type VARCHAR2(20) := 'CODE A';
206 BEGIN
207 -- add code here to generate additional checksum digits if the barcode type
208 -- requires more than one checksum digit
209 return null;
210 END Additional_CheckSum_digit;
211
212 -- ---------------------------------------------------------------------------------------------------------
213 -- Function: Carriage_return
214 -- Parameters: 1) BarCode Type
215 -- 2) BarCode font name
216 --
217 -- Description: This Function returns the Carriage return string for a barcode font.
218 --
219 -- ---------------------------------------------------------------------------------------------------------
220
221 FUNCTION Carriage_return(
222 p_barcode_type IN VARCHAR2,
223 p_barcode_font_name IN VARCHAR2
224 ) return VARCHAR2 IS
225 l_barcode_sub_type VARCHAR2(20) := 'CODE A';
226 BEGIN
227 IF p_barcode_type = 'CODE 39' THEN
228 return '*'||fnd_global.local_chr(10)||fnd_global.local_chr(10)||'*';
229 ELSIF p_barcode_type = 'CODE 128' THEN
230 IF l_barcode_sub_type = 'CODE A' THEN
231 return 'm';
232 ELSIF l_barcode_sub_type = 'CODE B' THEN
233 return (fnd_global.local_chr(171)||'m');
234 ELSIF l_barcode_sub_type = 'CODE C' THEN
235 return fnd_global.local_chr(10);
236 END IF;
237 END IF;
238 END Carriage_return;
239
240
241 END WMS_BARCODE_STUB;