Sunteți pe pagina 1din 11

Digital Signature in Adobe Forms

Add to favorites February 11, 2014 UI SAP Interactive Forms by Adobe

This blog will help in creating a digitally signed Adobe Form.

With digital signatures getting a nod in many countries, a lot of organizations are looking up to digital
signatures to save the time spent on a redundant task such as, signing the hard copy. By using digital
signatures, a soft copy can be digitally signed and secured.

I have used, ABAP to design the form. The reason of using SFP transaction is, easier integration of
form and interface with various other platforms, that is not easily ans seamlessly possible with WD
JAVA.

The following steps need to be verified by the basis team for digital signature to be active in the
system.

1. Uploading a digital signature in the system

2. Create connection between ADS (Adobe Document Services) and R/3 system – It is recommended
to name the connection, “ADS_HTTPS”

The following steps will create an Adobe for with digital signature.

Go to transaction SFP
Give the interface, you want to design, a name. The interface is that part, in which we write the
logic for pulling data from the tables. Click on create.
Maintain the data to be used in the form under Global Data. Both input and output elements can be
used here. We need to define the name and the type.
Go to Code initialization. Here we write the logic of extracting the data from the tables. Here we need
to define the Input & Output parameters. The Input / Output parameters are the ones, defined in
Global Data. Here we don’t need to define the Type.

Note: The name used in The Input / Output parameters should be the same that is used in
Global Data.
Once the code is written in the interface, save it and go back to Form (Transaction SFP)

Give the form a name and create the form.

In the form properties, provide the name of the interface which the form will call.
In the context, bind the global data with the form context. This can be done by simple drag and drop.

Click on layout, to design the form.

Design the form and bind the UIs with the data available in the data view.

After form design, insert the signature field in the form.


Once the form has been designed and the digital signature field has been incorporated in the
form, the code for digitally signing the form will be written in the RFC that will call the form.

We’ll have to define the HTTP Connection, the position of the Digital Signature UI and the
name of the digital signature in the form.

Following is the code that we need to write to define the above mentioned fields.

P_DEST TYPE RFCDEST VALUE ‘ADS_HTTPS’, // The name of connection


S_FIELD(100) TYPE C VALUE ‘data.#subform[0].END.SIGNATURE.SignatureField1’, // The
position of digital signature

FORM_NAME = ‘ZMM_V2V_RATE’. // The form RFC needs to call


S_ALSIGN = ‘Umang_Test’ . // Name of Digital Signature

Following is the code that needs to be written for digitally signing the form.

FORM_NAME = ‘ZMM_V2V_RATE’.
S_ALSIGN = ‘Umang_Test’.

GS_FPOUTPARAMS–NODIALOG = ‘X’.
GS_FPDOCPARAMS–FILLABLE = ‘X’.
CALL FUNCTION ‘FP_JOB_OPEN’
CHANGING
IE_OUTPUTPARAMS = GS_FPOUTPARAMS
EXCEPTIONS
CANCEL =1
USAGE_ERROR =2
SYSTEM_ERROR =3
INTERNAL_ERROR =4
OTHERS = 5.
IF SY–SUBRC <> 0.
ENDIF.
TRY.
CALL FUNCTION ‘FP_FUNCTION_MODULE_NAME’
EXPORTING
I_NAME = FORM_NAME
IMPORTING
E_FUNCNAME = GV_FMNAME.
CATCH CX_ROOT INTO LV_W_CX_ROOT.
LV_MESG = LV_W_CX_ROOT->GET_TEXT( ).
ENDTRY.
CLEAR: FORMOUTPUT.

CALL METHOD L_PDFOBJ->SET_DOCUMENT


EXPORTING
PDFDATA = FORMOUTPUT–PDF.

CALL METHOD L_PDFOBJ->SET_SIGNATURE


EXPORTING
KEYNAME = S_ALSIGN
FIELDNAME = S_FIELD.

CLEAR: L_OUT.
CALL METHOD L_PDFOBJ->EXECUTE( ).
L_PDFOBJ->SET_USAGERIGHTS( DEFAULT_RIGHTS = C_FALSE ).
CALL METHOD L_PDFOBJ->GET_DOCUMENT
IMPORTING
PDFDATA = L_OUT.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’


EXPORTING
BUFFER = L_OUT
* APPEND_TO_TABLE =‘‘
* IMPORTING
* OUTPUT_LENGTH =
TABLES
BINARY_TAB = BINARY_CONTENT.

* ENDLOOP.

CALL FUNCTION ‘FP_JOB_CLOSE’


