ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

使用ABAP创建QR Code(二维码)

2020-09-07 09:00:20  阅读:266  来源: 互联网

标签:FUNCTION Code name ABAP QR outputparams error TYPE ls


In the previous blog we discuss how to generate QRCode to enable it be scanned via mobile phone.

In that solution, the QRCode is generated and stored in a PDF file via ABAP webdynpro framework, we only provide the form template. In fact it is quite easy to adapt the solution to generate the PDF by ourselves, so that the QRCode could be used more flexibly in many other scenario for example as an attachment of email.

Note: it is still necessary to create a form interface and form template as described in the blog.

The report source code is below:

PARAMETERS: content TYPE string.
DATA:
  ls_outputparams TYPE sfpoutputparams,
  ls_docparams    TYPE sfpdocparams,
  ls_pdf_file        TYPE fpformoutput,
  ls_post            TYPE crmd_soc_post,
  lv_fm_name      TYPE rs38l_fnam.
ls_outputparams-noprint   = 'X'.
ls_outputparams-nopributt = 'X'.
ls_outputparams-noarchive = 'X'.
ls_outputparams-nodialog  = 'X'.
ls_outputparams-preview   = 'X'.
ls_outputparams-getpdf    = 'X'.
CALL FUNCTION 'FP_JOB_OPEN'
  CHANGING
    ie_outputparams = ls_outputparams
  EXCEPTIONS
    cancel                = 1
    usage_error        = 2
    system_error       = 3
    internal_error      = 4
    OTHERS              = 5.
CHECK sy-subrc = 0.
TRY.
    CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
      EXPORTING
        i_name        = 'ZPF_QRCODE' " put your own form template name here
      IMPORTING
        e_funcname = lv_fm_name.
  CATCH cx_fp_api_repository
        cx_fp_api_usage
        cx_fp_api_internal.
    RETURN.
ENDTRY.
ls_docparams-langu     = 'E'.
ls_docparams-country   = 'US'.
CALL FUNCTION lv_fm_name
  EXPORTING
    /1bcdwb/docparams  = ls_docparams
    qrcode_input            = content
  IMPORTING
    /1bcdwb/formoutput = ls_pdf_file
  EXCEPTIONS
    usage_error         = 1
    system_error       = 2
    internal_error      = 3
    OTHERS             = 4.
CHECK sy-subrc = 0.
CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
    usage_error    = 1
    system_error   = 2
    internal_error  = 3
OTHERS         = 4.

execute the report, the PDF binary is stored in ls_pdf_file-pdf.

It could be scanned by the QRCode scanner installed in my mobile phone:

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

标签:FUNCTION,Code,name,ABAP,QR,outputparams,error,TYPE,ls
来源: https://www.cnblogs.com/sap-jerry/p/13624943.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有