Chinaunix首页 | 论坛 | 博客
  • 博客访问: 126032
  • 博文数量: 60
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 0
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-25 18:14
个人简介

ABAP 小店http://ymhtea.taobao.com

文章分类

全部博文(60)

分类: WINDOWS

2014-03-29 18:28:08

原文地址:SAP smartform转PDF 作者:连老

REPORT zlianjf_test.
DATA:control_parameters TYPE ssfctrlop,
        output_options TYPE ssfcompop,
        job_output_info TYPE ssfcrescl.
DATA: fm_name TYPE rs38l_fnam.
DATA: p_e_devtype TYPE rspoptype.
DATA: p_language  TYPE  sflangu.
AT SELECTION-SCREEN OUTPUT.
START-OF-SELECTION.
  PERFORM open_smartform USING 'ZTEST_SF'.
*转成PDF
  IF NOT job_output_info-otfdata[] IS INITIAL.
    PERFORM convert_2_pdf.
  ENDIF.

END-OF-SELECTION.
*&--------------------------------------------------------------------*
*&      Form  open_smartform
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
*      -->F_FORM     text
*---------------------------------------------------------------------*
FORM open_smartform USING f_form.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = f_form
    IMPORTING
      fm_name            = fm_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.
  p_language = sy-langu.
  CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
    EXPORTING
      i_language    = p_language
      i_application = 'SAPDEFAULT'
    IMPORTING
      e_devtype     = p_e_devtype.
*发email
*output_options-xsfcmode = 'X'.
*output_options-xsf = space.
*output_options-xdfcmode = 'X'.
*output_options-xdf = space.
*发email
*转PDF
  output_options-tdprinter = p_e_devtype.
  control_parameters-no_dialog = 'X'.
  control_parameters-getotf = 'X'.
*转PDF
*标准输出预览,不弹对话框
* output_options-TDDEST = 'LP01'.
* control_parameters-PREVIEW = 'X'.
* control_parameters-no_dialog = 'X'.
*标准输出预览,不弹对话框

  CALL FUNCTION fm_name
    EXPORTING
      control_parameters = control_parameters
      output_options     = output_options
      user_settings      = ''    "严重注意该栏位的作用:默认是‘X’,如果是‘X’,那么上面的输出设备(TDDEST,tdprinter等)就会被忽略,直接从登陆用户的设置上带过来。
    IMPORTING
      job_output_info    = job_output_info
    EXCEPTIONS
      formatting_error   = 1
      internal_error=
      2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.
ENDFORM.                    "open_smartform
*&---------------------------------------------------------------------*
*&      Form  convert_2_PDF
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM convert_2_pdf.
* Converting to PDF Format
  DATA l_lines TYPE TABLE OF tline WITH HEADER LINE.
  DATA l_docs TYPE TABLE OF docs.
  DATA len TYPE i.
  CALL FUNCTION 'CONVERT_OTF_2_PDF'
    IMPORTING
      bin_filesize           = len
    TABLES
      otf                    = job_output_info-otfdata[]
      doctab_archive         = l_docs[]
      lines                  = l_lines[]
    EXCEPTIONS
      err_conv_not_possible? = 1
      err_otf_mc_noendmarker = 2
      OTHERS                 = 3.
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      bin_filesize = len
      filename     = 'c:\pdf.pdf'
      filetype     = 'BIN'
    CHANGING
      data_tab     = l_lines[]"i_objbin[]
    EXCEPTIONS
      OTHERS       = 1.
ENDFORM.                    "convert_2_PDF
阅读(1435) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~