2015 Nov 27 6:28 AM
Hi Experts,
1) I have used SO_OBJECT_INSERT to create the attachment.
2) Attachment is getting created properly (PDF, JPG, DOC)
Issue is when we try to open those attachments we are getting below issues,
Seeking your help to resolve this issue.
Thanks,
Tejas Shah
2015 Nov 27 11:33 AM
Hi All,
Got the solution, here it is...
While uploading data using GUI_UPLOAD you must take file type as 'BIN' and then we need to use below FMs
1) SO_CONVERT_CONTENTS_BIN
2) SO_FOLDER_ROOT_ID_GET
3) SO_OBJECT_INSERT
4) BINARY_RELATION_CREATE_COMMIT
now I can upload and view PDF, DOC, JPG and PNG files.
Regards,
Tejas Shah
2015 Nov 27 11:33 AM
Hi All,
Got the solution, here it is...
While uploading data using GUI_UPLOAD you must take file type as 'BIN' and then we need to use below FMs
1) SO_CONVERT_CONTENTS_BIN
2) SO_FOLDER_ROOT_ID_GET
3) SO_OBJECT_INSERT
4) BINARY_RELATION_CREATE_COMMIT
now I can upload and view PDF, DOC, JPG and PNG files.
Regards,
Tejas Shah
2016 Feb 05 9:33 AM
Hi Tejas,
I have tried the same steps which you mentioned above. PDF and TXT are working.
But image files and DOC files are not working.
Can you pls. let me know whether any additional parameters need to be passed for image files.
Regards,
Imran.
2016 Feb 05 11:17 AM
Hi Imran,
Please find below code snip it may useful to you.
DATA: lit_objhead TYPE TABLE OF soli.
DATA: lwa_data_tab TYPE soli,
lwa_fold_id TYPE soodk,
lwa_obj_hd TYPE sood1,
lwa_obj_id TYPE soodk,
lwa_rolea TYPE borident,
lwa_roleb TYPE borident.
DATA: lv_ext(3) TYPE c.
*reading attachment file and filling internal table
OPEN DATASET gv_file_name FOR INPUT IN BINARY MODE .
IF sy-subrc = 0.
DO.
READ DATASET gv_file_name INTO lwa_data_tab-line.
IF sy-subrc = 0.
APPEND lwa_data_tab TO git_data_tab.
CLEAR: lwa_data_tab.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
* MESSAGE 'Issue in opening the file' TYPE 'E'.
gwa_log-qmnum = <gfs_vss_sap>-qmnum.
gwa_log-aufnr = <gfs_vss_sap>-aufnr.
gwa_log-posnr = <gfs_vss_sap>-posnr.
gwa_log-msg_type = gc_e.
gwa_log-msg_desc = 'Error in Opening the file'.
*If message type is error cell colour RED else GREEN.
PERFORM cell_colour USING 6.
APPEND gwa_log TO git_log.
CLEAR: gwa_log.
EXIT. "control will move to next loop pass
ENDIF.
CLOSE DATASET gv_file_name.
*Call the Function Module for Converts into Bin
CALL FUNCTION 'SO_CONVERT_CONTENTS_BIN'
EXPORTING
it_contents_bin = git_data_tab
IMPORTING
et_contents_bin = git_data_tab.
*Call the Function Module to get the Folder Id
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
* OWNER = ' '
region = gc_b
IMPORTING
folder_id = lwa_fold_id
EXCEPTIONS
communication_failure = 1
owner_not_exist = 2
system_failure = 3
x_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO gwa_log-msg_desc.
gwa_log-qmnum = <gfs_vss_sap>-qmnum.
gwa_log-aufnr = <gfs_vss_sap>-aufnr.
gwa_log-posnr = <gfs_vss_sap>-posnr.
gwa_log-msg_type = sy-msgty.
CONCATENATE gwa_log-msg_desc 'Attachment Failed'
INTO gwa_log-msg_desc
SEPARATED BY gc_comma.
IF gwa_log-msg_type = gc_e.
*If message type is error cell colour RED else GREEN.
PERFORM cell_colour USING 6.
ENDIF.
APPEND gwa_log TO git_log.
CLEAR: gwa_log.
* E=Error if there is an error in reading the file
<gfs_vss_sap>-attach_proc = gc_e.
ELSE.
*we will get file extension
CALL FUNCTION 'TRINT_FILE_GET_EXTENSION'
EXPORTING
filename = gv_file_name
uppercase = 'X'
IMPORTING
extension = lv_ext.
.
IF sy-subrc = 0.
lwa_obj_hd-file_ext = lv_ext."v_extension.
ENDIF.
lwa_obj_hd-objsns = gc_o.
lwa_obj_hd-objla = sy-langu.
lwa_obj_hd-objdes = gv_file_name.
*We will get filr size
*** DATA: l_filesize TYPE epsf-epsfilsiz.
*** CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
*** EXPORTING
*** file_name = 'Cap_jpg.jpg'
*** dir_name = '/uiftp/int/in/wellsfargo/'
*** IMPORTING
*** file_size = l_filesize.
lwa_obj_hd-objlen = lines( git_data_tab ) * 255.
CALL FUNCTION 'SO_OBJECT_INSERT'
EXPORTING
folder_id = lwa_fold_id
* OBJECT_FL_CHANGE = ' '
object_hd_change = lwa_obj_hd
object_type = gc_ext
* ORIGINATOR_ID = ' '
* OWNER = ' '
IMPORTING
* OBJECT_FL_DISPLAY =
* OBJECT_HD_DISPLAY =
object_id = lwa_obj_id
TABLES
objcont = git_data_tab
objhead = lit_objhead
* OBJPARA =
* OBJPARB =
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
dl_name_exist = 4
folder_not_exist = 5
folder_no_authorization = 6
object_type_not_exist = 7
operation_no_authorization = 8
owner_not_exist = 9
parameter_error = 10
substitute_not_active = 11
substitute_not_defined = 12
system_failure = 13
x_error = 14
OTHERS = 15.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO gwa_log-msg_desc.
gwa_log-qmnum = <gfs_vss_sap>-qmnum.
gwa_log-aufnr = <gfs_vss_sap>-aufnr.
gwa_log-posnr = <gfs_vss_sap>-posnr.
gwa_log-msg_type = sy-msgty.
CONCATENATE gwa_log-msg_desc 'Attachment Failed'
INTO gwa_log-msg_desc
SEPARATED BY gc_comma.
IF gwa_log-msg_type = gc_e.
*If message type is error cell colour RED(6) else GREEN(5).
PERFORM cell_colour USING 6.
ENDIF.
APPEND gwa_log TO git_log.
CLEAR: gwa_log.
* E=Error if there is an error in reading the file
<gfs_vss_sap>-attach_proc = gc_e.
ELSE.
IF <gfs_vss_sap>-qmnum IS NOT INITIAL.
lwa_rolea-objkey = <gfs_vss_sap>-qmnum.
lwa_rolea-objtype = gc_bus2007.
ELSEIF <gfs_vss_sap>-aufnr IS NOT INITIAL.
lwa_rolea-objkey = <gfs_vss_sap>-aufnr.
lwa_rolea-objtype = gc_bus2038.
ENDIF.
lwa_roleb-objtype = gc_message.
CONCATENATE lwa_fold_id
lwa_obj_id
INTO lwa_roleb-objkey.
* attach document as GOS attacment to realted bussiness object
CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
EXPORTING
obj_rolea = lwa_rolea
obj_roleb = lwa_roleb
relationtype = gc_atta
* IMPORTING
* BINREL =
* TABLES
* BINREL_ATTRIB =
EXCEPTIONS
no_model = 1
internal_error = 2
unknown = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO gwa_log-msg_desc.
gwa_log-qmnum = <gfs_vss_sap>-qmnum.
gwa_log-aufnr = <gfs_vss_sap>-aufnr.
gwa_log-posnr = <gfs_vss_sap>-posnr.
gwa_log-msg_type = sy-msgty.
CONCATENATE gwa_log-msg_desc 'Attachment Failed'
INTO gwa_log-msg_desc
SEPARATED BY gc_comma.
IF gwa_log-msg_type = gc_e.
*If message type is error cell colour RED else GREEN.
PERFORM cell_colour USING 6.
ENDIF.
APPEND gwa_log TO git_log.
CLEAR: gwa_log.
* E=Error if there is an error in reading the file
<gfs_vss_sap>-attach_proc = gc_e.
ELSE.
<gfs_vss_sap>-attach_proc = gc_y.
<gfs_vss_sap>-date_atsp = sy-datum.
<gfs_vss_sap>-time_atsp = sy-uzeit.
gwa_log-qmnum = <gfs_vss_sap>-qmnum.
gwa_log-aufnr = <gfs_vss_sap>-aufnr.
gwa_log-posnr = <gfs_vss_sap>-posnr.
gwa_log-msg_type = gc_s.
gwa_log-msg_desc = 'Attachment Successful'.
PERFORM cell_colour USING 5.
APPEND gwa_log TO git_log.
CLEAR: gwa_log.
ENDIF.
ENDIF.
ENDIF.
Please try using above code, if you still face the problem let me know.
Regards,
Tejas Shah
2019 Oct 09 10:33 AM
Hi ,
I am facing the same issue with my code.
Could you please send your code if it working .
It will be helpful for me.
Regards,
Ashwini Somani
2019 Oct 09 10:36 AM
Create a new question, post the part of your code & check you save the file as binary file