How to extract VIM DP Documents as PDF attachments from OpenText Archive server
One of simple tasks that I had to do was to retrieve DP documents from OpenText Archive server using Archive link functions in order to attach them into GOS email services.
I found lots of examples of reading data from Archive link and all of them required writing files on a physical folder to attach them to email function . However I remember that I programed ABAP modules and objects in a SAP security project circa 2003 where I setup a Kpro server as SAP DMS and did DMS configurations. The function modules I built at that time is reading data from Kpro DMS contents sever in MEMORY not as a physical file nor needed to write down a file on local folder wherever. Thee reason of that was the encrypted of RSA keys were to be added to the header of the footer of MS office (or Adobe) documents as binary set which also worked only with binary document body. The documents I read as memory must be binary format for that reason. The decryption and validation process with CA were done by opposite ways.
I am suspicious that there might be one among Archive link functions which I built. I did find it.
Get Archive ID of DP document
Create ABAP class ZCL_VIM_DP_INVFILE_SRV_001->CONSTRUCTOR and read Archive ID by using OpenText FM ‘/OPT/VIM_VA2_GET_ARCH_DATA’ or simply select from 1head table at method “constructor”
SELECT SINGLE archiv_id arc_doc_id INTO (iv_archiv_id, iv_arc_doc_id) FROM /opt/vim_1head WHERE docid = iv_docid.
You can get Archive ID and Archive Document ID from DP document ID
CALL FUNCTION '/OPT/VIM_VA2_GET_ARCH_DATA' EXPORTING iv_docid = iv_docid IMPORTING iv_archiv_id = gv_archiv_id iv_arc_doc_id = gv_arc_doc_id EXCEPTIONS system_failure = 1 error_message communication_failure = 2 error message.
Import parameter IV_DOCID TYPE /OPT/DOCID
* read Archive ID IF iv_docid IS INITIAL. RAISE EXCEPTION TYPE zcx_vim_util EXPORTING textid = zcx_vim_util=>exp_id001. ENDIF. CALL FUNCTION '/OPT/VIM_VA2_GET_ARCH_DATA' EXPORTING iv_docid = iv_docid IMPORTING iv_archiv_id = gv_archiv_id iv_arc_doc_id = gv_arc_doc_id EXCEPTIONS system_failure = 1 error_message communication_failure = 2 error message. IF gv_archiv_id IS INITIAL OR gv_arc_doc_id IS INITIAL. RAISE EXCEPTION TYPE zcx_vim_util EXPORTING textid = zcx_vim_util=>exp_id002. ENDIF.
Read Document as memory (Internal table)
Create a METHOD get_dp_image_from_cms_x. with return parameter RT_SOLIX_TAB TYPE SOLIX_TAB
CompID should be ‘data’ and need to pass Archive ID and Doc ID. Then need to convert the data type RAW 1024 of output into type RAW 255 which is compatible with the data format of email attachment.
Archive Link Document Class for the OpenText DP document is ‘/OPT/V1001’ : GC_DP_DOC_TYPE
METHOD get_dp_image_from_cms_x. CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE' EXPORTING archiv_id = gv_archiv_id document_type = gc_dp_doc_type archiv_doc_id = gv_arc_doc_id * ALL_COMPONENTS = * SIGNATURE = 'X' compid = 'data' IMPORTING length = ev_length binlength = ev_binlength TABLES archivobject = et_archivobject binarchivobject = et_binarchivobject EXCEPTIONS error_archiv = 1 error_communicationtable = 2 error_kernel = 3 OTHERS = 4. IF sy-subrc = 0. CALL METHOD cl_rmps_general_functions=>convert_1024_to_255 EXPORTING im_tab_1024 = et_binarchivobject RECEIVING re_tab_255 = rt_solix_tab. ENDIF. ENDMETHOD.
Make a short form with email attachment as PDF
GP_DEF_ATTRIB = DP document id (type : /opt/docid )
** Create OBJ attachment - DP Invoice PDF DATA(lt_pdf_solix) = NEW zcl_vim_dp_invfile_srv_001( CONV /opt/docid( gp_def_attrib ) )->get_dp_image_from_cms_x( IMPORTING ev_binlength = lv_binlength ev_length = lv_length ). IF lt_pdf_solix IS NOT INITIAL. lo_document_att = cl_document_bcs=>create_document( i_type = 'PDF' i_subject = CONV so_obj_des( TEXT-303 ) i_length = CONV so_obj_len( lv_binlength ) i_hex = lt_pdf_solix i_language = sy-langu i_importance = '1' ). lo_document->add_document_as_attachment( lo_document_att ). APPEND lo_document_att TO lt_attachments. ENDIF.
Eventually, The Function Group SAPLARCHIVOBJECT is a kind of full package of check-in and check-out functions plus extra functionalities.
In general usage as contents server, you can read PDF data directly with export parameter document_type = ‘PDF’ if the documents are stored as PDF file . But OT DP document has own document class.
call function ‘ARCHIVOBJECT_GET_TABLE’
archiv_id = aid
document_type = ‘PDF’
archiv_doc_id = adi