EXCEPTIONS
USAGE_ERROR =1
SYSTEM_ERROR =2
INTERNAL_ERROR = 3
OTHERS = 4.

The above mentioned code will digitally sign the document.

Digital Signature in SAP FIORI


How to save the Digital Signature in SAP.
This code helps to DeCode the BASE64 format which FIORI applications sends, this
needs to converted to BINARY format and further to be used as per the requirement.

Some times the Image you get is Black but it might not be the mistake at SAP end
while sending the time the background in getting black from UI end.

Its better or advised to save the data in the Z table and then it can be retrieved. You
can create the a field OF DATA TYPE RAWSTRING.

Below example sign field is created with datatype RAWSTRING using predefined
type.

*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” REFERENCE(IV_INPUT) TYPE STRING OPTIONAL
*” REFERENCE(IV_NAME) TYPE STXBITMAPS-TDNAME OPTIONAL
*” REFERENCE(IV_DEL) TYPE CHAR01 OPTIONAL
*” EXPORTING
*” REFERENCE(EV_RETURN) TYPE CHAR01
*”———————————————————————-

TYPES: BEGIN OF lty_bitmap,


l(64) TYPE x,
END OF lty_bitmap.

DATA:
lo_conv_x2c TYPE REF TO cl_abap_conv_in_ce,
base64_string TYPE string,
base64_xstring TYPE xstring,
lv_size TYPE i,
lt_content TYPE TABLE OF lty_bitmap, ” sdokcntbin.
ls_dsign TYPE zfcs_sign_update.

CONSTANTS : lc_filename TYPE rlgrap-filename VALUE ”,


lc_object TYPE stxbitmaps-tdobject VALUE ‘GRAPHICS’,
lc_id TYPE stxbitmaps-tdid VALUE ‘BMAP’,
lc_btype TYPE stxbitmaps-tdbtype VALUE ‘BMON’,
lc_extension TYPE char03 VALUE ‘BMP’,
lc_title LIKE bapisignat-prop_value VALUE ”,
lc_resident TYPE stxbitmaps-resident VALUE ”,
lc_autoheight TYPE stxbitmaps-autoheight VALUE ‘X’,
lc_bmcomp TYPE stxbitmaps-bmcomp VALUE ‘X’.
DATA: lv_docid TYPE stxbitmaps-docid,
lv_resolution TYPE stxbitmaps-resolution.

lo_conv_x2c = cl_abap_conv_in_ce=>create( ).

* lo_conv_x2c->convert( EXPORTING input = Iv_input


* IMPORTING data = base64_string ).
*
base64_string = iv_input.
*— decoding base_64
CALL FUNCTION ‘SSFC_BASE64_DECODE’
EXPORTING
b64data = base64_string
* B64LENG =
* B_CHECK =
IMPORTING
bindata = base64_xstring
EXCEPTIONS
ssf_krn_error = 1
ssf_krn_noop = 2
ssf_krn_nomemory = 3
ssf_krn_opinv = 4
ssf_krn_input_data_error = 5
ssf_krn_invalid_par = 6
ssf_krn_invalid_parlen = 7
OTHERS = 8.

“Getting the data


CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = base64_xstring
append_to_table = ‘X’
IMPORTING
output_length = lv_size
TABLES
binary_tab = lt_content.

DESCRIBE TABLE lt_content LINES DATA(lv_count).


READ TABLE lt_content INTO DATA(ls_content)
INDEX lv_count.
IF ls_content-l = text-e01.
ev_return = ‘E’.
ELSE.
ev_return = ‘S’.
IF iv_del IS INITIAL.
“Saving Dsign
ls_dsign-tdname = iv_name.
ls_dsign-sign = base64_xstring.
MODIFY zfcs_sign_update FROM ls_dsign.

“Uploading the Grahic(s)


PERFORM import_bitmap
USING lc_filename
iv_name
lc_object “GRAPHICS
lc_id “BMAP
lc_btype “BMON
lc_extension “BMP
lc_title
lc_resident
lc_autoheight “X
lc_bmcomp “X
lt_content
CHANGING lv_docid
lv_resolution.
ELSE.
“Deleted Upload
CALL FUNCTION ‘SAPSCRIPT_DELETE_GRAPHIC_BDS’
EXPORTING
i_object = ‘GRAPHICS’
i_name = iv_name
i_id = ‘BMAP’
i_btype = ‘BMON’
dialog = ”
EXCEPTIONS
enqueue_failed = 1
delete_failed = 2
not_found = 3
canceled = 4
OTHERS = 5.

ENDIF.
ENDIF. “Check no error
ENDFUNCTION.

S-ar putea să vă placă și