on 06-24-2014 9:38 AM
Hi,
I have a requirement to display UWL attachments from ESS application. The document should be first stored in opentext repository then later on be retrieved by workflow to display the attachment in UWL. Initially, to achive this, I am using FMs ARCHIVOBJECT_CREATE_FILE and ARCHIV_CONNECTION_INSERT. I was able to successfully store the document in ArchiveLink. But during retrieval, when I tried to use "swc_create_object attobj 'SOFM' sofmkey" to create the attachment object where the SOFMKEY-KEY is equal to the archive document ID, I am able to see the link in the UWL for the attachment but can't open the actual file.
From researching, I have seen that the file should be stored using the following FMs first before I am able to retrieve the folder ID which I will need to created the attachment object that I will pass to my user decision step in workflow.
SO_DOCUMENT_INSERT_API1
BINARY_RELATION_CREATE
Thus, in my current code, what i did is to create the SOFM Object, create a relationship between the business object and attachment, then call the two archiving FMs for archiving to opentext.
I am not sure if what I did makes any sense. I hope someone could guide me.
Here is the code:
METHOD save_attachment.
DATA:
lv_folderid TYPE soodk,
lv_data_read TYPE i.
DATA:
ls_object_hd_change TYPE sodocchgi1,
ls_obj_rolea TYPE borident,
ls_obj_roleb TYPE borident,
lt_zarch_tbl_lso TYPE STANDARD TABLE OF zarch_tbl_lso,
ls_zarch_tbl_lso LIKE LINE OF lt_zarch_tbl_lso,
lt_object_content_hex TYPE TABLE OF solix,
ls_line_content_hex TYPE solix,
ls_docu_info TYPE sofolenti1.
CONSTANTS:
lc_relationtype_atta TYPE binreltyp VALUE 'ATTA'.
* For conversion from XString to Hex
DATA:
lo_conv_class TYPE REF TO cl_abap_conv_in_ce,
lo_off_class TYPE REF TO cl_abap_view_offlen.
* temporary storage in app server
CONSTANTS:
lc_path_development TYPE string VALUE '\\vcenhcmvm21\SAPPHIRE\D27\TVM\OpenText\Temp\',
lc_path_testing TYPE string VALUE '\\vcenhcmvm21\SAPPHIRE\T27\LSO\OpenText\Temp\',
lc_path_production TYPE string VALUE '\\VCENSAPPRD30\SAPPHIRE\P27\LSO\OpenText\Temp\'.
* Archivelink
DATA:
lv_sap_object TYPE toaom-sap_object VALUE 'ZESS_LSO01', " Business Object
lv_ar_object TYPE toaom-ar_object VALUE 'ZESS_LSO10', " Document Type
lv_doctype TYPE toadv-doc_type VALUE 'PDF', " File Type
lv_archiv_id TYPE toa01-archiv_id, " Content Repos. ID
lv_arc_doc_id TYPE toa01-arc_doc_id, " Document ID
lv_path_as TYPE sapb-sappfad, " File Path in AppServer
lv_path_ps TYPE sapb-sappfad, " File Path in Pres. Server
lv_filename TYPE sapb-sappfad, " File Name
lv_object_id TYPE sapb-sapobjid, " Business Object Key
lv_folder_as TYPE string.
IF iv_filecontents IS NOT INITIAL.
PERFORM split_path IN PROGRAM oaall USING iv_filepath lv_path_ps lv_filename.
CONCATENATE iv_plvar
iv_learnertype
iv_learnerid
iv_trainingotype
iv_trainingid
INTO lv_object_id RESPECTING BLANKS.
* Convert XString to HEX
lo_conv_class = cl_abap_conv_in_ce=>create(
replacement = ' '
ignore_cerr = abap_true
input = iv_filecontents ) .
lo_off_class = cl_abap_view_offlen=>create_legacy_view( ls_line_content_hex ).
lv_data_read = 1.
WHILE lv_data_read > 0.
CLEAR ls_line_content_hex.
CALL METHOD lo_conv_class->read
EXPORTING
n = -1
view = lo_off_class
IMPORTING
data = ls_line_content_hex
len = lv_data_read.
IF lv_data_read > 0.
APPEND ls_line_content_hex TO lt_object_content_hex.
ENDIF.
ENDWHILE.
* Get Folder ID
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
region = 'B'
IMPORTING
folder_id = lv_folderid
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
ENDIF.
ls_object_hd_change-doc_size = xstrlen( iv_filecontents ).
ls_object_hd_change-obj_langu = sy-langu.
ls_object_hd_change-obj_descr = lv_filename.
CALL FUNCTION 'SO_DOCUMENT_INSERT_API1'
EXPORTING
folder_id = lv_folderid
document_data = ls_object_hd_change
document_type = 'PDF'
IMPORTING
document_info = ls_docu_info
TABLES
contents_hex = lt_object_content_hex
EXCEPTIONS
folder_not_exist = 1
document_type_not_exist = 2
operation_no_authorization = 3
parameter_error = 4
x_error = 5
enqueue_error = 6
OTHERS = 7.
IF sy-subrc EQ 0.
ls_obj_rolea-objkey = lv_object_id.
ls_obj_rolea-objtype = 'ZESS_LSO01'.
MOVE ls_docu_info-doc_id TO ls_obj_roleb-objkey.
ls_obj_roleb-objtype = 'MESSAGE'.
* Create link between object and attachment
CALL FUNCTION 'BINARY_RELATION_CREATE'
EXPORTING
obj_rolea = ls_obj_rolea
obj_roleb = ls_obj_roleb
relationtype = lc_relationtype_atta
EXCEPTIONS
OTHERS = 1.
IF sy-subrc EQ 0.
COMMIT WORK AND WAIT.
ENDIF.
** File Archiving to OpenText
*
** AS Temp Folder
* CASE sy-sysid.
* WHEN 'D27'.
* lv_folder_as = lc_path_development.
* WHEN 'T27'.
* lv_folder_as = lc_path_testing.
* WHEN 'P27'.
* lv_folder_as = lc_path_production.
* WHEN OTHERS.
* ENDCASE.
*
* CONCATENATE lv_folder_as lv_filename INTO lv_path_as.
*
** Transfer File first to application server
* OPEN DATASET lv_path_as FOR OUTPUT IN BINARY MODE.
* IF sy-subrc EQ 0.
* TRANSFER iv_filecontents TO lv_path_as.
* CLOSE DATASET lv_path_as.
*
** get the archive ID
* SELECT SINGLE archiv_id
* FROM toaom
* INTO lv_archiv_id
* WHERE sap_object EQ lv_sap_object
* AND ar_object EQ lv_ar_object
* AND ar_status EQ 'X'.
*
* IF sy-subrc EQ 0.
*
* CALL FUNCTION 'ARCHIVOBJECT_CREATE_FILE'
* EXPORTING
* archiv_id = lv_archiv_id
* document_type = 'PDF'
* path = lv_path_as
* IMPORTING
* archiv_doc_id = lv_arc_doc_id
* EXCEPTIONS
* error_archiv = 1
* error_communicationtable = 2
* error_upload = 3
* error_kernel = 4
* OTHERS = 5.
*
* IF sy-subrc = 0.
*
* CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'
* EXPORTING
* archiv_id = lv_archiv_id
* arc_doc_id = lv_arc_doc_id
* ar_object = lv_ar_object
* object_id = lv_object_id
* sap_object = lv_sap_object
* doc_type = lv_doctype
* EXCEPTIONS
* error_connectiontable = 1
* OTHERS = 2.
*
* IF sy-subrc EQ 0.
* COMMIT WORK.
* ENDIF.
* ENDIF.
* ENDIF.
*
* DELETE DATASET lv_path_as.
*
* ENDIF.
ls_zarch_tbl_lso-zdoc_id = ls_docu_info-doc_id.
ls_zarch_tbl_lso-zplvar = iv_plvar.
ls_zarch_tbl_lso-zlearnertype = iv_learnertype.
ls_zarch_tbl_lso-zlearnerid = iv_learnerid.
ls_zarch_tbl_lso-ztrainingotype = iv_trainingotype.
ls_zarch_tbl_lso-ztrainingid = iv_trainingid.
ls_zarch_tbl_lso-zfilename = lv_filename.
IF lv_arc_doc_id IS NOT INITIAL.
ls_zarch_tbl_lso-zsapal_docid = lv_arc_doc_id.
ls_zarch_tbl_lso-zarchive_status = 'X'.
ENDIF.
MODIFY zarch_tbl_lso FROM ls_zarch_tbl_lso.
ENDIF.
ENDIF.
ENDMETHOD.
As a summary, I need help on how to retrieve file from HTTP content server to display later on as UWL attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
11 | |
10 | |
6 | |
5 | |
5 | |
5 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.