FUNCTION z_einvoice_qrcode_from_table.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(INVOICE_NO) TYPE VBELN_VF
*" EXPORTING
*" REFERENCE(QRCODE_HEXSTR) TYPE EDOC_SA_XSTRING
*" REFERENCE(QRCODE_STRING) TYPE STRING
*" REFERENCE(QRCODE_BASE64) TYPE STRING
*" EXCEPTIONS
*" NO_INVOICE
*"----------------------------------------------------------------------
* For this FM to give QR value result in base64 encoding, XML should
* have been successfully generated from transaction EDOC_COCKPIT against
* the invoice.
*"----------------------------------------------------------------------
DATA: v_guid TYPE edoc_guid.
SELECT SINGLE edoc_guid FROM edocument INTO v_guid
WHERE source_key = invoice_no.
IF sy-subrc = 0.
SELECT SINGLE qr_code FROM edosainv INTO qrcode_hexstr
WHERE edoc_guid = v_guid.
IF sy-subrc = 0.
PERFORM convert_hex_to_str USING qrcode_hexstr CHANGING qrcode_string.
***************Encode String to Base64*********************
CALL METHOD cl_http_utility=>if_http_utility~encode_base64
EXPORTING
unencoded = qrcode_string
RECEIVING
encoded = qrcode_base64.
ENDIF.
ELSE.
RAISE no_invoice.
ENDIF.
ENDFUNCTION.
*&---------------------------------------------------------------------*
*& Form CONVERT_HEX_TO_STR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_HEX text
* <--P_STR text
*----------------------------------------------------------------------*
FORM convert_hex_to_str USING p_hex
CHANGING p_str.
* CALL FUNCTION 'HR_RU_CONVERT_HEX_TO_STRING'
* EXPORTING
* xstring = p_hex
* IMPORTING
* cstring = p_str.
DATA: loc_conv TYPE REF TO cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input = p_hex
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true
RECEIVING
conv = loc_conv.
TRY.
CALL METHOD loc_conv->read
IMPORTING
data = p_str.
CATCH cx_sy_conversion_codepage. "Should ignore errors in code conversions
CATCH cx_sy_codepage_converter_init."Should ignore errors in code conversions
CATCH cx_parameter_invalid_type.
CATCH cx_parameter_invalid_range.
ENDTRY.
ENDFORM.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |