首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在WebDynpro报表中显示ABAP?

如何在WebDynpro报表中显示ABAP?
EN

Stack Overflow用户
提问于 2015-07-09 13:24:06
回答 1查看 2.2K关注 0票数 0

我刚开始编写ABAP代码几天,我有一项任务要从事务SE38调用报告,并且

报表的结果显示在WebDynPro应用程序SE80的屏幕上。

报告接受用户输入(例如:材料编号、材料类型、工厂、销售机构)。)作为查询的条件,WebDynPro应用程序必须允许用户在此参数中键入键。

在一些相关的文章中,他们谈到了使用SUBMIT rep EXPORTING LIST TO MEMORYCALL FUNCTION 'LIST_FROM_MEMORY',但到目前为止,我真的不知道实现它。

如有任何答复,将不胜感激。谢谢!

EN

回答 1

Stack Overflow用户

发布于 2015-07-28 16:37:24

您可以将其导出为PDF。因此,当用户单击链接时,您将运行转换并在浏览器窗口中显示该文件。

为此,首先使用以下代码创建一个作业:

代码语言:javascript
复制
  constants c_name type tbtcjob-jobname value 'YOUR_JOB_NAME'.

  data v_number type tbtcjob-jobcount.
  data v_print_parameters type pri_params.

  call function 'JOB_OPEN'
    exporting
      jobname          = c_name
    importing
      jobcount         = v_number
    exceptions
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      others           = 4.

  if sy-subrc = 0.
    commit work and wait.
  else.
    EXIT. "// todo: err handling here
  endif.

然后,需要获取打印机参数才能提交报告:

代码语言:javascript
复制
call function 'GET_PRINT_PARAMETERS'
  exporting
    destination            = 'LP01'
    immediately            = space
    new_list_id            = 'X'
    no_dialog              = 'X'
    user                   = sy-uname
  importing
    out_parameters         = v_print_parameters
  exceptions
    archive_info_not_found = 1
    invalid_print_params   = 2
    invalid_archive_params = 3
    others                 = 4.

v_print_parameters-linct = 55.
v_print_parameters-linsz = 1.
v_print_parameters-paart = 'LETTER'.

现在,您可以使用应用的过滤器提交报告。不要忘记向其添加作业参数,如下代码所示:

代码语言:javascript
复制
  submit your_report_name
         to sap-spool
         spool parameters v_print_parameters
         without spool dynpro
         with ...(insert all your filters here)
         via job c_name number v_number
         and return.

  if sy-subrc = 0.
    commit work and wait.
  else.
    EXIT. "// todo: err handling here
  endif.

在那之后,你结束工作:

代码语言:javascript
复制
  call function 'JOB_CLOSE'
    exporting
      jobcount             = v_number
      jobname              = c_name
      strtimmed            = 'X'
    exceptions
      cant_start_immediate = 1
      invalid_startdate    = 2
      jobname_missing      = 3
      job_close_failed     = 4
      job_nosteps          = 5
      job_notex            = 6
      lock_failed          = 7
      others               = 8.

  if sy-subrc = 0.
    commit work and wait.
  else.
    EXIT. "// todo: err handling here
  endif.

现在,工作将继续进行,您需要等待它完成。用一个循环来做。一旦工作完成,你可以得到它的线轴输出,并转换为PDF。

代码语言:javascript
复制
  data v_rqident type tsp01-rqident.

  data v_job_head type tbtcjob.

  data t_job_steplist type tbtcstep occurs 0 with header line.

  data t_pdf like tline occurs 0 with header line.

  do 200 times.

    wait up to 1 seconds.

    call function 'BP_JOB_READ'
      exporting
        job_read_jobcount     = v_number
        job_read_jobname      = c_name
        job_read_opcode       = '20'
      importing
        job_read_jobhead      = v_job_head
      tables
        job_read_steplist     = t_job_steplist
      exceptions
        invalid_opcode        = 1
        job_doesnt_exist      = 2
        job_doesnt_have_steps = 3
        others                = 4.

    read table t_job_steplist index 1.

    if not t_job_steplist-listident is initial.
      v_rqident = t_job_steplist-listident.
      exit.
    else.
      clear v_job_head.
      clear t_job_steplist.
      clear t_job_steplist[].
    endif.

  enddo.

  check not v_rqident is initial.

  call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
      src_spoolid              = v_rqident
      dst_device               = 'LP01'
    tables
      pdf                      = t_pdf
    exceptions
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      others                   = 12.

如果要通过HTTP发送它,也可能需要将其转换为BASE64。

代码语言:javascript
复制
  field-symbols <xchar> type x.
  data v_offset(10) type n.
  data v_char type c.
  data v_xchar(2) type x.
  data v_xstringdata_aux type xstring.
  data v_xstringdata type xstring.
  data v_base64data type string.
  data v_base64data_aux type string.

  loop at t_pdf.
    do 134 times.
      v_offset = sy-index - 1.
      v_char = t_pdf+v_offset(1).
      assign v_char to <xchar> casting type x.
      concatenate v_xstringdata_aux <xchar> into v_xstringdata_aux in byte mode.
    enddo.
    concatenate v_xstringdata v_xstringdata_aux into v_xstringdata in byte mode.
    clear v_xstringdata_aux.
  endloop.

  call function 'SCMS_BASE64_ENCODE_STR'
    exporting
      input  = v_xstringdata
    importing
      output = v_base64data.

  v_base64data_aux = v_base64data.

  while strlen( v_base64data_aux ) gt 255.
    clear t_base64data.
    t_base64data-data = v_base64data_aux.
    v_base64data_aux = v_base64data_aux+255.
    append t_base64data.
  endwhile.

  if not v_base64data_aux is initial.
    t_base64data-data = v_base64data_aux.
    append t_base64data.
  endif.

你就完蛋了!

希望能帮上忙。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31318844

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档