FUNCTION
get_char(char_code
IN
PLS_INTEGER
)
RETURN
VARCHAR2
IS
LANGUAGE
JAVA
NAME
'xxfnd.XxfndBarcodeUtil.getChar(int) return String'
;
FUNCTION
code128b(data_to_encode
IN
VARCHAR2
)
RETURN
VARCHAR2
IS
v_c128_start
VARCHAR2
(
3
);
v_c128_end
VARCHAR2
(
3
);
n_checksum
PLS_INTEGER
:=
104
;
n_data_length
PLS_INTEGER
;
n_curr_char_code
PLS_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;
FOR
i
IN
1
.. n_data_length
LOOP
n_curr_char_code := ascii(substr(data_to_encode, i,
1
));
IF
n_curr_char_code >=
32
THEN
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
));
END
IF
;
END
LOOP
;
n_checksum :=
MOD
(n_checksum,
103
);
IF
n_checksum <
95
THEN
n_checksum := n_checksum +
32
;
ELSE
n_checksum := n_checksum +
100
;
END
IF
;
RETURN
v_c128_start || data_to_encode || get_char(n_checksum) || v_c128_end;
END
code128b;