Saturday, 30 April 2022

Invoice sample code for PT QR codes

 

Below code will give QR code back in QRSTRING.

for this SIPT_VBRK should have entries for the given invoice docuemnt.

-------------------------------------------------------------------------------------------------------------

DATAsource_object_pt TYPE cl_sipt_qrcode_pt=>source_object_pt,

      qrc_get_param    TYPE cl_rdsv_qrcode=>qrcode_get_param,
      source_object    TYPE cl_rdsv_map_util_sd=>source_object_sd,
      key              TYPE cl_rdsv_map_util_sd=>keys_sd,
      ls_qr            TYPE sipt_s_invqrcode.
      

PARAMETERS p_vbeln TYPE vbeln_vf DEFAULT '1100200008'.

qrc_get_param-intca  'PT'.
qrc_get_param-source_type 'BILLING_DOCUMENT'.
key-vbeln  p_vbeln.  "'1100200007'.

DATA(lcl_dataNEW cl_sipt_map_qrc_pt_sd).

TRY.
    lcl_data->if_rdsv_map_get~read_source_object(
    EXPORTING key  key
    IMPORTING source_object  source_object ).

    lcl_data->if_rdsv_map_get~map(
    EXPORTING source_object  source_object
    IMPORTING target_object  source_object_pt ).

  CATCH cx_rdsv_map INTO DATA(exc_map).
    MESSAGE ID exc_map->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_map->if_t100_message~t100key-msgno
    WITH exc_map->if_t100_message~t100key-attr1.
ENDTRY.

TRY.
    BREAK-POINT.
    cl_rdsv_qrcode=>get_qrcode(
    EXPORTING get_param  qrc_get_param
    source_object source_object_pt
    IMPORTING qrcode  DATA(qr_result).

  CATCH cx_rdsv_qrcode INTO DATA(exc_qrc).
    MESSAGE ID exc_qrc->if_t100_message~t100key-msgid
    TYPE 'E'
    NUMBER exc_qrc->if_t100_message~t100key-msgno
    WITH exc_qrc->if_t100_message~t100key-attr1.
ENDTRY.

*ls_qr-qrstring =  condense( qr_result-qrstring ).
ls_qr-qrstring =  qr_result-qrstring.

No comments:

Post a Comment