Skip to Content

INTRODUCTION

This document describes a Barcode solution implemented in ABAP to generate/print barcodes . The project is totally developed in ABAP and it can be used with any SAP solution and version.

h4. SYMPTOM
There’re differents solutions for the creation and print BARCODEs . All of them have the same problem : When you create a spool from a form/smartform with Barcodes, it’s not possible to convert the spool to a PDF file because the BARCODE is created at the time of printing .

See Notes OSS : 430887 , 645158

h4. SOLUTION
This solution is totally developed in ABAP . It runs for any SAP ( and O.S. ) because it’s a library and function module for the barcodes creation .

Output is a data table within the barcode coordinates . You can use this coordinates to create a Barcode in a form/smartform seeing the correct Barcode image when you display the form.

It’s possible to generate automatically others types of file ( using CONVERT_OTF from spool to PDF ) .
Others outputs could be HTML format or Java Bitmap , always using the barcodes coordinates ( not developed yet ) .

The process can be executed on-line and batch .

ADVANTAGE

DISADVANTAGE

It can be use with any O.S. and SAP version .

It can’t be use for a SAP-Reports .

It can be use with any printer connected to SAP.

 

Output to form/smartform ( PDF ) , data table ( it’s possible to format to HTML , Java-Bitmap )

 

Free solution

 

h4. BARCODE SPECS
You need a CODECS file for decode the string to Barcode coordinates . CODECS have the definition of each barcode font and his map with each ASCII char.

These are the font codes implemented and tested :

FONT

SUB-SET

CHECKSUM

CODECS

TEST

Code 128

A

Yes

C128

Intermec CK31/1551

Code 128

B

Yes

C128

Intermec CK31/1551

Code 128

C

Yes

C128

Intermec CK31/1551

Code 39

 

Yes/No

C39

Intermec CK31/1551

Code 93

 

Yes

C93

Intermec CK31/1551

EAN 8

 

Yes

EAN13

 

EAN 13

 

Yes

EAN13

Intermec CK31/1551

EAN 14

Font C128

Yes

C128

Intermec CK31/1551

CODABAR

 

No

CODABAR

Intermec CK31/1551

UPC/EAN

A

 

UPCEAN

 

UPC/EAN

E

 

UPCEAN

 

CODECS File :

