Generate QR Code with ABAP

In addition to using my blog Step by step to create QRCode in ABAP Webdynpro to generate a QR code using ABAP webdynpro, you can also generate a QR code by using the QR code to generate the service provided by the website online.

QR code online generation website:

http://www.makepic.com/qrcode.php

Enter the QR code data source, verification level and image size to be generated on the webpage, click Generate to see the generated QR code image:

The following is the code for generating a QR code using the above service using ABAP code:

DATA:ls_form type zcl_http_tool=>ty_name_pair,
lt_header type zcl_http_tool=>tt_name_pair,
lt_form type zcl_http_tool=>tt_name_pair,
lv_code type xstring.

ls_form = value #( name = 'data' value = 'testforQRCode' ).
APPEND ls_form TO lt_form.

ls_form = value #( name = 'level' value = 'M' ).
APPEND ls_form TO lt_form.

ls_form = value #( name = 'size' value = '6' ).
APPEND ls_form TO lt_form.

zcl_http_tool=>send_request( iv_url = 'http://www.makepic.com/qrcode.php'
iv_req_type = if_http_request=>co_request_method_post
it_form = lt_form ).

ls_form = value #( name = 'Referer' value = 'http://www.makepic.com/qrcode.php' ).

APPEND ls_form TO lt_header.

zcl_http_tool=>send_request( EXPORTING iv_url = 'http://www.makepic.com/mkqr.php?data=testforQRCode&level=M&size=6'
iv_req_type = if_http_request=>co_request_method_get
it_header = lt_header
IMPORTING ev_response = lv_code ).

testforQRCode corresponds to the generated QR code:

 

It can be successfully scanned with the QR code scanning application on the mobile phone:

 

The code of zcl_http_tool is on my github (because it is used for demo purposes, there is no corresponding error handling)

To get more original technical articles from Jerry, please follow the public account "Wang Zixi" or scan the QR code below:

 

 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326165487&siteId=291194637