Hi all,
I used the code below to attach a doc to a pernr. After attaching a PDF document to pernr 00070845, I goto transaction PA20/PA30 to see the attachment list. However, I cannot manage to see the doc in the attachment list. Idoublle check that table SOOD (SAP Office: Object Definition) contains the added entry but table SRGBTBREL(Relationship in GOS Environment) did not have the entry. What could be the problem here in the codes?
.
"Construct upload structure from xstring
This part of code is meant ONLY for .PDF file type
IF wa_document_type = 'PDF'.
WHILE wa_stringlength <> -1.
CLEAR: wa_xbuf, wa_contents_hex.
wa_stringlength = STRLEN( wa_datastring ).
IF wa_stringlength >= 510.
wa_xbuf = wa_datastring(510).
wa_datastring = wa_datastring+510.
ELSE.
wa_xbuf = wa_datastring.
wa_stringlength = -1. "end condition
ENDIF.
<contents_hex> = <xbuf>.
APPEND wa_contents_hex TO wt_contents_hex.
ENDWHILE.
ENDIF.
"Find proper folder for uploading
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET' DESTINATION 'NONE'
EXPORTING
OWNER = ' '
region = 'B'
IMPORTING
folder_id = wa_folder_id
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
wa_document_data-obj_name = 'MESSAGE'.
wa_document_data-obj_descr = wa_filename.
wa_document_data-obj_langu = 'E'.
"Upload the document
CALL FUNCTION 'SO_DOCUMENT_INSERT_API1' DESTINATION 'NONE'
EXPORTING
folder_id = wa_folder_id
document_data = wa_document_data
document_type = wa_document_type
IMPORTING
document_info = wa_document_info
TABLES
OBJECT_HEADER = wt_object_header
OBJECT_CONTENT = wt_object_content
contents_hex = wt_contents_hex
OBJECT_PARA = wt_object_para
OBJECT_PARB = wt_object_parb
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 = 0.
COMMIT WORK.
ENDIF.
wa_obj_rolea-objkey = lo_stru_input_param-pernr.
wa_obj_rolea-objtype = 'BUS1065'.
wa_obj_roleb-objkey = wa_document_info-doc_id(34).
wa_obj_roleb-objtype = 'MESSAGE'.
CALL FUNCTION 'BINARY_RELATION_CREATE' DESTINATION 'NONE'
EXPORTING
obj_rolea = wa_obj_rolea
obj_roleb = wa_obj_roleb
relationtype = 'ATTA'
FIRE_EVENTS = 'X'
IMPORTING
BINREL =
TABLES
BINREL_ATTRIB =
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
COMMIT WORK.
Edited by: Siong Chao on Nov 15, 2010 11:03 AM
Edited by: Siong Chao on Nov 15, 2010 11:05 AM