Links
[http://www.barcodesymbols.com/symbologies.htm | http://www.barcodesymbols.com/symbologies.htm]
[http://www.jtbarton.com/Barcodes/Code128.aspx | http://www.jtbarton.com/Barcodes/Code128.aspx]
[http://www.barcoderesource.com/code39_barcode_map.html | http://www.barcoderesource.com/code39_barcode_map.html]
http://grandzebu.net/index.php?page=/informatique/codbar-en/code128.htm
[http://www.barcodeman.com/info/c39_1.php3 | http://www.barcodeman.com/info/c39_1.php3]
[http://community.bartdesmet.net/blogs/bart/archive/2006/09/20/4459.aspx | http://community.bartdesmet.net/blogs/bart/archive/2006/09/20/4459.aspx]
[http://www.barcodesymbols.com/ean13.htm | http://www.barcodesymbols.com/ean13.htm]

h4. IMPLEMENTATION
Implementation of the library and functions modules has been developed in ABAP language in SAP 4.6 system , but it can run in any ABAP version ( supported by SAP ) .
To install is necessary to upload the code ( Z-include and Z-functions ) on SAP-system ans save file CODECS into SAP ( or local server ) .

h5. 1. Create Structure ZBARCODE_COORDS ( SE11 – Abap Dictionary – Data Type )

image

h5. 2. Create Include ZBARCODE_GENERATOR

—-


  •   INCLUDE ZBARCODE_GENERATOR                                         *

—-


  • CODEBAR  | SUBSET  | CHECKSUM | CODECS  |  TESTED            |       *

  • C128     |   A     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C128     |   B     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C128     |   C     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C39      |         |    Yes   |  C39    | Intermec CK31-1551 |       *

  • EAN8     |         |    Yes   |  EAN13  | No                 |       *

  • EAN13    |         |    Yes   |  EAN13  | Intermec CK31-1551 |       *

  • EAN14    |         |    Yes   |  C128   | Intermec CK31-1551 |       *

  • CODABAR  |         |    No    |  CODABAR| Intermec CK31-1551 |       *

  • UPCEAN   |   A     |    Yes   |  UPCEAN | No                 |       *

  • UPCEAN   |   E     |    Yes   |  UPCEAN | No                 |       *

—-


  • Declaración de constantes

*

  • Declaración de variables

*

DATA : D_X_INI TYPE P DECIMALS 3.

DATA : D_Y_INI TYPE P DECIMALS 3.

DATA : D_W_INI TYPE P DECIMALS 3.

DATA : D_H_INI TYPE P DECIMALS 3.

DATA : D_FONT(10).

DATA : D_SUBSET(5).

DATA : D_CHECKS .

DATA : D_BARCODE_BIN(500).

DATA : D_BARCODE(50).

*

DATA : BEGIN OF BC,

       X1(10),

       Y1(10),

       W1(10),

       H1(10).

DATA : END OF BC.

DATA : BEGIN OF BC_DEC OCCURS 500.

  •       X1 TYPE P DECIMALS 2,

  •       Y1 TYPE P DECIMALS 2,

  •       W1 TYPE P DECIMALS 2,

  •       H1 TYPE P DECIMALS 2.

       INCLUDE STRUCTURE ZBARCODE_COORDS.

DATA : END OF BC_DEC.

*DATA : BEGIN OF T_BC128 OCCURS 200,

  •       VALUE   TYPE I,

  •       CODE(4) TYPE N,

  •       PATTERN(15) .

*DATA : END OF T_BC128.

*

*DATA : BEGIN OF T_EAN13_PARITY OCCURS 20,

  •       NUM(1) TYPE N,

  •       PARITY(6) .

*DATA : END OF T_EAN13_PARITY.

**

*DATA : BEGIN OF T_EAN13_PATTERN OCCURS 20,

  •       NUM(1) TYPE N,

  •       PATTERN1(7) ,

  •       PATTERN2(7) ,

  •       PATTERN3(7) .

*DATA : END OF T_EAN13_PATTERN.

DATA : BEGIN OF T_CODECS OCCURS 500,

       CODECS(10),

       VALUE   TYPE I,

       CODE(4) TYPE N,

       PATTERN1(15) ,

       PATTERN2(15) ,

       PATTERN3(15) ,

       PATTERN4(15) .

DATA : END OF T_CODECS.

—-


&—-


*&      Form  GENERA-BARCODE-NUMERICO

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM GENERA-BARCODE-NUMERICO USING L_BARCODE L_SEPARADOR L_BARCODE_BIN.

*

   DATA L_NUM TYPE I.

   DATA L_DEC(4)    TYPE N.

  •   DATA L_DEC_C(20) .

  •   DATA L_CONST(20).

   FIELD-SYMBOLS  TYPE X.

  •   field-symbols <CTS> type c.

*

    CLEAR L_BARCODE_BIN.

    L_NUM = STRLEN( L_BARCODE ) .

    DO L_NUM TIMES .

       ASSIGN L_BARCODE(1) TO .

  •       L_DEC_C = L_DEC.

  •       SHIFT L_DEC_C LEFT  DELETING LEADING SPACE.

  •       CONCATENATE ‘C_BC128_’ L_DEC_C INTO L_CONST.

  •       assign (L_CONST) TO <CTS>.

  •       CONCATENATE L_BARCODE_BIN <CTS>  INTO L_BARCODE_BIN.

        READ TABLE T_CODECS WITH KEY CODECS = D_FONT

                                     CODE   = L_DEC.

        IF SY-SUBRC = 0.

           CONCATENATE L_BARCODE_BIN L_SEPARADOR T_CODECS-PATTERN1

                       INTO L_BARCODE_BIN.

        ENDIF .

       L_BARCODE = L_BARCODE+1.

*

    ENDDO .

    • Si existe separador se elimina el primero

    IF L_SEPARADOR NE SPACE .

       L_BARCODE_BIN = L_BARCODE_BIN+1 .

    ENDIF .

*

ENDFORM.                    ” GENERA-BARCODE-NUMERICO

&—-


*&      Form  GENERA-BARCODE-BITMAP

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

—-


FORM GENERA-BARCODE-BITMAP USING   L_BARCODE_BIN.

*

   DATA L_NUM TYPE I.

   DATA L_OLDCHAR.

   DATA L_CHAR.

   DATA L_WIDTH TYPE I.

   DATA L_XPOS  TYPE I.

   DATA L_X_FIN TYPE P DECIMALS 3.

   DATA L_%     TYPE P DECIMALS 3.

*

   L_NUM = STRLEN( L_BARCODE_BIN ) .

   L_XPOS = D_X_INI.

*

   REFRESH BC_DEC.

*

   DO L_NUM TIMES .

       L_CHAR = L_BARCODE_BIN(1).

       IF ( L_CHAR NE L_OLDCHAR ) AND

            L_OLDCHAR NE SPACE .

          IF L_OLDCHAR = ‘1’.

            BC_DEC-X1 = L_XPOS .

            BC_DEC-Y1 = D_Y_INI.

            BC_DEC-W1 = L_WIDTH .

            BC_DEC-H1 = D_H_INI.

            APPEND BC_DEC.

    •          PERFORM WRITE_FORM.

          ENDIF .

          L_XPOS = L_XPOS + L_WIDTH.

          CLEAR L_WIDTH .

          CLEAR BC_DEC.

       ENDIF .

       L_WIDTH   = L_WIDTH + 1 .

       L_OLDCHAR = L_CHAR.

       L_BARCODE_BIN = L_BARCODE_BIN+1.

   ENDDO.

*

   IF SY-SUBRC = 0.

      IF L_CHAR = ‘1’.

         BC_DEC-X1 = L_XPOS .

         BC_DEC-Y1 = D_Y_INI.

         BC_DEC-W1 = L_WIDTH .

         BC_DEC-H1 = D_H_INI.

         APPEND BC_DEC.

    •       PERFORM WRITE_FORM.

      ENDIF .

      L_XPOS = L_XPOS + L_WIDTH.

   ENDIF .

*

   L_X_FIN = L_XPOS – D_X_INI.

   IF L_X_FIN > 0.

      L_% = D_W_INI / L_X_FIN.

   ENDIF .

*

   LOOP AT BC_DEC.

      BC_DEC-X1 = BC_DEC-X1 * L_%.

      BC_DEC-W1 = BC_DEC-W1 * L_%.

      MODIFY BC_DEC.

   ENDLOOP.

*

*

ENDFORM.                    ” GENERA-BARCODE-BITMAP

&—-


*&      Form  CHECKSUM-C128

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

—-


FORM CHECKSUM-C128 USING D_BARCODE L_SUBSET.

*

    DATA L_BARCODE(50).

    DATA L_SUM TYPE I.

    DATA L_NUM TYPE I.

    DATA L_DEC(4) TYPE N.

    DATA L_HEX(4) TYPE X.

    DATA L_CHAR.

    DATA L_INDEX LIKE SY-INDEX .

*

    FIELD-SYMBOLS  TYPE ‘C’.

  •    ASSIGN L_HEX TO <ASCII> CASTING.

*

    L_CHAR = .

    CONCATENATE D_BARCODE L_CHAR INTO D_BARCODE .

*

ENDFORM.                    ” CHECKSUM-C128

&—-


*&      Form  BC-START-STOP

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

—-


FORM BC-START-STOP USING  L_BARCODE L_START  L_STOP.

*

    CONCATENATE L_START L_BARCODE L_STOP INTO L_BARCODE .

*

ENDFORM.                    ” BC-START-STOP

&—-


*&      Form  INIT-TABLE

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM INIT-TABLE USING L_PATH L_PATHSERVER.

*

    DATA : BEGIN OF T_FILE OCCURS 0,

           LINE(500).

    DATA : END OF T_FILE .

*

    DATA : BEGIN OF L_CODECS,

       CODECS(10),

       VALUE(5),

       CODE(4),

       PATTERN1(15) ,

       PATTERN2(15) ,

       PATTERN3(15) ,

       PATTERN4(15) .

    DATA : END OF L_CODECS.

*

  •   Get data from Application Server or Presentation Server .

  •   Get data from ZTABLE will be the best thing

*

    CHECK T_CODECS[] IS INITIAL .

    CASE L_PATHSERVER.

     WHEN ‘A’ .

  •     “Application Server

       OPEN DATASET L_PATH FOR INPUT IN TEXT MODE.

       CHECK SY-SUBRC = 0.

       DO.

         CLEAR T_FILE.

         READ DATASET L_PATH INTO T_FILE.

         IF SY-SUBRC NE 0.

             APPEND T_FILE.

             EXIT.

         ELSE.

             APPEND T_FILE.

         ENDIF .

       ENDDO.

       CLOSE DATASET L_PATH.

     WHEN ‘P’ .

  •      “Presentation Server

        CALL FUNCTION ‘WS_UPLOAD’

          EXPORTING

            FILENAME                      = L_PATH

            FILETYPE                      = ‘ASC’

         TABLES

            DATA_TAB                      = T_FILE.

     WHEN ‘T’ .

  •        ” Table SAP

  •        SELECT * INTO TABLE T_CODECS FROM ZBARCODE_CODECS.

  •        EXIT .

    ENDCASE .

    LOOP AT T_FILE.

        CLEAR L_CODECS.

        SPLIT T_FILE-LINE AT ‘;’ INTO  L_CODECS-CODECS

                                       L_CODECS-VALUE

                                       L_CODECS-CODE

                                       L_CODECS-PATTERN1

                                       L_CODECS-PATTERN2

                                       L_CODECS-PATTERN3

                                       L_CODECS-PATTERN4.

        MOVE-CORRESPONDING L_CODECS TO T_CODECS.

        APPEND T_CODECS.

    ENDLOOP.

ENDFORM.                    ” INIT-TABLE

&—-


*&      Form  CHECKSUM-C39

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

—-


FORM CHECKSUM-C39 USING   D_BARCODE.

*

    DATA L_BARCODE(50).

    DATA L_SUM TYPE I.

    DATA L_NUM TYPE I.

    DATA L_DEC(4) TYPE N.

    DATA L_HEX TYPE X.

    DATA L_INDEX LIKE SY-INDEX .

*

    FIELD-SYMBOLS  INTO D_BARCODE .

*

ENDFORM.                    ” CHECKSUM-C39

&—-


*&      Form  CHECKSUM-EAN13

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

—-


FORM CHECKSUM-EAN13 USING  D_BARCODE.

*

    DATA L_BARCODE(50).

    DATA L_NUM TYPE I .

    DATA L_PARIMPAR TYPE I.

    DATA L_CODE TYPE I.

    DATA L_NUMN TYPE N .

    L_BARCODE = D_BARCODE .

    L_NUM = STRLEN( L_BARCODE ) .

    DO L_NUM TIMES .

       L_NUMN = L_BARCODE(1).

       L_PARIMPAR = SY-INDEX MOD 2.

       IF L_PARIMPAR = 0.

          L_CODE = L_CODE + ( L_NUMN * 3 ) .

       ELSE.

          L_CODE = L_CODE + L_NUMN.

       ENDIF .

       L_BARCODE = L_BARCODE+1.

    ENDDO .

    L_CODE = L_CODE MOD 10.

    L_CODE = 10 – L_CODE .

    L_CODE = L_CODE MOD 10.

    L_NUMN = L_CODE.

*

    CONCATENATE D_BARCODE L_NUMN INTO D_BARCODE .

*

ENDFORM.                    ” CHECKSUM-EAN13

&—-


*&      Form  GENERA-BARCODE-NUMERICO-EAN13

&—-


  •       text

—-


  •      –>P_D_BARCODE  text

  •      –>P_D_BARCODE  text

—-


FORM GENERA-BARCODE-NUMERICO-EAN13 USING  D_BARCODE L_BARCODE_BIN.

*

   DATA L_BARCODE(50) .

   DATA L_NUM  TYPE I .

   DATA L_SEPARADOR(10) VALUE ‘01010’.

   DATA L_PARITY(15).

*

   L_BARCODE  = D_BARCODE.

   CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 1.

      L_NUM = L_BARCODE(1).

   ENDCATCH.

   CHECK SY-SUBRC = 0.

*

   READ TABLE T_CODECS WITH KEY CODECS = D_FONT

                                VALUE  = L_NUM.

   CHECK SY-SUBRC = 0.

   L_PARITY = T_CODECS-PATTERN4.

*

   L_BARCODE  = L_BARCODE+1 .

*

   DO 6 TIMES .

      CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 1.

         L_NUM = L_BARCODE(1).

      ENDCATCH.

      CHECK SY-SUBRC = 0.

      READ TABLE T_CODECS WITH KEY CODECS = D_FONT

                                   VALUE  = L_NUM.

      CHECK SY-SUBRC = 0.

      IF L_PARITY(1) = ‘o’.

         CONCATENATE L_BARCODE_BIN T_CODECS-PATTERN1

                     INTO L_BARCODE_BIN.

      ELSE.

         CONCATENATE L_BARCODE_BIN T_CODECS-PATTERN2

                     INTO L_BARCODE_BIN.

      ENDIF .

      L_PARITY = L_PARITY+1 .

      L_BARCODE  = L_BARCODE+1 .

   ENDDO .

*

   CONCATENATE L_BARCODE_BIN L_SEPARADOR INTO L_BARCODE_BIN.

*

   DO 6 TIMES .

      CATCH SYSTEM-EXCEPTIONS CONVT_NO_NUMBER = 1.

         L_NUM = L_BARCODE(1).

      ENDCATCH.

      CHECK SY-SUBRC = 0.

      READ TABLE T_CODECS WITH KEY CODECS = D_FONT

                                   VALUE  = L_NUM.

      CONCATENATE L_BARCODE_BIN T_CODECS-PATTERN3

                  INTO L_BARCODE_BIN.

      L_BARCODE  = L_BARCODE+1 .

   ENDDO .

*

      •   CONCATENATE ‘101’ L_BARCODE_BIN ‘101’ INTO L_BARCODE_BIN.

*

ENDFORM.                    ” GENERA-BARCODE-NUMERICO-EAN13

&—-


*&      Form  BARCODE-ENCODE

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM BARCODE-ENCODE USING L_PATH L_PATHSERVER.

*

    REFRESH BC_DEC .

*

    CASE D_FONT .

    PERFORM INIT-TABLE USING L_PATH L_PATHSERVER.

  •    C128 ( subsets A/B/C )

     WHEN ‘C128’.

       IF D_CHECKS NE SPACE .

          PERFORM CHECKSUM-C128 USING D_BARCODE D_SUBSET.

       ENDIF .

       CASE D_SUBSET.

          WHEN ‘A’. PERFORM BC-START-STOP USING D_BARCODE ‘Ë’ ‘Î’.

          WHEN ‘B’. PERFORM BC-START-STOP USING D_BARCODE ‘Ì’ ‘Î’.

          WHEN ‘C’. PERFORM BC-START-STOP USING D_BARCODE ‘Í’ ‘Î’.

       ENDCASE .

       PERFORM GENERA-BARCODE-NUMERICO USING D_BARCODE ” D_BARCODE_BIN.

  •    C39

     WHEN ‘C39’.

       IF D_CHECKS NE SPACE .

          PERFORM CHECKSUM-C39 USING D_BARCODE.

       ENDIF .

       PERFORM BC-START-STOP USING D_BARCODE ‘‘ ‘‘.

       PERFORM GENERA-BARCODE-NUMERICO USING D_BARCODE ‘0’ D_BARCODE_BIN

.

  •    EAN8

  •    EAN13

     WHEN ‘EAN13’.

       IF D_CHECKS NE SPACE .

          PERFORM CHECKSUM-EAN13 USING D_BARCODE.

       ENDIF .

       PERFORM GENERA-BARCODE-NUMERICO-EAN13 USING D_BARCODE

                                                   D_BARCODE_BIN.

       PERFORM BC-START-STOP USING D_BARCODE_BIN ‘101’ ‘101’.

  •    CODABAR

     WHEN ‘CODABAR’.

       PERFORM BC-START-STOP USING D_BARCODE ‘A’ ‘A’.

       PERFORM GENERA-BARCODE-NUMERICO USING D_BARCODE ” D_BARCODE_BIN.

  •    C93

     WHEN ‘C93’.

       PERFORM GENERA-BARCODE-NUMERICO USING D_BARCODE ” D_BARCODE_BIN.

       PERFORM BC-START-STOP USING D_BARCODE_BIN ‘101011110’

                                                 ‘1010111101’.

  •    UPC A/E

     WHEN ‘UPC’.

       CASE D_SUBSET.

          WHEN ‘A’.

          WHEN ‘E’.

       ENDCASE .

    ENDCASE .

*

    PERFORM GENERA-BARCODE-BITMAP USING D_BARCODE_BIN.

*

ENDFORM.                    ” BARCODE-ENCODE

h5. 3. Create Include ZBARCODE_FORMVIEWER

—-


  •   INCLUDE ZBARCODE_FORMVIEWER                                        *

—-


*

DATA : BEGIN OF BC,

       X1(10),

       Y1(10),

       W1(10),

       H1(10).

DATA : END OF BC.

DATA : BEGIN OF BC_DEC OCCURS 500.

       INCLUDE STRUCTURE ZBARCODE_COORDS.

DATA : END OF BC_DEC.

*

  • Emulador códigos de Barras FORM – Ventana Variable

DATA BC1  LIKE BC.

DATA BC2  LIKE BC.

DATA BC3  LIKE BC.

DATA BC4  LIKE BC.

DATA BC5  LIKE BC.

DATA BC6  LIKE BC.

DATA BC7  LIKE BC.

DATA BC8  LIKE BC.

DATA BC9  LIKE BC.

DATA BC10 LIKE BC.

DATA BC11 LIKE BC.

DATA BC12 LIKE BC.

DATA BC13 LIKE BC.

DATA BC14 LIKE BC.

DATA BC15 LIKE BC.

DATA BC16 LIKE BC.

DATA BC17 LIKE BC.

DATA BC18 LIKE BC.

DATA BC19 LIKE BC.

DATA BC20 LIKE BC.

DATA BC21 LIKE BC.

DATA BC22 LIKE BC.

DATA BC23 LIKE BC.

DATA BC24 LIKE BC.

DATA BC25 LIKE BC.

DATA BC26 LIKE BC.

DATA BC27 LIKE BC.

DATA BC28 LIKE BC.

DATA BC29 LIKE BC.

DATA BC30 LIKE BC.

DATA BC31 LIKE BC.

DATA BC32 LIKE BC.

DATA BC33 LIKE BC.

DATA BC34 LIKE BC.

DATA BC35 LIKE BC.

DATA BC36 LIKE BC.

DATA BC37 LIKE BC.

DATA BC38 LIKE BC.

DATA BC39 LIKE BC.

DATA BC40 LIKE BC.

DATA BC41 LIKE BC.

DATA BC42 LIKE BC.

DATA BC43 LIKE BC.

DATA BC44 LIKE BC.

DATA BC45 LIKE BC.

DATA BC46 LIKE BC.

DATA BC47 LIKE BC.

DATA BC48 LIKE BC.

DATA BC49 LIKE BC.

DATA BC50 LIKE BC.

DATA BC51 LIKE BC.

DATA BC52 LIKE BC.

DATA BC53 LIKE BC.

DATA BC54 LIKE BC.

DATA BC55 LIKE BC.

DATA BC56 LIKE BC.

DATA BC57 LIKE BC.

DATA BC58 LIKE BC.

DATA BC59 LIKE BC.

DATA BC60 LIKE BC.

DATA BC61 LIKE BC.

DATA BC62 LIKE BC.

DATA BC63 LIKE BC.

DATA BC64 LIKE BC.

DATA BC65 LIKE BC.

DATA BC66 LIKE BC.

DATA BC67 LIKE BC.

DATA BC68 LIKE BC.

DATA BC69 LIKE BC.

DATA BC70 LIKE BC.

DATA BC71 LIKE BC.

DATA BC72 LIKE BC.

DATA BC73 LIKE BC.

DATA BC74 LIKE BC.

DATA BC75 LIKE BC.

DATA BC76 LIKE BC.

DATA BC77 LIKE BC.

DATA BC78 LIKE BC.

DATA BC79 LIKE BC.

DATA BC80 LIKE BC.

DATA BC81 LIKE BC.

DATA BC82 LIKE BC.

DATA BC83 LIKE BC.

DATA BC84 LIKE BC.

DATA BC85 LIKE BC.

DATA BC86 LIKE BC.

DATA BC87 LIKE BC.

DATA BC88 LIKE BC.

DATA BC89 LIKE BC.

DATA BC90 LIKE BC.

DATA BC91 LIKE BC.

DATA BC92 LIKE BC.

DATA BC93 LIKE BC.

DATA BC94 LIKE BC.

DATA BC95 LIKE BC.

DATA BC96 LIKE BC.

DATA BC97 LIKE BC.

DATA BC98 LIKE BC.

DATA BC99 LIKE BC.

DATA BC100 LIKE BC.

DATA BC101 LIKE BC.

DATA BC102 LIKE BC.

DATA BC103 LIKE BC.

DATA BC104 LIKE BC.

DATA BC105 LIKE BC.

DATA BC106 LIKE BC.

DATA BC107 LIKE BC.

DATA BC108 LIKE BC.

DATA BC109 LIKE BC.

DATA BC110 LIKE BC.

DATA BC111 LIKE BC.

DATA BC112 LIKE BC.

DATA BC113 LIKE BC.

DATA BC114 LIKE BC.

DATA BC115 LIKE BC.

DATA BC116 LIKE BC.

DATA BC117 LIKE BC.

DATA BC118 LIKE BC.

DATA BC119 LIKE BC.

DATA BC120 LIKE BC.

DATA BC121 LIKE BC.

DATA BC122 LIKE BC.

DATA BC123 LIKE BC.

DATA BC124 LIKE BC.

DATA BC125 LIKE BC.

DATA BC126 LIKE BC.

DATA BC127 LIKE BC.

DATA BC128 LIKE BC.

DATA BC129 LIKE BC.

DATA BC130 LIKE BC.

DATA BC131 LIKE BC.

DATA BC132 LIKE BC.

DATA BC133 LIKE BC.

DATA BC134 LIKE BC.

DATA BC135 LIKE BC.

DATA BC136 LIKE BC.

DATA BC137 LIKE BC.

DATA BC138 LIKE BC.

DATA BC139 LIKE BC.

DATA BC140 LIKE BC.

DATA BC141 LIKE BC.

DATA BC142 LIKE BC.

DATA BC143 LIKE BC.

DATA BC144 LIKE BC.

DATA BC145 LIKE BC.

DATA BC146 LIKE BC.

DATA BC147 LIKE BC.

DATA BC148 LIKE BC.

DATA BC149 LIKE BC.

DATA BC150 LIKE BC.

DATA BC151 LIKE BC.

DATA BC152 LIKE BC.

DATA BC153 LIKE BC.

DATA BC154 LIKE BC.

DATA BC155 LIKE BC.

DATA BC156 LIKE BC.

DATA BC157 LIKE BC.

DATA BC158 LIKE BC.

DATA BC159 LIKE BC.

DATA BC160 LIKE BC.

DATA BC161 LIKE BC.

DATA BC162 LIKE BC.

DATA BC163 LIKE BC.

DATA BC164 LIKE BC.

DATA BC165 LIKE BC.

DATA BC166 LIKE BC.

DATA BC167 LIKE BC.

DATA BC168 LIKE BC.

DATA BC169 LIKE BC.

DATA BC170 LIKE BC.

DATA BC171 LIKE BC.

DATA BC172 LIKE BC.

DATA BC173 LIKE BC.

DATA BC174 LIKE BC.

DATA BC175 LIKE BC.

DATA BC176 LIKE BC.

DATA BC177 LIKE BC.

DATA BC178 LIKE BC.

DATA BC179 LIKE BC.

DATA BC180 LIKE BC.

DATA BC181 LIKE BC.

DATA BC182 LIKE BC.

DATA BC183 LIKE BC.

DATA BC184 LIKE BC.

DATA BC185 LIKE BC.

DATA BC186 LIKE BC.

DATA BC187 LIKE BC.

DATA BC188 LIKE BC.

DATA BC189 LIKE BC.

DATA BC190 LIKE BC.

DATA BC191 LIKE BC.

DATA BC192 LIKE BC.

DATA BC193 LIKE BC.

DATA BC194 LIKE BC.

DATA BC195 LIKE BC.

DATA BC196 LIKE BC.

DATA BC197 LIKE BC.

DATA BC198 LIKE BC.

DATA BC199 LIKE BC.

DATA BC200 LIKE BC.

DATA BC201 LIKE BC.

DATA BC202 LIKE BC.

DATA BC203 LIKE BC.

DATA BC204 LIKE BC.

DATA BC205 LIKE BC.

DATA BC206 LIKE BC.

DATA BC207 LIKE BC.

DATA BC208 LIKE BC.

DATA BC209 LIKE BC.

DATA BC210 LIKE BC.

DATA BC211 LIKE BC.

DATA BC212 LIKE BC.

DATA BC213 LIKE BC.

DATA BC214 LIKE BC.

DATA BC215 LIKE BC.

DATA BC216 LIKE BC.

DATA BC217 LIKE BC.

DATA BC218 LIKE BC.

DATA BC219 LIKE BC.

DATA BC220 LIKE BC.

DATA BC221 LIKE BC.

DATA BC222 LIKE BC.

DATA BC223 LIKE BC.

DATA BC224 LIKE BC.

DATA BC225 LIKE BC.

DATA BC226 LIKE BC.

DATA BC227 LIKE BC.

DATA BC228 LIKE BC.

DATA BC229 LIKE BC.

DATA BC230 LIKE BC.

DATA BC231 LIKE BC.

DATA BC232 LIKE BC.

DATA BC233 LIKE BC.

DATA BC234 LIKE BC.

DATA BC235 LIKE BC.

DATA BC236 LIKE BC.

DATA BC237 LIKE BC.

DATA BC238 LIKE BC.

DATA BC239 LIKE BC.

DATA BC240 LIKE BC.

DATA BC241 LIKE BC.

DATA BC242 LIKE BC.

DATA BC243 LIKE BC.

DATA BC244 LIKE BC.

DATA BC245 LIKE BC.

DATA BC246 LIKE BC.

DATA BC247 LIKE BC.

DATA BC248 LIKE BC.

DATA BC249 LIKE BC.

DATA BC250 LIKE BC.

DATA BC251 LIKE BC.

DATA BC252 LIKE BC.

DATA BC253 LIKE BC.

DATA BC254 LIKE BC.

DATA BC255 LIKE BC.

DATA BC256 LIKE BC.

DATA BC257 LIKE BC.

DATA BC258 LIKE BC.

DATA BC259 LIKE BC.

DATA BC260 LIKE BC.

DATA BC261 LIKE BC.

DATA BC262 LIKE BC.

DATA BC263 LIKE BC.

DATA BC264 LIKE BC.

DATA BC265 LIKE BC.

DATA BC266 LIKE BC.

DATA BC267 LIKE BC.

DATA BC268 LIKE BC.

DATA BC269 LIKE BC.

DATA BC270 LIKE BC.

DATA BC271 LIKE BC.

DATA BC272 LIKE BC.

DATA BC273 LIKE BC.

DATA BC274 LIKE BC.

DATA BC275 LIKE BC.

DATA BC276 LIKE BC.

DATA BC277 LIKE BC.

DATA BC278 LIKE BC.

DATA BC279 LIKE BC.

DATA BC280 LIKE BC.

DATA BC281 LIKE BC.

DATA BC282 LIKE BC.

DATA BC283 LIKE BC.

DATA BC284 LIKE BC.

DATA BC285 LIKE BC.

DATA BC286 LIKE BC.

DATA BC287 LIKE BC.

DATA BC288 LIKE BC.

DATA BC289 LIKE BC.

DATA BC290 LIKE BC.

DATA BC291 LIKE BC.

DATA BC292 LIKE BC.

DATA BC293 LIKE BC.

DATA BC294 LIKE BC.

DATA BC295 LIKE BC.

DATA BC296 LIKE BC.

DATA BC297 LIKE BC.

DATA BC298 LIKE BC.

DATA BC299 LIKE BC.

DATA BC300 LIKE BC.

DATA BC301 LIKE BC.

DATA BC302 LIKE BC.

DATA BC303 LIKE BC.

DATA BC304 LIKE BC.

DATA BC305 LIKE BC.

DATA BC306 LIKE BC.

DATA BC307 LIKE BC.

DATA BC308 LIKE BC.

DATA BC309 LIKE BC.

DATA BC310 LIKE BC.

DATA BC311 LIKE BC.

DATA BC312 LIKE BC.

DATA BC313 LIKE BC.

DATA BC314 LIKE BC.

DATA BC315 LIKE BC.

DATA BC316 LIKE BC.

DATA BC317 LIKE BC.

DATA BC318 LIKE BC.

DATA BC319 LIKE BC.

DATA BC320 LIKE BC.

DATA BC321 LIKE BC.

DATA BC322 LIKE BC.

DATA BC323 LIKE BC.

DATA BC324 LIKE BC.

DATA BC325 LIKE BC.

DATA BC326 LIKE BC.

DATA BC327 LIKE BC.

DATA BC328 LIKE BC.

DATA BC329 LIKE BC.

DATA BC330 LIKE BC.

DATA BC331 LIKE BC.

DATA BC332 LIKE BC.

DATA BC333 LIKE BC.

DATA BC334 LIKE BC.

DATA BC335 LIKE BC.

DATA BC336 LIKE BC.

DATA BC337 LIKE BC.

DATA BC338 LIKE BC.

DATA BC339 LIKE BC.

DATA BC340 LIKE BC.

DATA BC341 LIKE BC.

DATA BC342 LIKE BC.

DATA BC343 LIKE BC.

DATA BC344 LIKE BC.

DATA BC345 LIKE BC.

DATA BC346 LIKE BC.

DATA BC347 LIKE BC.

DATA BC348 LIKE BC.

DATA BC349 LIKE BC.

DATA BC350 LIKE BC.

DATA BC351 LIKE BC.

DATA BC352 LIKE BC.

DATA BC353 LIKE BC.

DATA BC354 LIKE BC.

DATA BC355 LIKE BC.

DATA BC356 LIKE BC.

DATA BC357 LIKE BC.

DATA BC358 LIKE BC.

DATA BC359 LIKE BC.

DATA BC360 LIKE BC.

DATA BC361 LIKE BC.

DATA BC362 LIKE BC.

DATA BC363 LIKE BC.

DATA BC364 LIKE BC.

DATA BC365 LIKE BC.

DATA BC366 LIKE BC.

DATA BC367 LIKE BC.

DATA BC368 LIKE BC.

DATA BC369 LIKE BC.

DATA BC370 LIKE BC.

DATA BC371 LIKE BC.

DATA BC372 LIKE BC.

DATA BC373 LIKE BC.

DATA BC374 LIKE BC.

DATA BC375 LIKE BC.

DATA BC376 LIKE BC.

DATA BC377 LIKE BC.

DATA BC378 LIKE BC.

DATA BC379 LIKE BC.

DATA BC380 LIKE BC.

DATA BC381 LIKE BC.

DATA BC382 LIKE BC.

DATA BC383 LIKE BC.

DATA BC384 LIKE BC.

DATA BC385 LIKE BC.

DATA BC386 LIKE BC.

DATA BC387 LIKE BC.

DATA BC388 LIKE BC.

DATA BC389 LIKE BC.

DATA BC390 LIKE BC.

DATA BC391 LIKE BC.

DATA BC392 LIKE BC.

DATA BC393 LIKE BC.

DATA BC394 LIKE BC.

DATA BC395 LIKE BC.

DATA BC396 LIKE BC.

DATA BC397 LIKE BC.

DATA BC398 LIKE BC.

DATA BC399 LIKE BC.

DATA BC400 LIKE BC.

DATA BC401 LIKE BC.

DATA BC402 LIKE BC.

DATA BC403 LIKE BC.

DATA BC404 LIKE BC.

DATA BC405 LIKE BC.

DATA BC406 LIKE BC.

DATA BC407 LIKE BC.

DATA BC408 LIKE BC.

DATA BC409 LIKE BC.

DATA BC410 LIKE BC.

DATA BC411 LIKE BC.

DATA BC412 LIKE BC.

DATA BC413 LIKE BC.

DATA BC414 LIKE BC.

DATA BC415 LIKE BC.

DATA BC416 LIKE BC.

DATA BC417 LIKE BC.

DATA BC418 LIKE BC.

DATA BC419 LIKE BC.

DATA BC420 LIKE BC.

DATA BC421 LIKE BC.

DATA BC422 LIKE BC.

DATA BC423 LIKE BC.

DATA BC424 LIKE BC.

DATA BC425 LIKE BC.

DATA BC426 LIKE BC.

DATA BC427 LIKE BC.

DATA BC428 LIKE BC.

DATA BC429 LIKE BC.

DATA BC430 LIKE BC.

DATA BC431 LIKE BC.

DATA BC432 LIKE BC.

DATA BC433 LIKE BC.

DATA BC434 LIKE BC.

DATA BC435 LIKE BC.

DATA BC436 LIKE BC.

DATA BC437 LIKE BC.

DATA BC438 LIKE BC.

DATA BC439 LIKE BC.

DATA BC440 LIKE BC.

DATA BC441 LIKE BC.

DATA BC442 LIKE BC.

DATA BC443 LIKE BC.

DATA BC444 LIKE BC.

DATA BC445 LIKE BC.

DATA BC446 LIKE BC.

DATA BC447 LIKE BC.

DATA BC448 LIKE BC.

DATA BC449 LIKE BC.

DATA BC450 LIKE BC.

DATA BC451 LIKE BC.

DATA BC452 LIKE BC.

DATA BC453 LIKE BC.

DATA BC454 LIKE BC.

DATA BC455 LIKE BC.

DATA BC456 LIKE BC.

DATA BC457 LIKE BC.

DATA BC458 LIKE BC.

DATA BC459 LIKE BC.

DATA BC460 LIKE BC.

DATA BC461 LIKE BC.

DATA BC462 LIKE BC.

DATA BC463 LIKE BC.

DATA BC464 LIKE BC.

DATA BC465 LIKE BC.

DATA BC466 LIKE BC.

DATA BC467 LIKE BC.

DATA BC468 LIKE BC.

DATA BC469 LIKE BC.

DATA BC470 LIKE BC.

DATA BC471 LIKE BC.

DATA BC472 LIKE BC.

DATA BC473 LIKE BC.

DATA BC474 LIKE BC.

DATA BC475 LIKE BC.

DATA BC476 LIKE BC.

DATA BC477 LIKE BC.

DATA BC478 LIKE BC.

DATA BC479 LIKE BC.

DATA BC480 LIKE BC.

DATA BC481 LIKE BC.

DATA BC482 LIKE BC.

DATA BC483 LIKE BC.

DATA BC484 LIKE BC.

DATA BC485 LIKE BC.

DATA BC486 LIKE BC.

DATA BC487 LIKE BC.

DATA BC488 LIKE BC.

DATA BC489 LIKE BC.

DATA BC490 LIKE BC.

DATA BC491 LIKE BC.

DATA BC492 LIKE BC.

DATA BC493 LIKE BC.

DATA BC494 LIKE BC.

DATA BC495 LIKE BC.

DATA BC496 LIKE BC.

DATA BC497 LIKE BC.

DATA BC498 LIKE BC.

DATA BC499 LIKE BC.

DATA BC500 LIKE BC.

*

&—-


*&      Form  WRITE_FORM_BARCODE_VAR

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM WRITE_FORM_BARCODE_VAR USING L_ELEMENT L_WINDOW.

*

  FIELD-SYMBOLS: .

  ENDLOOP.

*

  CALL FUNCTION ‘WRITE_FORM’

       EXPORTING

           ELEMENT  = L_ELEMENT

           FUNCTION = ‘APPEND’

           WINDOW   = L_WINDOW

  EXCEPTIONS

           OTHERS   = 1.

*

ENDFORM.                    ” WRITE_FORM_BARCODE_VAR

&—-


*&      Form  WRITE_FORM_BARCODE_MAIN

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM WRITE_FORM_BARCODE_MAIN USING L_ELEMENT L_WINDOW.

*

  LOOP AT BC_DEC.

      MOVE-CORRESPONDING BC_DEC TO BC .

*

      CALL FUNCTION ‘WRITE_FORM’

           EXPORTING

                ELEMENT  = L_ELEMENT

                FUNCTION = ‘SET’

                WINDOW   = L_WINDOW

           EXCEPTIONS

                OTHERS   = 1.

  ENDLOOP.

*

ENDFORM.                    ” WRITE_FORM_BARCODE_MAIN

h5. 4. Create Function Module Z_BARCODE_CREATE

Input Parameters :

!https://weblogs.sdn.sap.com/weblogs/images/251866795/Z_BARCODE_CREATE_IMPORT2.jpg|height=336|alt=image|width=509|src=https://weblogs.sdn.sap.com/weblogs/images/251866795/Z_BARCODE_CREATE_IMPORT2.jpg|border=0!

Table Parameters :

!https://weblogs.sdn.sap.com/weblogs/images/251866795/ZBARCODE_CREATE_TABLES.jpg|height=157|alt=image|width=592|src=https://weblogs.sdn.sap.com/weblogs/images/251866795/ZBARCODE_CREATE_TABLES.jpg|border=0!

Global Data : include ZBARCODE_GENERATOR in global data (LZBARCODETOP)

!https://weblogs.sdn.sap.com/weblogs/images/251866795/Z_BARCODE_CREATE_GLOBALDATA.jpg|height=202|alt=image|width=455|src=https://weblogs.sdn.sap.com/weblogs/images/251866795/Z_BARCODE_CREATE_GLOBALDATA.jpg|border=0!

Source Code of function module Z_BARCODE_CREATE :

FUNCTION Z_BARCODE_CREATE.

*”—-


“Interfase local

*”  IMPORTING

*”     REFERENCE(BARCODE) TYPE  C

*”     REFERENCE(FONT) TYPE  C

*”     REFERENCE(SUBSET) TYPE  C OPTIONAL

*”     REFERENCE(CHECKSUM) TYPE  C DEFAULT ‘X’

*”     REFERENCE(ROTATE) TYPE  C OPTIONAL

*”     REFERENCE(X_INI) TYPE  P OPTIONAL

*”     REFERENCE(Y_INI) TYPE  P OPTIONAL

*”     REFERENCE(W_INI) TYPE  P

*”     REFERENCE(H_INI) TYPE  P

*”     REFERENCE(CODECSPATH) LIKE  RLGRAP-FILENAME

*”     REFERENCE(PATHSERVER) TYPE  C

*”  TABLES

*”      BC_COORDS STRUCTURE  ZBARCODE_COORDS OPTIONAL

*”—-


—-


  • CODEBAR  | SUBSET  | CHECKSUM | CODECS  |  TESTED            |       *

  • C128     |   A     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C128     |   B     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C128     |   C     |    Yes   |  C128   | Intermec CK31-1551 |       *

  • C39      |         |    Yes   |  C39    | Intermec CK31-1551 |       *

  • EAN8     |         |    Yes   |  EAN13  | No                 |       *

  • EAN13    |         |    Yes   |  EAN13  | Intermec CK31-1551 |       *

  • EAN14    |         |    Yes   |  C128   | Intermec CK31-1551 |       *

  • CODABAR  |         |    No    |  CODABAR| Intermec CK31-1551 |       *

  • UPCEAN   |   A     |    Yes   |  UPCEAN | No                 |       *

  • UPCEAN   |   E     |    Yes   |  UPCEAN | No                 |       *

—-


*

      DATA L_AUX   LIKE ZBARCODE_COORDS-X1.

*

      D_BARCODE = BARCODE.

      D_X_INI   = X_INI.

      D_Y_INI   = Y_INI.

      D_W_INI   = W_INI.

      D_H_INI   = H_INI.

      D_FONT    = FONT.

      D_SUBSET  = SUBSET.

      D_CHECKS  = CHECKSUM.

*

      PERFORM BARCODE-ENCODE USING CODECSPATH PATHSERVER.

**

      LOOP AT BC_DEC.

  •       Rotate 90

        IF ROTATE NE SPACE .

           L_AUX = BC_DEC-X1.

           BC_DEC-X1 = BC_DEC-Y1.

           BC_DEC-Y1 = L_AUX.

           L_AUX = BC_DEC-W1.

           BC_DEC-W1 = BC_DEC-H1.

           BC_DEC-H1 = L_AUX.

           MODIFY BC_DEC.

        ENDIF .

        MOVE-CORRESPONDING BC_DEC TO BC_COORDS.

        APPEND BC_COORDS.

      ENDLOOP .

  •     BC_COORDS[] = BC_DEC[].

ENDFUNCTION.

h5. 5. CODECS file
Save the codecs file in the SAP Application Server or in your local PC . When you execute the function , you must inform the path in the input parameter.

h4. MANUAL
Function Z_BARCODE_CREATE : you can use this function to create the Barcode coordinates

Parameters :

BARCODE

initial string

FONT

type of Barcode ( referenced to the table CODECS )

SUBSET

subset of Barcode ( referenced to the table CODECS )

CHECKSUM

generate check code (flag)

ROTATE

Rotate Barcode 90º (flag)

X_INI

initial X position

Y_INI

initial Y position

W_INI

Weight of the image

H_INI

High of the image

CODECSPATH

CODECS file path

PATHSERVER

type of path ( P = presentation server / A = application server / T = Table )

Output table : Barcode coordinates of each black bar

X1

X coordinate

Y1

Y coordinate

W1

Weight

H1

High

Display the barcode in a SAPSCRIPT Forms or Smartforms : It depends on the window type of the Form you need to use differents PERFORMs developed in the ZBARCODE_FORMVIEWER include.

SAPSCRIPT => MAIN WINDOW : use PERFORM WRITE_FORM_BARCODE_MAIN . You need to create an element in the Main Window

SAPSCRIPT => VAR WINDOW : use PERFORM WRITE_FORM_BARCODE_VAR . In that case, you can’t call to write many times at the same window ( because it isn’t Main window ) . It’s necesary create a SAPSCRIPT form with all the black bar ( max 500 bars ).

SMARTFORM : you have the internal table with the Barcode coordinates. Looping this table you can display the black bars in a Smartform.

h4. EXAMPLES
This report display a sapscript form using the Z_BARCODE_CREATE function module and ZBARCODE_FORMVIEWER to display the form. If you print the form , you can convert the sap-spool to the PDF file using CONVERT_OTF function module.

PDF generated from SAP-SPOOL :

!https://weblogs.sdn.sap.com/weblogs/images/251866795/PDF_barcode_example.JPG|height=379|alt=image|width=383|src=https://weblogs.sdn.sap.com/weblogs/images/251866795/PDF_barcode_example.JPG|border=0!

Source Code Z_BCTEST :

REPORT ZBC_TEST .

—-


—-


PARAMETERS PBARCODE(50) LOWER CASE.

SELECTION-SCREEN SKIP .

*PARAMETERS P_% TYPE I DEFAULT 100.

PARAMETERS P_X_INI TYPE P DECIMALS 3 DEFAULT 5.

PARAMETERS P_Y_INI TYPE P DECIMALS 3 DEFAULT 5.

PARAMETERS P_W_INI TYPE P DECIMALS 3 DEFAULT 400.

PARAMETERS P_H_INI TYPE P DECIMALS 3 DEFAULT 150.

SELECTION-SCREEN SKIP .

PARAMETERS P_FONT(10).

PARAMETERS P_SUBSET(5).

PARAMETERS P_CHECKS AS CHECKBOX DEFAULT ‘X’.

PARAMETERS P_ROTATE AS CHECKBOX .

PARAMETERS P_CODEC LIKE RLGRAP-FILENAME OBLIGATORY.

PARAMETERS P_SERVER.

—-


INCLUDE ZBARCODE_FORMVIEWER.

*

START-OF-SELECTION.

  •      D_BARCODE = PBARCODE.

  •      D_X_INI   = P_X_INI.

  •      D_Y_INI   = P_Y_INI.

  •      D_W_INI   = P_W_INI.

  •      D_H_INI   = P_H_INI.

  •      D_FONT    = P_FONT.

  •      D_SUBSET  = P_SUBSET.

  •      D_CHECKS  = P_CHECKS.

*

  •      PERFORM BARCODE-ENCODE .

  •    EXPORT BC_DEC TO MEMORY ID ‘BARCODE’.

    CALL FUNCTION ‘Z_BARCODE_CREATE’

      EXPORTING

        BARCODE         = PBARCODE

        FONT            = P_FONT

        SUBSET          = P_SUBSET

        CHECKSUM        = P_CHECKS

        ROTATE          = P_ROTATE

        X_INI           = P_X_INI

        Y_INI           = P_Y_INI

        W_INI           = P_W_INI

        H_INI           = P_H_INI

        CODECSPATH      = P_CODEC

        PATHSERVER      = P_SERVER

      TABLES

        BC_COORDS       = BC_DEC.

*

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    IF NOT BC_DEC[] IS INITIAL .

       PERFORM OPEN_FORM .

       PERFORM WRITE_FORM_BARCODE_MAIN USING ‘BARCODE’ ‘MAIN’.

       PERFORM CLOSE_FORM.

    ENDIF .

*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

*

—-


&—-


*&      Form  OPEN_FORM

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM OPEN_FORM.

*

  DATA I_ITCPO LIKE ITCPO.

*

  CLEAR I_ITCPO.

   I_ITCPO-TDNEWID   = ‘X’.

   I_ITCPO-TDPREVIEW = ‘X’.

   I_ITCPO-TDNOPRINT = ‘ ‘.

*

  CALL FUNCTION ‘OPEN_FORM’

       EXPORTING

            APPLICATION                 = ‘TX’

            DEVICE                      = ‘PRINTER’

            DIALOG                      = ‘X’

            FORM                        = ‘ZBC_TEST’

            LANGUAGE                    = SY-LANGU

            OPTIONS                     = I_ITCPO

       EXCEPTIONS

            CANCELED                    = 1

            DEVICE                      = 2

            FORM                        = 3

            OPTIONS                     = 4

            UNCLOSED                    = 5

            MAIL_OPTIONS                = 6

            ARCHIVE_ERROR               = 7

            INVALID_FAX_NUMBER          = 8

            MORE_PARAMS_NEEDED_IN_BATCH = 9

            SPOOL_ERROR                 = 10

            OTHERS                      = 11.

*

ENDFORM.                    ” OPEN_FORM

&—-


*&      Form  CLOSE_FORM

&—-


  •       text

—-


  • –>  p1        text

  • <–  p2        text

—-


FORM CLOSE_FORM.

*

  DATA: ITCPP TYPE ITCPP.

  CALL FUNCTION ‘CLOSE_FORM’

       IMPORTING

            RESULT = ITCPP.

*

ENDFORM.                    ” CLOSE_FORM

Form Z_BCTEST (SE71): Create a sapscript form Z_BCTEST with a MAIN window. Include the BARCODE element into the main window.

 

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

      1. feng zhang
        Hi, Javier.
        I have searched on the Internet, but I didn’t found some useful methods. Now, I want to create a Z table,which stored the ASCII characters. In the Form: CHECKSUM-128, I think it’s no need to declare L_HEX , instead we can use SELECT statement to fetch corresponding value according to the TCODECS-CODE. Then CONCATENATE them into D_BARCODE.
        This is my immature idea, please advise.
        Regards,
        feng.
        (0) 
        1. Javier Perez-Ullivarri Post author
          Hi feng,
          I’ve tested this code in a Netweaver 6.4 and you were right . To solve the problem it’s necesary declare the variable “DATA L_HEX(4) TYPE X” and move L_HEX TO L_CHAR.

          You’ve the new version on the blog .

          Regards,
          Javier

          (0) 
            1. Javier Perez-Ullivarri Post author
              Hi,
              please test the new version to solve this problem. Your example has L_ASCII = ‘0097’ but in the new source code the ascii values aren’t begin with 00 ( L_ASCII = 97 ).

              Regards,
              Javier

              (0) 
  1. klaus stüven
    Hello Javier,
    Thank you for sharing your knowledge. Your post was a great help for me.
    But of course there is always a question remaining: Could you give me a hint
    – how to use the result-table BC_DEC in a smartform form textfield ?
    – and how to rotate the result ? (90° backwards)

    merry Christmas

    Sincerely
    klaus stueven

    (0) 
    1. Javier Perez-Ullivarri Post author
      Hi Klaus,
      good questions , rotate 90º has been a challenge for me . It’s easy , you only need to invert coordinates ( the final code will put on the blog ) :

            LOOP AT BC_DEC.

      *       Rotate 90
              IF ROTATE NE SPACE .
                 L_AUX = BC_DEC-X1.
                 BC_DEC-X1 = BC_DEC-Y1.
                 BC_DEC-Y1 = L_AUX.
                 L_AUX = BC_DEC-W1.
                 BC_DEC-W1 = BC_DEC-H1.
                 BC_DEC-H1 = L_AUX.
                 MODIFY BC_DEC.
              ENDIF .
           ENDLOOP.

      I’m not an expert in smartforms but the idea is to do a loop with the coordinates and draw each bar like a box. I’ll try to make an example .

      Regards

      (0) 
  2. Javier Perez-Ullivarri Post author
    Hello,
    you have a new version on the blog with the following enhancements:

    – Barcode Rotate 90º
    – Problem Conversion HEX to ASCII in Netweaver

    Please, send me your feedback to improve the code. I’m also interested if you’ve tested and it works correctly.

    Regards,
    Javier

    (0) 
  3. feng zhang
    Hi, Javier Perez-Ullivarr.As I’m a beginner and I’m not familiar with SAPScript, so there are so many places that I can’t understand.

    In FM z_barcode_create, I can’t understand the meaning of “X_INI, Y_INI, W_INI, H_INI”. Could you give a particular description of each parameter? And can you tell me why the values of “P_X_INI, P_Y_INI, P_W_INI, P_H_INI” in Z_BCTEST are “5,5,400,150”? Can they be other values?

    Regards,
    feng.

    (0) 
  4. Hernan Restrepo
    Dear Javier,

    I just wonder how to draw each black bar of the barcode using smartforms, what is the sentence to do it.. with Sapscripts we are using the ‘BOX’ sentence.

    Thanks a lot,

    Hernán Restrepo C.

    (0) 
  5. Ronaldo Torres
    Hi Javier,
    first, tnks for sharing this solution and congratulations.

    My question is: There is a techinical restriction to implement this solution in version 4.0B?
    Someone already used this solution?

    Tnks for attention.

    Ronaldo Torres

    (0) 

Leave a Reply