Search on this Website

Sunday, February 20, 2011

Create a Digital Signature in ABAP ( Sample Code)

This is a short list of necessary operations:
Build a table for metadata using as key a field referring to data element SIGN_GUID_22 and the complete key for your to-be-signed document; in my case:
ZZAPT_SIGNATURE
FIELD DATA ELEMENT
MANDT
MANDT
SIGN_ID SIGN_GUID_22
CORDERID N1CORDID
Build a structure for operation log: ZZAPT_SIGNATURE_LOG
FIELD DATA ELEMENT
.include
SIGN_PROT_STRUC
CORDERID N1CORDID
Launch the following transactions(very intuitive):
SLG0: declare a sub-object under CDSG1
SIGNA:declare your application
SIGNO:insert the signature object
ELSIG03N: choose and link the type of signature(in my case R/3)
REPORT ZPR00004
.
DATA: lo_ds_runtime TYPE REF TO if_ds_runtime.
DATA: lo_sign TYPE REF TO if_ds_sign.
DATA: l_metadata_wa TYPE ZZAPT_SIGNATURE. lo_ds_runtime = cl_ds_runtime=>get_instance( ).
l_metadata_wa-corderid = '5159DB46ACFC1424E1000000010000AB'."Doc ID call method lo_ds_runtime->create
exporting
im_appl = 'ZTEST'"APPL
im_object = 'ZTEST'"OBJECT
im_meta = l_metadata_wa
im_type = 'C' "Synch signature
receiving
result = lo_sign.
call method lo_sign->sign
exporting
im_signer = sy-uname
im_doc_txt = 'SIGNING DOCUMENT 5159DB46ACFC1424E1000000010000AB'
im_doctype = 'TXT'. commit work and wait.

No comments: