ICode9

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

PDF 上传 Abap 获取OTF文档

2021-07-21 17:04:58  阅读:215  来源: 互联网

标签:sy gs data OTF Abap outputparams error PDF type


*&---------------------------------------------------------------------*
*& Report ZRICO_25
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*

report ztest_pdf2spool.

include fp_utilities. "#EC INCL_OK

data gv_cust_id type s_customer.
data: content type fpcontent.
data gs_outputparams type sfpoutputparams.
data: total_pages type fppagecount.

parameters: fpages type i modif id upl.

initialization.

start-of-selection.


perform upload_data.

perform set_outpars.
perform send_pdf_to_spool.

form send_pdf_to_spool.

data: size type i.
data: total_size type i.
data: spoolid type rspoid.
data: copies type rspocopies.
data: lifetime.

size = xstrlen( content ).
add size to total_size.

copies = gs_outputparams-copies.
lifetime = gs_outputparams-lifetime.

call function 'ADS_CREATE_PDF_SPOOLJOB'
exporting
dest = gs_outputparams-dest
pages = total_pages
pdf_data = content
name = gs_outputparams-dataset
suffix1 = gs_outputparams-suffix1
suffix2 = gs_outputparams-suffix2
copies = copies
immediate_print = gs_outputparams-reqimm
auto_delete = gs_outputparams-reqdel
titleline = gs_outputparams-covtitle
receiver = gs_outputparams-receiver
division = gs_outputparams-division
authority = gs_outputparams-authority
lifetime = lifetime
importing
spoolid = spoolid
exceptions
no_data = 1
not_pdf = 2
wrong_devtype = 3
operation_failed = 4
cannot_write_file = 5
device_missing = 6
no_such_device = 7
others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

message s060(ssfcomposer) with spoolid.


endform. " SEND_PDF_To_SPOOL


form upload_data.

include fp_spool_constants.

data: name type string,
filetype type char10,
filetable type filetable,
rc type i,
guiobj type ref to cl_gui_frontend_services,
uact type i.
data: datatab type table of ssfdata.
data: extension type string.
data: bin_filesize type i.
data: buffer type xstring.

extension = c_file_ext_pdf.
filetype = 'BIN'.
concatenate '*' extension into name.
create object guiobj.

call method guiobj->file_open_dialog
exporting
default_filename = name
changing
file_table = filetable
rc = rc
user_action = uact
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3.
if uact = guiobj->action_cancel.
leave program.
endif.

read table filetable index 1 into name.
check sy-subrc = 0.

call function 'GUI_UPLOAD'
exporting
filename = name
filetype = filetype
importing
filelength = bin_filesize
tables
data_tab = datatab
exceptions
file_open_error = 1
file_read_error = 2
invalid_type = 3
no_batch = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
leave program.
endif. "#EC *

*CALL FUNCTION 'WS_DOWNLOAD'
* EXPORTING
*   BIN_FILESIZE                  = '80400'
**   CODEPAGE                      = DATA_SIZE
*   FILENAME                      = 'C:\Users\itstudy\Desktop\aaaa2.txt'
*   FILETYPE                      = 'ASC'
**   MODE                          = ' '
**   WK1_N_FORMAT                  = ' '
**   WK1_N_SIZE                    = ' '
**   WK1_T_FORMAT                  = ' '
**   WK1_T_SIZE                    = ' '
**   COL_SELECT                    = ' '
**   COL_SELECTMASK                = ' '
**   NO_AUTH_CHECK                 = ' '
** IMPORTING
**   FILELENGTH                    = DATA_SIZE
*  TABLES
*    data_tab                      = datatab
**   FIELDNAMES                    =
* EXCEPTIONS
*   FILE_OPEN_ERROR               = 1
*   FILE_WRITE_ERROR              = 2
*   INVALID_FILESIZE              = 3
*   INVALID_TYPE                  = 4
*   NO_BATCH                      = 5
*   UNKNOWN_ERROR                 = 6
*   INVALID_TABLE_WIDTH           = 7
*   GUI_REFUSE_FILETRANSFER       = 8
*   CUSTOMER_ERROR                = 9
*   NO_AUTHORITY                  = 10
*   OTHERS                        = 11
*          .

call function 'SCMS_BINARY_TO_XSTRING'
exporting
input_length = bin_filesize
importing
buffer = buffer
tables
binary_tab = datatab
exceptions
failed = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
leave program.
endif.

content = buffer.
total_pages = fpages.

endform.

form set_outpars .

data: ls_outpars type sfpoutpar.

call function 'FPCOMP_SHOW_DIALOG'
changing
ie_outpar = ls_outpars
exceptions
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
others = 5.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
leave program.
else.
move-corresponding ls_outpars to gs_outputparams.
endif.

endform.

 

标签:sy,gs,data,OTF,Abap,outputparams,error,PDF,type
来源: https://www.cnblogs.com/Brokenshelltao/p/15040296.html

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

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

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

ICode9版权所有