Thursday, November 16, 2023

Report For Generate The QR code As per input selection.

 


**Declaration of Data and Variables
TABLES marc.

TYPESBEGIN OF ty_data,
         matnr TYPE matnr,
         werks TYPE werks_d,
         ekgrp TYPE ekgrp,
       END OF ty_data.

DATAit_data TYPE STANDARD TABLE OF ty_data INITIAL SIZE 1,
      wa_data TYPE ty_data.

DATAlv1(50)  TYPE c.
DATAlv_qrcode TYPE xstring.
DATA:lv_qrcode_link TYPE string.

**Selection Screen
SELECT-OPTIONSs_matnr FOR marc-matnr.

**Start of selection Event.

START-OF-SELECTION.

  SELECT DISTINCT matnrwerksekgrp FROM marc INTO TABLE @it_data 

UP TO 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_solixEXPORTING iv_xstring lv_qrcode ).
      cl_gui_frontend_services=>gui_downloadEXPORTING
                                              filename 'QRcode.jpg'
                                              filetype =  'BIN'
                                              bin_filesize =  xstrlenlv_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

Translation of language in Smart Forms.

  Step by Step process to Translate English language to Spanish language in smart form. 1. Go to T-Code SE63 in command bar and then enter. ...