0% found this document useful (0 votes)
17 views5 pages

BARCODE Cod

The document outlines the function Z_F_BARCODE128_REDTITAN, which generates a barcode sequence based on the provided barcode type and text input. It includes error handling for various exceptions such as nonexistent barcodes, invalid characters, and CRC computation errors. The function processes the input to construct a valid barcode sequence by verifying the barcode type, calculating the CRC, and appending start and stop sequences.

Uploaded by

Roger Sudati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

BARCODE Cod

The document outlines the function Z_F_BARCODE128_REDTITAN, which generates a barcode sequence based on the provided barcode type and text input. It includes error handling for various exceptions such as nonexistent barcodes, invalid characters, and CRC computation errors. The function processes the input to construct a valid barcode sequence by verifying the barcode type, calculating the CRC, and appending start and stop sequences.

Uploaded by

Roger Sudati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

FUNCTION Z_F_BARCODE128_REDTITAN.

*"----------------------------------------------------------------------
*"*"Interface local:
*" IMPORTING
*" VALUE(TYPEBC) LIKE ZZE17-ZTYPBC
*" VALUE(TEXT) TYPE C
*" EXPORTING
*" VALUE(SEQUENCE) TYPE C
*" EXCEPTIONS
*" BARCODE_INEXISTANT
*" CARACTER_NOT_ALLOWED
*" ERROR_COMPUTING_CRC
*" WRONG_DATA_TYPE
*" DATA_TOO_LONG
*"----------------------------------------------------------------------
CLEAR : T_TRAV, W_CRC, SEQUENCE.
REFRESH : T_TRAV.

* Verification of Barcode type in table ZZE17


SELECT SINGLE * FROM ZZE17
WHERE ZTYPBC EQ TYPEBC.
IF SY-SUBRC NE 0.
RAISE BARCODE_INEXISTANT.
ENDIF.

* Verification of Barcode type in table ZZE16


* and reading of ZZE16 for barcode type
SELECT * FROM ZZE16 INTO TABLE T_ZZE16
WHERE ZTYPBC EQ TYPEBC.
IF SY-SUBRC NE 0.
RAISE BARCODE_INEXISTANT.
ENDIF.

* insertion of the START sequence


READ TABLE T_ZZE16 WITH KEY ZTYPBC = TYPEBC
ZCARACT = K_START.
IF SY-SUBRC NE 0.
RAISE CARACTER_NOT_ALLOWED.
ENDIF.
T_TRAV-CAR = K_START.
T_TRAV-VAL = T_ZZE16-ZVALEUR.
T_TRAV-COD = T_ZZE16-ZCODAGE.
APPEND T_TRAV.

CASE TYPEBC.
WHEN K_128A.
PERFORM TRAIT_128A USING TYPEBC TEXT.
WHEN K_128B.
PERFORM TRAIT_128B USING TYPEBC TEXT.
WHEN K_128C.
PERFORM TRAIT_128C USING TYPEBC TEXT.
WHEN OTHERS.

ENDCASE.

* Compute the Coding Value (=CRC)


LOOP AT T_TRAV.
IF T_TRAV-CAR = K_START.
W_CRC = T_TRAV-VAL.
ELSE.
W_POIDS = SY-TABIX - 1.
W_CRC = W_CRC + T_TRAV-VAL * W_POIDS.
ENDIF.
ENDLOOP.
W_CRC = W_CRC MOD 103.

* Insertion of the CRC value


READ TABLE T_ZZE16 WITH KEY ZTYPBC = TYPEBC
ZVALEUR = W_CRC.
IF SY-SUBRC NE 0.
RAISE ERROR_COMPUTING_CRC.
ENDIF.
T_TRAV-CAR = T_ZZE16-ZCARACT.
T_TRAV-VAL = T_ZZE16-ZVALEUR.
T_TRAV-COD = T_ZZE16-ZCODAGE.
APPEND T_TRAV.

* Insertion of the STOP sequence


READ TABLE T_ZZE16 WITH KEY ZTYPBC = TYPEBC
ZCARACT = K_STOP.
IF SY-SUBRC NE 0.
RAISE CARACTER_NOT_ALLOWED.
ENDIF.

T_TRAV-CAR = K_STOP.
T_TRAV-VAL = T_ZZE16-ZVALEUR.
T_TRAV-COD = T_ZZE16-ZCODAGE.
APPEND T_TRAV.

* Construction of the sequence


LOOP AT T_TRAV.
CONCATENATE SEQUENCE T_TRAV-COD INTO SEQUENCE.
IF SY-SUBRC NE 0.
*-- Variable Sequence too small to contain the transco..
RAISE DATA_TOO_LONG.
ENDIF.
ENDLOOP.

ENDFUNCTION.
Tabela ZZE17 - Allowed Codbar Type.

Valores preenchidos para teste:


Exemplo de utilização da Função

w_barcode(256) TYPE c,

MOVE: j_1bprnfhd-nfnum TO w_nfnum,


j_1bprnfis-cgc TO w_cnpj,
j_1bprnfis-regio TO w_regio,
j_1bprnfhd-docdat TO w_docdat.

CONCATENATE '1'
w_nfnum
w_cnpj
w_regio
w_docdat
'2'
INTO w_code.

CALL FUNCTION 'Z_F_BARCODE128_REDTITAN'


EXPORTING
typebc = '128_B'
text = w_code
IMPORTING
sequence = w_barcode
EXCEPTIONS
barcode_inexistant = 1
caracter_not_allowed = 2
error_computing_crc = 3
wrong_data_type =4
data_too_long =5
OTHERS = 6.

CALL FUNCTION 'Z_F_BARCODE128_REDTITAN'


EXPORTING
typebc = '128_B'
text = w_code
IMPORTING
sequence = w_barcode
EXCEPTIONS
barcode_inexistant = 1
caracter_not_allowed = 2
error_computing_crc = 3
wrong_data_type =4
data_too_long =5
OTHERS = 6.

You might also like