cancel
Showing results for 
Search instead for 
Did you mean: 

attaching office 2007 files to an object

Former Member
0 Kudos

I am having problems with attaching office 2007 files to an object. the attaching works fine. The problem is when I try to open the files in word / excel. I get file corrupt messages.

I took the code in [http://friendlyabaper.blogspot.com/2009/12/office-2007-and-secret-handshake.html]

and modified it slightly.

I've looked other links in SDN but none of them help me.

this is what I have.

DATA: ls_fol_id TYPE soodk,

ls_obj_id TYPE soodk,

ls_obj_data TYPE sood1,

ls_folmem_k TYPE sofmk,

ls_note TYPE borident,

ls_object TYPE borident,

lv_ep_note TYPE borident-objkey,

  • lv_offset TYPE i,

lv_lines TYPE i,

ls_content like LINE OF GT_CONTENT,

lv_filename TYPE c LENGTH 100, " file name and ext

lv_extension TYPE c LENGTH 4. " extension only

DATA: it_objhead TYPE STANDARD TABLE OF soli,

it_content LIKE STANDARD TABLE OF soli,

wa_content LIKE soli,

lv_file TYPE string.

it_files[] = gt_files[].

ls_object-objkey = iv_object_key.

ls_object-objtype = iv_bus_object.

LOOP AT it_files.

CLEAR: ls_obj_id, ls_obj_data, ls_folmem_k, ls_note, lv_ep_note,

lv_lines, lv_filename, lv_extension, it_objhead, it_content, wa_content,

lv_file.

it_content[] = GT_CONTENT[].

CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'

EXPORTING

it_contents_bin = it_content[]

IMPORTING

et_contents_bin = it_content[].

CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'

EXPORTING

region = 'B'

IMPORTING

folder_id = ls_fol_id

EXCEPTIONS

OTHERS = 1.

PERFORM split_filename USING it_files

CHANGING lv_extension

lv_filename.

ls_obj_data-objsns = 'O'.

ls_obj_data-objla = sy-langu.

ls_obj_data-objdes = it_files.

ls_obj_data-file_ext = lv_extension.

CLEAR wa_content.

DESCRIBE TABLE it_content LINES lv_lines.

READ TABLE it_content INTO wa_content INDEX lv_lines.

2

ls_obj_data-objlen = lv_lines * 256 + STRLEN( wa_content ).

  • Object header

CLEAR wa_content.

CONCATENATE '&SO_FILENAME=' lv_filename INTO wa_content.

APPEND wa_content TO it_objhead.

wa_content = '&SO_FORMAT = BIN'.

1

APPEND wa_content TO it_objhead.

CALL FUNCTION 'SO_OBJECT_INSERT'

EXPORTING

folder_id = ls_fol_id

object_type = 'EXT'

object_hd_change = ls_obj_data

IMPORTING

object_id = ls_obj_id

TABLES

objhead = it_objhead

objcont = it_content

EXCEPTIONS

active_user_not_exist = 35

folder_not_exist = 6

object_type_not_exist = 17

owner_not_exist = 22

parameter_error = 23

OTHERS = 1000.

IF sy-subrc = 0 AND ls_object-objkey IS NOT INITIAL.

ls_folmem_k-foltp = ls_fol_id-objtp.

ls_folmem_k-folyr = ls_fol_id-objyr.

ls_folmem_k-folno = ls_fol_id-objno.

ls_folmem_k-doctp = ls_obj_id-objtp.

ls_folmem_k-docyr = ls_obj_id-objyr.

ls_folmem_k-docno = ls_obj_id-objno.

lv_ep_note = ls_folmem_k.

ls_note-objtype = 'MESSAGE'.

ls_note-objkey = lv_ep_note+(34).

CALL FUNCTION 'BINARY_RELATION_CREATE'

EXPORTING

obj_rolea = ls_object

obj_roleb = ls_note

relationtype = 'ATTA'

  • FIRE_EVENTS = 'X'

  • IMPORTING

  • BINREL =

  • TABLES

  • BINREL_ATTRIB =

EXCEPTIONS

no_model = 1

internal_error = 2

unknown = 3

OTHERS = 4

.

COMMIT WORK AND WAIT.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

.

ELSE.

MESSAGE 'Not OK' TYPE 'I'.

RETURN.

ENDIF.

ENDLOOP.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

moved to [;