惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 热门话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
V
V2EX
GbyAI
GbyAI
量子位
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
G
Google Developers Blog
云风的 BLOG
云风的 BLOG
B
Blog
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
O
OpenAI News
N
News and Events Feed by Topic
博客园 - Franky
爱范儿
爱范儿
Forbes - Security
Forbes - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V2EX - 技术
V2EX - 技术
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Schneier on Security
Schneier on Security
Cloudbric
Cloudbric
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
人人都是产品经理
人人都是产品经理
P
Privacy International News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
Last Week in AI
Last Week in AI
罗磊的独立博客
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
The Cloudflare Blog
Google DeepMind News
Google DeepMind News
AWS News Blog
AWS News Blog
The Register - Security
The Register - Security
Y
Y Combinator Blog
J
Java Code Geeks
I
Intezer

博客园 - 老白先生

webpack4+vue2+axios+vue-router的多页+单页混合应用框架 用文本增强修改SAP标准屏幕中的字段名称 ABAP:ALV的 Header中添加HTML内容 BDC处理时用到结构--BDCDATA FI 相关table的说明 ABAP:FI常用BAPI ABAP 自动生成EXCEL文件并作简单格式处理 smartform中打印bseg-wrbtr(凭证货币金额)字段的问题 Complex LUW processing (internal/external Session) ABAP 动态内表构建 Dynamic internal table AT LINE-SELECTION SAP:建表时如果有QUAN、CURR类型的字段不能激活的问题 关于SAP LUW ABAP:关于隐式与显式的DB Commit ABAP笔记:BDC完整版例子 SAP:Authority-check 加入收藏夹功能(jQuery) 成功的秘密? ERP流程的一个生动的例子
ABAP:Smartform生成PDF
老白先生 · 2011-09-30 · via 博客园 - 老白先生
注意:生成PDF时,Smartform中的参数  control_parameters-getotf = 'X'. 必须
 
 
*&---------------------------------------------------------------------*
*& REPORT       ZHARPO_010
*&
*&---------------------------------------------------------------------*
*&
*& Smartform生成PDF,可设置不显示Smartform打印窗口
*&---------------------------------------------------------------------*
 
REPORT zharpo_010 NO STANDARD PAGE HEADING.
 
TABLES rlgrap.
DATA fm_name TYPE rs38l_fnam.
DATA control_parameters TYPE ssfctrlop.
DATA job_output_info    TYPE ssfcrescl.
DATA job_output_options TYPE ssfcresop.
DATA itab TYPE TABLE OF bkpf.
DATA BEGIN OF pdf OCCURS 10.
        INCLUDE STRUCTURE tline.
DATA END OF pdf.
DATA len TYPE i.  "PDF文件大小
 
PARAMETERS filename TYPE rlgrap-filename.
 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.
  PERFORM f4_file_save CHANGING filename.
 
 
START-OF-SELECTION.
  SELECT bukrs belnr bldat
    UP TO 300 ROWS
    INTO CORRESPONDING FIELDS OF TABLE itab
    FROM bkpf.
 
  control_parameters-getotf    = 'X'.   "此参数必须,否则不会导出PDF而直接显示smartform
  control_parameters-no_close  = ' '.
  control_parameters-no_dialog = 'X'.   "不显示打印对话框
 
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = 'ZHARPO_001'
    IMPORTING
      fm_name            = fm_name
    EXCEPTIONS
      no_form            = 1
      no_function_module = 2
      OTHERS             = 3.
 
  CHECK: sy-subrc = 0.
 
  CALL FUNCTION fm_name
    EXPORTING
      control_parameters = control_parameters
    IMPORTING
      job_output_info    = job_output_info
      job_output_options = job_output_options
    TABLES
      itab2              = itab
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.
 
  CHECK: sy-subrc = 0.
 
* convert smartforms to PDF
  CALL FUNCTION 'CONVERT_OTF'
    EXPORTING
      format                = 'PDF'
    IMPORTING
      bin_filesize          = len
    TABLES
      otf                   = job_output_info-otfdata
      lines                 = pdf
    EXCEPTIONS
      err_max_linewidth     = 1
      err_format            = 2
      err_conv_not_possible = 3
      OTHERS                = 4.
 
  CHECK: sy-subrc = 0.
 
  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      filename            = filename
      filetype            = 'BIN'
      bin_filesize        = len
    TABLES
      data_tab            = pdf
    EXCEPTIONS
      file_open_error     = 1
      file_write_error    = 2
      invalid_filesize    = 3
      invalid_table_width = 4
      invalid_type        = 5
      no_batch            = 6
      unknown_error       = 7
      OTHERS              = 8.
 
  IF sy-subrc <> 0.
    MESSAGE 'ERROR!' TYPE 'E'.
  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  F4_FILE_SAVE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_FILENAME  text
*----------------------------------------------------------------------*
FORM f4_file_save  CHANGING p_file.
  DATA: l_file TYPE string.
  DATA: l_path TYPE string.
  DATA: l_fullpath TYPE string.
 
  l_file = p_file.
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      default_file_name    = l_file
      initial_directory    = l_path
    CHANGING
      filename             = l_file
      path                 = l_path
      fullpath             = l_fullpath
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.
 
  IF sy-subrc = 0.
    p_file = l_fullpath.
  ELSE.
 
  ENDIF.
ENDFORM.                    " F4_FILE_OPEN