(转)SAP 将smartforms的报表转成PDF

SAP将smartforms的报表转成PDF
方法一:
通过调用系统程序:RSTXPDFT4将SAPscript (OTF)或 ABAP 清单假脱机作业转换到 PDF
  选择画面条件
     假脱机请求    ⇒ smartforms的脱机打印号
     PDF文件名    ⇒ 需要进行保存的pdf文件及路径  
 
举例如下:
*调用SAP转PDF的程序
SUBMIT RSTXPDFT4 VIA SELECTION-SCREEN
                 WITH SPOOLNO = LW_SP00LIDS         选择画面上的脱机打印机号
                 AND  RETURN. 
 
方法二:
获取SMARTFORMS的函数ID:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = 'ZXXX'      *此处为smartform名字
  IMPORTING
    fm_name            = fm_name
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2
    OTHERS             = 3.
 
执行SMARTFORMS
CALL FUNCTION fm_name
  EXPORTING
    control_parameters = cparam    
*   HTH                = HTH             此处传入参数
    output_options     = outop
    user_settings      = space
  IMPORTING
    job_output_info    = tab_otf_data
  EXCEPTIONS
    formatting_error   = 1
    internal_error     = 2
    send_error         = 3
    user_canceled      = 4
    OTHERS             = 5.
 
tab_otf_final[] = tab_otf_data-otfdata[].
通过函数:CONVERT_OTF  将smartforms转换为PDF
************ converting OTF data into pdf data**************************
CALL FUNCTION 'CONVERT_OTF'
  EXPORTING
    format                  = 'PDF'
    max_linewidth           = 132
*   ARCHIVE_INDEX           = ' '
*   COPYNUMBER              = 0
*   ASCII_BIDI_VIS2LOG      = ' '
  IMPORTING
    bin_filesize            = bin_filesize
  TABLES
    otf                     = tab_otf_final
    lines                   = pdf_tab
  EXCEPTIONS
    err_max_linewidth       = 1
    err_format              = 2
    err_conv_not_possible   = 3
    err_bad_otf             = 4
    OTHERS                  = 5.
 
PDF文件下载
CALL FUNCTION 'GUI_DONLOAD'
  EXPORTING
    bin_filesize            = bin_filesize
    filename                = 'D:\TEST.PDF'
    filetype                = 'BIN'
  IMPORTING
    filelength              = file_size
  TABLES
    data_tab                = pdf_tab
*   FIELDNAMES              =
  EXCEPTIONS
    file_write_error        = 1
    no_batch                = 2
    gui_refuse_filetransfer = 3
    invalid_type            = 4
    no_authority            = 5
    unknown_error           = 6
    header_not_allowed      = 7
    separator_not_allowed   = 8
    filesize_not_allowed    = 9
    header_too_long         = 10
    dp_error_create         = 11
    dp_error_send           = 12
    dp_error_write          = 13
    unknown_dp_error        = 14
    access_denied           = 15
    dp_out_of_memory        = 16
    disk_full               = 17
    dp_timeout              = 18
    file_not_found          = 19
    dataprovider_exception  = 20
    control_flush_error     = 21
    OTHERS                  = 22.
posted @ 2018-08-23 18:58  陈一清  阅读(568)  评论(0编辑  收藏  举报