Vous êtes sur la page 1sur 20

SAP Package DS

add metadata to PDF document in ABAP


by sapalles • October 2, 2014 • 0 Comments

add metadata to PDF document in ABAP


4 (80%) 1 vote

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.

 An Adobe Java Server should be configured by SAP Basis team.


 An RFC destionation to reach Adobe Server should be created in SM59.

 Required change should be adapted in ABAP side.

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

You may also like


Digital Signature
Technical Information
Package DS
Short Text Digital Signature
Parent Package ABA
Package Contents
The package DS is a normal package. It contains the following embedded packages and
dictionary objects.
Function Groups
The package DS contains 4 function groups.
ASIG Extended Table Maintenance (Generated)
CSIG Extended Table Maintenance (Generated)
OSIG Extended Table Maintenance (Generated)
RSIG Digital Signature: Runtime
Transactions
The package DS contains 7 transactions.
ELSIG00 Signature Strategy
ELSIG01 Authorization Grp Digital Signatures
ELSIG02 Digital Signature
ELSIG03 Signature Method for Signat. Object
ELSIG03N Signature Method for Signat. Object
SIGNA Register Signature Application
SIGNO Register Signature Object
Database Tables
The package DS contains 23 database tables.
DSIG_BOOKING_EX Signature Tool: Example Database Table with Application Data
DSIG_META_EX Signature Tool: Example Database Table for Metadata
SIGNAPPL Registration Table for Applications for Digital Signatures
SIGNAPPLT Texts for Registering the Applications for the Dig. Sig.
SIGNDO Digital Signature: Documents to Sign
SIGNH Digital Signature: Header Data
SIGNOBJECT Registration Table for Objects for Digital Signature
SIGNOBJECTT Texts for Registration of the Digital Signature Objects
SIGNOBJECTTV Version Table: Texts for Registration of DS Objects
SIGNOBJECTV Version Table: Registration of DS Objects
SIGNS Transaction Data for Digital Signatures
TC81 Authorization Group for Digital Signatures
TC82 Short Text for Authorization Group for Digital Signatures
TC83 Individual Signature
TC84 Short Text for Individual Signature
TC85 Signature Strategy
TC86 Short Text for Signature Strategy
TC87 Signature Sequence
TC88 Release Statuses for Signature Strategy
TC89 Strategy/Individual Signature Assignment
TC90 Release Status/Individual Signature Assignment
TC91 Setting Up Signature Method for Individual Signature
TC92 Digital Signature: Signature Object
Views
The package DS contains 11 views.
SIGNAPPL_V Register 'Application' Grouping Element for Dig. Signature
SIGNOBJECT_V Register Signature Objects for Digital Signature
V_TC81 Authorization Group for Digital Signatures
V_TC83 Individual Signature
V_TC85 Signature Strategy
V_TC87 Signature Sequence
V_TC88 Release Statuses
V_TC89 Strategy/Individual Signature Assignment
V_TC90 Release Status/Individual Signature Assignment
V_TC91 Specify Signature Method for Simple Signature
V_TC92 Digital Signature: Signature Object
Structures
The package DS contains 34 structures.
DSIG_EXAMPLE_SIGN_LOG Signature Tool: Log Structure for Example
RC80B Buffer for Individual Signatures
RC80B2 Buffer for Individual Signatures
RC80K Dialog Structure for Details on Individual Signatures
RC80N Signature Sequence: Graphical Maintenance
RC80R Signature Sequence: Graphical Maintenance
RC80S Buffer for Indivivual Signatures for Sequence Maintenance
RC80T Signature Sequence: Graphical Maintenance
RC80V Signature Sequence: Graphical Maintenance
RC80Z Signature Sequence: Graphical Maintenance
RC87E Export Table for Graph. Maintenance of Signature Sequences
Export Structure TC88 for Graph. Maintenance of
RC88E
Rel.Statuses
Export Structure TC88 for Graph. Maintenance of
RC90E
Rel.Statuses
SIGN_DATA_DB_STRUC Digital Signature: Transaction Data
SIGN_DOC_DB_STRUC Digital Signature: Document to Sign
SIGN_FLT_STRUC Filter Values of Digital Signature for BAdI Implementation
SIGN_HEADER_DB_STRUC Digital Signature: Header Data
SIGN_HEADER_STRUC Digital Signature: Header Data
SIGN_ID_STRUC Digital Signature: Signature ID
SIGN_META_SAVE_STRUC Digital Signature: Metadata for Update
SIGN_META_STRUC Digital Signature: Meta Data
SIGN_POPUP_STRUC Transfer of Values to the DS Dialog Box
SIGN_PROT_MSG Structure of Digital Signature Log, Context Message
SIGN_PROT_STRUC Digital Signature: General Data for the Log
SIGN_REF_STRUC Digital Signature: Reference to an Object
SIGN_REG_INFO_STRUC Registration Info of Applications for Digital Signature
SIGN_REMARK_STRUC Record of Remarks for the Application for Digital Signature
SIGN_STEP_LIST_STRUC Digital Signature: List of Signature Data
SIGN_STEP_POST_STRUC Information on Signatures Executed
SIGN_STEP_PRED_STRUC Information on Signatures to Execute
SIGN_STEP_STRUC Digital Signature: Signatures Executed
SIGN_TIME_STRUC Date and Time of Digital Signature
SIGN_VERIFY_STEP_STRUC Digital Signature: Verification of Data
SIGN_VERIFY_STRUC Digital Signature: Verification Result
Programs
The package DS contains 1 programs.
DSIG_BOOKING_EX Report DSIG_BOOKING_EX
Search Helps
The package DS contains 1 search helps.
SIGN_S_STRATEGY Digital Signature: Search Help for Strategies
Message Classes
The package DS contains 1 message classes.
SIG Digitale Signatur
Authorization Objects
The package DS contains 2 authorization objects.
C_SIGN Authorization for Digital Signatures
C_SIGN_BGR Authorization Group for Digital Signature
Community WIKI SAP Community

