Escolar Documentos
Profissional Documentos
Cultura Documentos
Recently we have encountered a security problem during sending PDF documents to external mail
addresses. Working on the issue we detected that the reason why we can not send PDF attachments is a
new security policy applied by the company IT department. According to this new policy every document
is classified considering its security class like private,restricted,classified etc. After carrying out this new
policy they have forbidden to send some document types to external mail accounts.
In this scenario, automatic mails sent by SAP system are blocked by mail server , so we had to implement
a solution in SAP application which is sending PDF documents as attachment.Firstly attachments were
created by a background job which was converting an SAP SmartForms print-out into Adobe PDF format
and then sending it via mail.convert smartforms into PDF format and download to your local post gives a
brief implementation of this process. Besides this ,classification of PDF documents was done by adding
some metadata to Adobe PDF print-out. You can navigate to this metadata in Adobe PDF document by
Cntrl+D shortcut or File->Properties.
In this post my ultimate aim is adding metadata to PDF document, that is filling required fields in
properties of PDF document namely the Key fields. In order to achieve this i had make use of
FP_PDF_TEST_23 .This report is developed by SAP for setting dynamic metadata in PDF file. I have copied
required part of standard code and adapt to my need.
Below steps summarizes the process.
For ABAP side , my template is below. You should adapt it to meet your needs.
1 *&---------------------------------------------------------------------*
2 *& Report ZYA_ADD_METADATA_PDF
3 *&
4 *&---------------------------------------------------------------------*
5 report zya_add_metadata_pdf.
6
7 start-of-selection .
8
9 perform add_metadata_pdf.
10
11 *&---------------------------------------------------------------------*
12 *& Form add_metadata_pdf
13 *&---------------------------------------------------------------------*
14 form add_metadata_pdf .
15
16 data: lt_otf type itcoo occurs 0 with header line,
17 lt_tline type table of tline with header line,
18 ls_ctrlop type ssfctrlop,
19 ls_compop type ssfcompop,
20 ls_return type ssfcrescl,
21 lv_form_name type rs38l_fnam,
22 lv_bin_filesize type i,
23 lt_lines type standard table of tline.
24 data: l_fp type ref to if_fp,
25 l_pdfobj type ref to if_fp_pdf_object,
26 l_pdf type fpcontent,
27 l_meta type sfpmetadata,
28 l_word type string,
29 l_fpex type ref to cx_fp_runtime,
30 lv_content type xstring.
31
32 * get function module name for smartform
33 call function 'SSF_FUNCTION_MODULE_NAME'
34 exporting
35 formname = 'ZYA_SAMARTFORM'
36 importing
37 fm_name = lv_form_name
38 exceptions
39 no_form =1
40 no_function_module = 2
41 others = 3.
42 if sy-subrc <> 0.
43 message id sy-msgid type sy-msgty number sy-msgno
44 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
45 endif.
46
47 * call smartform with relevant parameters
48 ls_ctrlop-getotf = 'X'.
49 ls_ctrlop-no_dialog = 'X'.
50 ls_compop-tdnoprev = 'X'.
51
52 call function lv_form_name
53 exporting
54 control_parameters = ls_ctrlop
55 output_options = ls_compop
56 user_settings = 'X'
57 importing
58 job_output_info = ls_return
59 exceptions
60 formatting_error = 1
61 internal_error = 2
62 send_error =3
63 user_canceled = 4
64 others = 5.
65 if sy-subrc <> 0.
66 message id sy-msgid type sy-msgty number sy-msgno
67 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
68 endif.
69
70 * get OTF into table
71 lt_otf[] = ls_return-otfdata[].
72
73 * convert OTF to 132 char PDF lines
74 call function 'CONVERT_OTF'
75 exporting
76 format = 'PDF'
77 max_linewidth = 132
78 importing
79 bin_filesize = lv_bin_filesize
80 bin_file = lv_content
81 tables
82 otf = lt_otf
83 lines = lt_lines
84 exceptions
85 err_max_linewidth = 1
86 err_format =2
87 err_conv_not_possible = 3
88 err_bad_otf =4
89 others = 5.
90
91
92 * add metadata to PDF document
93 *----
94 l_pdf = lv_content.
95
96 * Get FP reference.
97
98 l_fp = cl_fp=>get_reference( ).
99
100 try.
101 * Create PDF Object.
102 l_pdfobj = l_fp->create_pdf_object( connection = 'ADS' ).
103
104 * Set document.
105 l_pdfobj->set_document( pdfdata = l_pdf ).
106
107 * Set metadata.
108 move: 'Title' to l_meta-title,
109 'Subject' to l_meta-subject,
110 'Author' to l_meta-author.
111 move 'SecurityClass =' to l_word.
112 insert l_word into table l_meta-keywords.
113 move 'SecurityClassNumber' to l_word.
114 insert l_word into table l_meta-keywords.
115 l_pdfobj->set_metadata( metadata = l_meta ).
116
117 * Execute, call ADS.
118 l_pdfobj->execute( ).
119
120 * Get result.
121 l_pdfobj->get_document( importing pdfdata = l_pdf ).
122
123 catch cx_fp_runtime_internal
124 cx_fp_runtime_system
125 cx_fp_runtime_usage into l_fpex.
126 perform error using l_fpex.
127 endtry.
128 *----
129
130
131 * Download result PDF
132 perform download_file using l_pdf 'C:\Users\yavuz.asik\Desktop\metadata.pdf'.
133
134 endform. " CONVERT_PDF
135 *&-----------------------------------------------
136 *&---------------------------------------------------------------------*
137 *& Form error
138 *&---------------------------------------------------------------------*
139 * create error text
140 *----------------------------------------------------------------------*
141 form error using p_exception type ref to cx_fp_runtime. "#EC CALLED
142 data lv_type type string.
143 data lx_system type ref to cx_fp_runtime_internal.
144
145 lv_type = substring_after(
146 val = cl_abap_classdescr=>get_class_name( p_exception )
147 sub = 'RUNTIME_' ).
148 * Create an exception object to display the message in order to allow
149 * the user to request the display in a pop-up window.
150 create object lx_system
151 exporting
152 textid = cx_fp_runtime_internal=>generic
153 errmsg = |{ lv_type } ERROR: { p_exception->get_text( ) }|.
154 message lx_system type 'E'.
155 endform. "error
156 *&-----------------------------------------------
157 *&---------------------------------------------------------------------*
158 *& Form download_file
159 *&---------------------------------------------------------------------*
160 * Download a file to the frontend.
161 *----------------------------------------------------------------------*
162 form download_file using p_data type xstring
163 p_file type localfile. "#EC CALLED
164 data: l_len type i,
165 l_tab type tsfixml,
166 l_filename type string.
167
168 call function 'SCMS_XSTRING_TO_BINARY'
169 exporting
170 buffer = p_data
171 importing
172 output_length = l_len
173 tables
174 binary_tab = l_tab.
175 move p_file to l_filename.
176 call method cl_gui_frontend_services=>gui_download
177 exporting
178 bin_filesize = l_len
179 filename = l_filename
180 filetype = 'BIN'
181 changing
182 data_tab = l_tab
183 exceptions
184 others = 1.
185 if sy-subrc is initial.
186 message id 'VER_MESSAGES' type 'S' number '082' with p_file.
187 else.
188 message id 'VER_MESSAGES' type 'E' number '083'.
189 endif.
190 endform. "download_file
Go to top
Welcome, Guest
Login
Register
Registration
Close
Getting Started
Store
Top of Form
Search the C
Bottom of Form
Skip to content
Skip to breadcrumbs
SCN Wiki
Spaces
Browse
Pages
Labels
Space Operations
Top of Form
Search
Quick Search
Bottom of Form
Help
Online Help
Keyboard Shortcuts
Feed Builder
What’s new
About Confluence
Attachments (8)
Page History
Page Information
Link to this Page…
View in Hierarchy
View Source
Export to PDF
Export to Word
Go to start of metadata
The user exit for the signature process in the PM application is realized with a BADI.
This BADI implements the digital signature process for PM Maintenance Plans (per master data,
items, scheduling separate).
The BADI will be invoked in any case when related maintenance plan data have been changed and
the user activates the "save" button. The specified data will be transferred to the signature tool as
an ASCII string (document) and saved on the database after the applications "commit work".
When the SAVE event is invoked in any of these transactions, the signature pop-up is displayed.
This displays the fields in the Maintenance Plan, a place for comments, remarks, reason for change
and the user id and password.
Once the password passes validation, the Maintenance Plan/Item is saved and the electronic
document is also saved.
METHODS:
Create an implementation of BADI: CJ_DSAL_FUNC, which is the BADI for DSAL for Including
Customer Functions.
METHODS:
GET_MULTI (Information for multiple marked rows (not used in this application)
For ECC 6.0, you will also need to change some of the classes, interfaces and methods being used in
the GET_SINGLE method.
For the new code you can refer to the blog -
https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14032\\
e-signature
for
maintenance
plants-
master
data
ecc
mdm_erp
Overview
Content Tools
Add-ons
Pages
Labels
Space Operations
Follow SCN
Contact Us
Privacy
Terms of Use
Legal Disclosure
Copyright
Cookie Preferences
Privacy Statement
You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In
if you already have an account.
search
attachments
weblink
Functional Questions
What release introduces this functionality?
What is the required customizing to enable this functionality for PM orders?
How do I set a digital signature for an order operation?
How do I display a digital signature for an order operation?
Technical Questions
How is the account assignment between operations and digital signatures
defined?
Answers to Functional Questions
What release introduces this functionality?
This functionality is available from release ECC 603.
A record is added to table AFVC_DS, this table stores the account assignment between a digital signature and an
operation..
The field AFVC_DS.-SIGN_ID provides the link to the digital signature table SIGNS.
The field AFVC_DS-OBJNR provides the link to the operation (this field will contain the operation object number).
back to top\