code128b條碼生成程式
阿新 • • 發佈:2019-02-13
FUNCTIONget_char(char_codeINPLS_INTEGER)RETURNVARCHAR2IS
LANGUAGEJAVANAME'xxfnd.XxfndBarcodeUtil.getChar(int)
return String';
FUNCTIONcode128b(data_to_encodeINVARCHAR2)RETURNVARCHAR2IS
v_c128_start VARCHAR2(3);
v_c128_end VARCHAR2(3);
n_checksum PLS_INTEGER:=104;
n_data_length PLS_INTEGER;
n_curr_char_codePLS_INTEGER;
BEGIN
--
Save the length of the content to cache.
n_data_length := length(data_to_encode);
fnd_message.set_name('CUX','CUX_FND_BARCODE_001');
v_c128_start := fnd_message.get;
fnd_message.set_name('CUX','CUX_FND_BARCODE_002');
v_c128_end := fnd_message.get;
FORiIN1..
n_data_lengthLOOP
n_curr_char_code := ascii(substr(data_to_encode, i,1));
IFn_curr_char_code
>=32THEN
n_checksum := n_checksum +
(i * (ascii(substr(data_to_encode, i,1))
-32));
ELSE
n_checksum := n_checksum +
(i * (ascii(substr(data_to_encode, i, 1))
+64));
ENDIF;
ENDLOOP;
n_checksum :=MOD(n_checksum,103);
IFn_checksum
<95THEN
n_checksum := n_checksum +32;
ELSE
n_checksum := n_checksum +100;
ENDIF;
RETURNv_c128_start
|| data_to_encode || get_char(n_checksum) || v_c128_end;
ENDcode128b;