天天看点

使用ABAP代码生成二维码(QR Code)

Previously we have discussed how to generate QRcode with SAP standard functionality:

(1) Generate QRcode with ABAP Webdynpro

(2) Generate QRcode with ABAP Code plus Adobe form template

Both solutions will generate QRCode within a PDF file.

If your requirement is to generate the QRCode in a picture file, you can use the solution described in this blog.

There are lots of websites which provide free QRCode generation service. Just google it:

使用ABAP代码生成二维码(QR Code)
使用ABAP代码生成二维码(QR Code)
使用ABAP代码生成二维码(QR Code)
使用ABAP代码生成二维码(QR Code)

DATA:ls_form   type zcl_http_tool=>ty_name_pair,

    lt_form   type zcl_http_tool=>tt_name_pair,

    lv_code   type xstring.

ls_form = value #( name = 'type' value = 'TEXT' ).

APPEND ls_form TO lt_form.

ls_form = value #( name = 'foreground_color' value = '000000' ).

ls_form = value #( name = 'ecc_level' value = 'L' ).

ls_form = value #( name = 'width_pixels' value = '200' ).

ls_form = value #( name = 'dpi' value = '72' ).

ls_form = value #( name = 'file_type' value = 'png' ).

ls_form = value #( name = 'text' value = 'testforQRCode' ).

zcl_http_tool=>send_request( EXPORTING iv_url      = 'http://www.qrstuff.com/generate.generate'

                                      iv_req_type = if_http_request=>co_request_method_get

                                      it_form     = lt_form

IMPORTING ev_response = lv_code ).

使用ABAP代码生成二维码(QR Code)

继续阅读