ABAP生成二维码

方法1:文档链接:https://blogs.sap.com/2016/05/12/qr-code-or-2d-bar-code-in-sap/

如果sap 版本是722以上,则可以直接在se73 中选择system bar code 中 创建 qr code 2005即可使用。

唯一的问题是不支持中文


方法2:

https://blogs.sap.com/2014/02/24/%E7%94%A8abap%E7%94%9F%E6%88%90%E4%BA%8C%E7%BB%B4%E7%A0%81/

Create Program to Download the QR Code as BMP (image File)

Write the below code in the SE38 Program. This Program can download the QR Code as image (.bmp format) on your presentation system.

*YOTQR starts

*&———————————————————————*

*& Report  YOTQR2 this program dirctly print BMP file of any barcode

*&

*&———————————————————————*

*&

*&

*&———————————————————————*

REPORT YOTQR.

PARAMETERS: barcode like tfo05-tdbarcode default ‘ZQRCODE’,

            barcdata(50) type c lower case default ‘1234567890’,

            filename type string LOWER CASE default ‘d:\1.bmp’.

DATA:errmsg(80)   TYPE c,

      bc_cmd       LIKE itcoo,

      bp_cmd       LIKE itcoo,

      bitmapsize   TYPE i,

      bitmap2_size TYPE i,

      w            TYPE i,

      h            TYPE i,

      bitmap       LIKE rspolpbi OCCURS 10 WITH HEADER LINE,

      bitmap2      LIKE rspolpbi OCCURS 10 WITH HEADER LINE,

      l_bitmap     TYPE xstring,

      otf          LIKE itcoo OCCURS 10 WITH HEADER LINE.

PERFORM get_otf_bc_cmd  IN PROGRAM sapmssco

                       USING barcode

                             barcdata

                             bc_cmd.

CHECK sy-subrc = 0.

bp_cmd-tdprintcom = ‘BP’.

PERFORM get_otf_bp_cmd  IN PROGRAM sapmssco

                       USING barcode

                             bp_cmd-tdprintpar.

CHECK sy-subrc = 0.

PERFORM renderbarcode IN PROGRAM sapmssco

                     TABLES bitmap

                      USING bc_cmd

                            bp_cmd

                            barcdata

                            bitmapsize

                            w

                            h

                            errmsg.

CHECK sy-subrc = 0.

perform bitmap2otf IN PROGRAM sapmssco

                   tables bitmap

                          otf

                    using bitmapsize

                          w

                          h.

data length type i.

data hex type xstring.

data bitmap3 type xstring.

FIELD-SYMBOLS  <fs>   type x.

clear: hex, bitmap3.

loop at otf.

  length = otf-tdprintpar+2(2).

  assign otf-tdprintpar+4(length) to <fs> casting.

  hex = <fs>(length).

  concatenate bitmap3 hex into bitmap3 in BYTE MODE.

endloop.

* convert from old format to new format

hex = ‘FFFFFFFF01010000’.

CONCATENATE bitmap3(8) hex bitmap3+8 into bitmap3 in BYTE MODE.

clear hex.

shift hex right by 90 places in BYTE MODE.

CONCATENATE bitmap3(42) hex bitmap3+42 into bitmap3 in BYTE MODE.

data bitmap4 type SBDST_CONTENT.

  CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’

    EXPORTING

      buffer                = bitmap3 ” xstring

    TABLES

      binary_tab            = bitmap4.

data bitmap4_size type i.

bitmap4_size = xstrlen( bitmap3 ).

CALL FUNCTION ‘SAPSCRIPT_CONVERT_BITMAP’

EXPORTING

   OLD_FORMAT                     = ‘BDS’

   NEW_FORMAT                     = ‘BMP’

   BITMAP_FILE_BYTECOUNT_IN       = bitmap4_size

IMPORTING

   BITMAP_FILE_BYTECOUNT          = bitmap2_size

  TABLES

    bitmap_file                    = bitmap2

   BDS_BITMAP_FILE                = BITMAP4

EXCEPTIONS

   NO_BITMAP_FILE                 = 1

   FORMAT_NOT_SUPPORTED           = 2

   BITMAP_FILE_NOT_TYPE_X         = 3

   NO_BMP_FILE                    = 4

   BMPERR_INVALID_FORMAT          = 5

   BMPERR_NO_COLORTABLE           = 6

   BMPERR_UNSUP_COMPRESSION       = 7

   BMPERR_CORRUPT_RLE_DATA        = 8

   BMPERR_EOF                     = 9

   BDSERR_INVALID_FORMAT          = 10

   BDSERR_EOF                     = 11.

  CALL METHOD cl_gui_frontend_services=>gui_download

    EXPORTING

      bin_filesize = bitmap2_size

      filename     = filename

      filetype     = ‘BIN’

    CHANGING

      data_tab     = bitmap2[]

    EXCEPTIONS

      OTHERS       = 3.

*YOTQR Ends


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SAP_Damon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值