03-17-2006 11:01 PM
Hello SAPients.
I know that I can upload an image to SAP using transaction SE78, but now I need the inverse process, I mean, download an image from SAP to my PC. How can I do this?
Thanks in advance for your help.
03-18-2006 9:26 AM
Hi,
In SE80, you should have a Repository for MIMES, including images.You should find your image here !
Best regards
03-18-2006 11:04 AM
you have to use the following method to get the image as a binary string and then use gui_download to download it to local system
call method cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
exporting
p_object = fs_stxbitmaps-tdobject
p_name = fs_stxbitmaps-tdname
p_id = fs_stxbitmaps-tdid
p_btype = fs_stxbitmaps-tdbtype
receiving
p_bmp = loc_graphic_xstr
exceptions
not_found = 1
others = 2.
Regards
Raja
06-07-2006 12:46 PM
Hi Raja,
Can you tell me how we can use it for the following and let me know what to fill in ???
CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP
EXPORTING
P_OBJECT = GRAPHICS
P_NAME = IDES_LOGO
P_ID = BMAP
P_BTYPE = ???
RECEIVING
P_BMP = ???
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
others = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please help me.
Regards
Deep
06-07-2006 1:02 PM
you can get those details for your graphics from table
STXBITMAPS
p_btype is either 'BMON' or BCOL'
p_bmp should be variable of type xstring to receive the bmp content as xstring.
Regards
Raja
06-07-2006 1:04 PM
Hii
check this demo prgram regarding the func module
<b>MSSCHO02</b>
You can store your pictures in the web repository (transaction code SMW0) and for reaching them during the program execution, you need a link to be generated by use of 'WWW_GET_MIME_OBJECT' and 'DP_CREATE_URL'.
chk this link..
chk this program
CONSTANTS: CNTL_TRUE TYPE I VALUE 1,
CNTL_FALSE type i value 0.
data:
h_picture type ref to cl_gui_picture,
h_pic_container type ref to cl_gui_custom_container.
* h_tree type ref to cl_gui_list_tree,
* h_docking type ref to cl_gui_docking_container,
* h_application type ref to lcl_application.
data: graphic_url(255),
graphic_refresh(1),
g_result like cntl_true.
data: begin of graphic_table occurs 0,
line(255) type x,
end of graphic_table.
data: graphic_size type i.
*--------------------------------------------------------------------*
***INCLUDE ZDISPLAYIMAGEPBO .
*--------------------------------------------------------------------*
*&-------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
module STATUS_0100 output.
data: l_graphic_xstr type xstring,
l_graphic_conv type i,
l_graphic_offs type i.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = 'ENJOY' "IMAGE NAME - Image name from SE78
p_id = 'BMAP'
p_btype = 'BMON' "(BMON = black&white, BCOL = colour)
RECEIVING
p_bmp = l_graphic_xstr
EXCEPTIONS
not_found = 1
OTHERS = 2.
* IF sy-subrc = 1.
* MESSAGE e287 WITH g_stxbitmaps-tdname.
* ELSEIF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
* EXIT.
* ENDIF.
graphic_size = XSTRLEN( l_graphic_xstr ).
CHECK graphic_size > 0.
l_graphic_conv = graphic_size.
l_graphic_offs = 0.
WHILE l_graphic_conv > 255.
graphic_table-line = l_graphic_xstr+l_graphic_offs(255).
APPEND graphic_table.
l_graphic_offs = l_graphic_offs + 255.
l_graphic_conv = l_graphic_conv - 255.
ENDWHILE.
graphic_table-line = l_graphic_xstr+l_graphic_offs(L_GRAPHIC_CONV).
APPEND graphic_table.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image' "#EC NOTEXT
subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'
size = graphic_size
lifetime = cndp_lifetime_transaction "'T'
TABLES
data = graphic_table
CHANGING
url = graphic_url
EXCEPTIONS
* dp_invalid_parameter = 1
* dp_error_put_table = 2
* dp_error_general = 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.
EXIT.
ENDIF.
create object h_pic_container
exporting container_name = 'CUST_CONTROL'.
create object h_picture exporting parent = h_pic_container.
call method h_picture->load_picture_from_url
exporting url = graphic_url
importing result = g_result.
endmodule. " STATUS_0100 OUTPUT
Regards
Naresh
02-11-2015 8:50 AM
The following program codes allow you to download SAP images stored in SE78 and the traditional SO10:
*&---------------------------------------------------------------------
*& Report Z_DOWNLOAD_BDS_GRAPHICS
*&
*&---------------------------------------------------------------------
*& Download image stored in document server
*& Published at SAPTechnical.COM
*&
*&---------------------------------------------------------------------
REPORT z_download_bds_graphics .
***********************************************************************
* Variable declaration
***********************************************************************
DATA: v_graphic_size TYPE i,
v_graphic_xstr TYPE xstring,
v_graphic_conv TYPE i,
v_graphic_offs TYPE i,
v_file TYPE string.
***********************************************************************
* Table declaration
***********************************************************************
DATA: BEGIN OF i_graphic_table OCCURS 0,
line(255) TYPE x,
END OF i_graphic_table.
DATA: lt_tline type table of tline with header line.
data: l_thead type thead.
***********************************************************************
* Structure declaration
***********************************************************************
DATA: st_stxbitmaps TYPE stxbitmaps.
***********************************************************************
* Selection screen
***********************************************************************
PARAMETERS: P_SO10 RADIOBUTTON GROUP RB1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_TDID LIKE THEAD-TDID DEFAULT 'ADRS',
p_TDNAME LIKE THEAD-TDNAME,
p_TDOBJ LIKE THEAD-TDOBJECT DEFAULT 'TEXT',
p_TDSPRA LIKE THEAD-TDSPRAS DEFAULT 'EN'.
SELECTION-SCREEN END OF BLOCK b2.
PARAMETERS: p_se78 RADIOBUTTON GROUP RB1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_object LIKE st_stxbitmaps-tdobject DEFAULT 'GRAPHICS'
MODIF ID abc ,
p_name LIKE st_stxbitmaps-tdname,
p_id LIKE st_stxbitmaps-tdid DEFAULT 'BMAP'
MODIF ID abc ,
p_type LIKE st_stxbitmaps-tdbtype.
SELECTION-SCREEN END OF BLOCK b1.
PARAMETERS: p_dir TYPE localfile DEFAULT 'D:\GIS'.
***********************************************************************
* At Selection-screen output event
***********************************************************************
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-group1 = 'ABC' .
screen-input = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
***********************************************************************
* At Selection-screen on value-request event
***********************************************************************
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dir.
DATA: l_folder TYPE string.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'Select Folder'
initial_folder = 'C:\'
CHANGING
selected_folder = l_folder
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc = 0.
p_dir = l_folder.
ENDIF.
***********************************************************************
* Start-of-selection event
***********************************************************************
START-OF-SELECTION.
IF p_se78 = 'X'.
st_stxbitmaps-tdobject = p_object.
st_stxbitmaps-tdname = p_name.
st_stxbitmaps-tdid = p_id.
st_stxbitmaps-tdbtype = p_type.
* Get the bmp image from BDS in hex string format
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = st_stxbitmaps-tdobject
p_name = st_stxbitmaps-tdname
p_id = st_stxbitmaps-tdid
p_btype = st_stxbitmaps-tdbtype
RECEIVING
p_bmp = v_graphic_xstr
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc = 0.
* Find the length of hex string
v_graphic_size = xstrlen( v_graphic_xstr ).
CHECK v_graphic_size > 0.
v_graphic_conv = v_graphic_size.
v_graphic_offs = 0.
* Populate internal table from this hex string
WHILE v_graphic_conv > 255.
i_graphic_table-line = v_graphic_xstr+v_graphic_offs(255).
APPEND i_graphic_table.
v_graphic_offs = v_graphic_offs + 255.
v_graphic_conv = v_graphic_conv - 255.
ENDWHILE.
i_graphic_table-line = v_graphic_xstr+v_graphic_offs(v_graphic_conv).
APPEND i_graphic_table.
* Prepare file name and file path
CONCATENATE p_dir '\' p_name '.BMP' INTO v_file.
* Download image
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_graphic_size
filename = v_file
filetype = 'BIN'
TABLES
data_tab = i_graphic_table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc = 0.
WRITE: 'File downloaded successfully'(003), v_file.
ELSE.
WRITE: 'Error during file download'(004).
ENDIF.
ELSE.
CASE sy-subrc.
WHEN 1.
WRITE: 'Image not found'(005).
WHEN OTHERS.
WRITE: 'Error in Image retrieval'(006).
ENDCASE.
ENDIF.
ENDIF. "IF P_SE78 = 'X'.
IF P_SO10 = 'X'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
ID = p_TDID
LANGUAGE = p_TDSPRA
NAME = p_TDNAME
OBJECT = p_TDOBJ
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
IMPORTING
HEADER = l_thead
TABLES
LINES = lt_tline
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF SY-SUBRC <> 0.
WRITE: 'Image not found'(005).
ENDIF.
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
EXPORTING
ITF_HEADER = l_thead
OLD_FORMAT = 'ITF'
NEW_FORMAT = 'BMP'
BITMAP_FILE_BYTECOUNT_IN = 0
ITF_BITMAP_TYPE_IN = '*'
IMPORTING
BITMAP_FILE_BYTECOUNT = v_graphic_size
* ITF_BITMAP_TYPE_OUT =
TABLES
ITF_LINES = lt_tline
BITMAP_FILE = i_graphic_table
* BDS_BITMAP_FILE =
EXCEPTIONS
NO_BITMAP_FILE = 1
FORMAT_NOT_SUPPORTED = 2
BITMAP_FILE_NOT_TYPE_X = 3
NO_BMP_FILE = 4
BMPERR_INVALID_FORMAT = 5
BMPERR_NO_COLORTABLE = 6
BMPERR_UNSUP_COMPRESSION = 7
BMPERR_CORRUPT_RLE_DATA = 8
BMPERR_EOF = 9
BDSERR_INVALID_FORMAT = 10
BDSERR_EOF = 11
OTHERS = 12
.
IF SY-SUBRC <> 0.
WRITE: 'Error in Image Format'(006).
ENDIF.
if sy-subrc = 0.
CONCATENATE p_dir '\' p_TDNAME '.BMP' INTO v_file.
* Download image
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_graphic_size
filename = v_file
filetype = 'BIN'
TABLES
data_tab = i_graphic_table
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc = 0.
WRITE: 'File downloaded successfully'(003), v_file.
ELSE.
WRITE: 'Error during file download'(004).
ENDIF.
endif.
ENDIF.
07-24-2015 8:35 PM
10-27-2015 11:02 AM