**Declaration of Data and Variables
TABLES : marc.
TYPES: BEGIN OF ty_data,
matnr TYPE matnr,
werks TYPE werks_d,
ekgrp TYPE ekgrp,
END OF ty_data.
DATA: it_data TYPE STANDARD TABLE OF ty_data INITIAL SIZE 1,
wa_data TYPE ty_data.
DATA: lv1(50) TYPE c.
DATA: lv_qrcode TYPE xstring.
DATA:lv_qrcode_link TYPE string.
**Selection Screen
SELECT-OPTIONS: s_matnr FOR marc-matnr.
**Start of selection Event.
START-OF-SELECTION.
SELECT DISTINCT matnr, werks, ekgrp FROM marc INTO TABLE @it_data
UP TO 2 ROWS WHERE matnr IN @s_matnr.
IF sy-subrc EQ 0.
SORT it_data BY matnr.
LOOP AT it_data INTO wa_data.
lv1 = wa_data-matnr.
CONCATENATE lv_qrcode_link lv1 INTO lv_qrcode_link SEPARATED BY space.
CLEAR:lv1.
lv1 = wa_data-werks.
CONCATENATE lv_qrcode_link lv1 INTO lv_qrcode_link SEPARATED BY space.
CLEAR:lv1.
lv1 = wa_data-ekgrp.
CONCATENATE lv_qrcode_link lv1 INTO lv_qrcode_link SEPARATED BY space.
CLEAR:lv1.
ENDLOOP.
CONDENSE lv_qrcode_link .
ENDIF.
******Generate the qr Code
TRY.
CALL METHOD cl_rstx_barcode_renderer=>qr_code
EXPORTING
i_module_size = 200
* i_mode = 'A'
i_error_correction = 'L'
* i_rotation = 0
i_barcode_text = lv_qrcode_link
IMPORTING
e_bitmap = lv_qrcode.
**************Download file
DATA(it_raw_data) = cl_bcs_convert=>xstring_to_solix( EXPORTING iv_xstring = lv_qrcode ).
cl_gui_frontend_services=>gui_download( EXPORTING
filename = 'QRcode.jpg'
filetype = 'BIN'
bin_filesize = xstrlen( lv_qrcode )
CHANGING
data_tab = it_raw_data ).
CATCH cx_rstx_barcode_renderer .
ENDTRY.
Input :
Output:
By scanning the QR code we get :
000000000000030000029 10A2 103
000000000000030000029 10A9 103
No comments:
Post a Comment