Welcome, Guest

Login

Register

Registration

Dear SAP Community Member,


In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.

Close

Getting Started

Store

Top of Form

Search the C

Bottom of Form
Skip to content

Skip to breadcrumbs

Skip to header menu

Skip to action menu

Skip to quick search

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

SAP Master Data Management

SAP Master Data Management

SAP Netweaver Master Data Managment

MDM Content and Processes

E-SIGNATURE for Maintenance Plants- Master Data ( ECC 6.0)

Skip to end of metadata

Created by Guest, last modified by Michael Theis on Feb 18, 2010

Go to start of metadata

E-SIGNATURE for Maintenance Plants- Master Data ( ECC 6.0)

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".

Transactions for Maintenance Plan

IP03, IP10, IP42, IP02, IP10, IP04, IP05.

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.

See screen shots below.


Transaction DSAL is used to display the
electronic signature documents.
A configuration table is needed to control
whether or not the signature should pop-up.
This is needed to be able to suppress the pop-
up during the conversion process.
Go to transaction DSAL -> Select Application
as PM: Maintenance Plans- Master Data -
>Signature object as Signature for PM
Maintenance Plans- Master Data and the
signature time.
On executing, you will get an entire list of logs.
Click on the one you need to view. Select the line
item and press the Document button.
This will display you the smartform which is linked
to your e-signature.
The smartform displays the name of the person
who made the changes, the remarks, along with
the change that was done in transaction IP02 etc.
See screen shots below.
BADI Implementations:

I created ZUSI_MAINTPLA_DIGSIG Digital Signature for Maintenance Plan.

METHODS:

DIG_SIGNATURE_MAINT_PLAN (Digital signature for MP (master


data))DIG_SIGNATURE_MAINT_ITEM (Digital signature for MP item)
DIG_SIGNATURE_MAINT_PLAN_SCHED (Digital signature for MP Scheduling)

BADI for viewing signed documents:

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)

GET_SINGLE (Display document for selected signature log)

GET_BUTTON (Setting individual drop down buttons for transaction DSAL)

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

SAP Help Portal

Privacy

Terms of Use

Legal Disclosure

Copyright

Cookie Preferences
Privacy Statement

Allow use of SAP Web Analytics Save

SAP Master Data Management

SAP Master Data Management

SAP Netweaver Master Data Managment

MDM Content and Processes

E-SIGNATURE for Maintenance Plants- Master Data ( ECC 6.0)

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

Digital Signatures in PM Orders


Skip to end of metadata

 Created by Former Member, last modified on Nov 24, 2011


Go to start of metadata

Digital Signatures in PM Orders - Frequently Asked Questions


This FAQ is moderated by Conor Forrest
These are the frequently asked questions for the use of Digital Signatures in PM Order Operations.

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.

 What is the required customizing to enable this functionality for PM orders?


Digital signature types are assigned to an order type / maintenance planning plant combination.

The relevant customizing can be found at the following node in SPRO:

-> Plant Maintenance and Customer Service

-> Maintenance and Service Processing

-> Maintenance and Service Orders

-> Functions and Settings for Order Types

-> Define Digital Signature for Order Types


Further information can be found by pressing the "IMG activity documentation" button for the node.

 How do I set a digital signature for an order operation?


Navigate to any tab in the operation screen (e.g. General) and follow the menu path:
Edit -> Digital signature -> Set

 How do I display a digital signature for an order operation?


Navigate to any tab in the operation screen (e.g. General) and follow the menu path:

Goto -> Logs -> Digital sig. log

Answers to Technical Questions


 How is the account assignment between operations and digital signatures defined?
When a digital signature and comment are added to an order operation this information is stored in table SIGNS.

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\

Vous aimerez peut-être aussi