1> Create smart form in Tcode: SMARTFORMS
YTEST_SF_001
Preview:
2> Create WDA Component
3> Assign UI elements to V_MAIN view:
Download file button and Interactive Form for displaying pdf
4> Design view context
Set supply function for Node N_PDF.
Db click SUPPLY_PDF
method supply_pdf .
data:
l_x
type char01 value 'X',
l_message type string,
l_form_name type tdsfname value 'YTEST_SF_001',
l_fm_name type
rs38l_fnam.
data: ls_control_parameters type ssfctrlop,
ls_output_options
type ssfcompop,
ls_ssf_output
type ssfcrescl.
data:
lt_otfdata
type table of itcoo.
* 1. get smartform
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname
= l_form_name
importing
fm_name
= l_fm_name
exceptions
no_form
= 1
no_function_module = 2
others
= 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into l_message.
return.
endif.
* Set relevant control parameters
ls_control_parameters-getotf
= l_x. "OTF
output
ls_control_parameters-no_dialog =
l_x. "No
print dialog
ls_control_parameters-preview =
space. "No preview
* Set relevant output options
ls_output_options-tdnewid
=
l_x.
"Print parameters,
ls_output_options-tddelete
= space. "Print
parameters,
ls_output_options-tddest
= 'LP01'.
"!!!Check your print device to ensure support UNICODE.
call function l_fm_name
exporting
*
ARCHIVE_INDEX
*
ARCHIVE_INDEX_TAB
*
RCHIVE_PARAMETERS
control_parameters
= ls_control_parameters
*
MAIL_APPL_OBJ
*
MAIL_RECIPIENT
*
MAIL_SENDER
output_options
= ls_output_options
user_settings
= space
*
pernr
= stru_input1-zpernr
*
reinr
= stru_input1-zreinr
*
pdvrs
= stru_input1-zpdvrs
importing
*
DOCUMENT_OUTPUT_INFO
job_output_info
= ls_ssf_output
*
JOB_OUTPUT_OPTIONS
exceptions
formatting_error
= 1
internal_error
= 2
send_error
= 3
user_canceled
= 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 into l_message.
return.
endif.
refresh lt_otfdata.
lt_otfdata[] = ls_ssf_output-otfdata[].
*2. Convert to PDF
data: l_dummy
type standard table of tline,
l_pdf_data type xstring,
l_pdf_size type i.
clear: l_pdf_data, l_pdf_size.
* convert otf to pdf
call function 'CONVERT_OTF'
exporting
format
= 'PDF'
importing
bin_filesize
= l_pdf_size
bin_file
= l_pdf_data
tables
otf
= lt_otfdata[]
lines
= l_dummy
exceptions
err_max_linewidth
= 1
err_format
= 2
err_conv_not_possible = 3
others
= 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into l_message.
return.
endif.
* 3. Bind pdf conent to node
** data declaration
data: ls_n_pdf type wd_this->element_n_pdf,
elem_pdf TYPE
REF TO if_wd_context_element.
ls_n_pdf-file_name =
l_form_name. " sample only
!
ls_n_pdf-content =
l_pdf_data. " sample only
!
*** bind a single element
node->bind_structure(
new_item
= ls_n_pdf
set_initial_elements = abap_true ).
endmethod.
5> Design button action to DOWNLOAD FILE.
Action source:
data: lo_nd_n_pdf type ref to if_wd_context_node,
lo_el_n_pdf type ref to if_wd_context_element.
data:
ls_n_pdf type
wd_this->element_n_pdf,
lv_content type
wd_this->element_n_pdf-content.
* navigate from
<CONTEXT> to
<N_PDF> via lead selection
lo_nd_n_pdf
= wd_context->get_child_node( name =
wd_this->wdctx_n_pdf ).
* get element via lead
selection
lo_el_n_pdf
= lo_nd_n_pdf->get_element( ).
* @TODO handle not set lead
selection
if lo_el_n_pdf is initial.
return.
endif.
* get single attribute
lo_el_n_pdf->get_attribute(
exporting
name = `CONTENT`
importing
value = lv_content ).
call method
cl_wd_runtime_services=>attach_file_to_response
exporting
i_filename
= 'YTEST001_FORM'
i_content
= lv_content
i_mime_type
= 'PDF'
*
i_in_new_window = ABAP_FALSE
*
i_inplace
= ABAP_FALSE
.
6> Test Application
分享到:
相关推荐
Unit 1: Introduction to Floorplan Manager (FPM) for Web Dynpro ABAP 1 Exercise 1: Create Components Containing the UIBBs for a Floorplan and Implement Interface IF_FPM_UI_BUILDING_BLOCK Unit 2: FPM...
This document explains step by step how to display a smartform as a PDF document in Web Dynpro for ABAP. It explains how to create the Web Dynpro application and the code for displaying smartform as ...
本节中主要记录WebDynpro For ABAP的基础操作.如各种UI Elment的使用,Context的使用等.
Controlling external windows
SAP WEB Dynpro for ABAP 简单ALV 展示 SAP WEB Dynpro for ABAP 简单ALV 展示SAP WEB Dynpro for ABAP 简单ALV 展示
Floorplan Manager for Web Dynpro ABAP ABAP FPM 2014版
The Structural Concepts of Web Dynpro Components.PDF Web Dynpro ABAP Programming Guidelines.PDF
SAP标准官方教程,webdynpro for ABAP高级 教程 NET313 - Floorplan Manager for Web Dynpro ABAP,免费下载
Web Dynpro ABAP for Practitioners
Web Dynpro for ABAP Tutorial
Webdynpro for ABAP tutorial
SAP Web Dynpro for ABAP 图片上传及使用
SAP WDA 详解
Floorplan Manager for Web Dynpro ABAP-basic FPM 基本概念
WebDynpro for ABAP WebDynpro for ABAP WebDynpro for ABAP WebDynpro for ABAP
一个webdynpro的手册,适于初学者快速上手webdynpro,虽然是英文但是很简单易懂
以图例方式介绍Web Dynpro与Flash Island之间关系,并以实例一步一步展示Web Dynpro Abap与Flash Island的应用开发.