How to use pictures without use TRX SE78
[How to use pictures without use TRX SE78 | How to use pictures without use TRX SE78] This is a simple way to use pictures in smartforms/sapscript without use se78 transaction, also these pictures can be used in reports. If you understand these steps, you will understand how to use DMS files with forms
This process es useful when you would like manage pictures without use se78 transaction and without transport requests. this method saves the binary data compressed from the picture in tables Z
Let’s to code
* A – Customs Functions*
*Z_HR_BIN_TABLE_COMPRESS*
FUNCTION z_hr_bin_table_compress.
*“—- —————————————————————–
*”
*”Interfase local
*” IMPORTING
*” REFERENCE(TAB_IN) TYPE UMB_BDS_CONTENT
*” REFERENCE(TAB_LEN_IN) TYPE I
*” EXPORTING
*” REFERENCE(TAB_OUT) TYPE W3MIMETABTYPE
*” REFERENCE(TAB_LEN_OUT) TYPE I
*” EXCEPTIONS
*” TABLA_VACIA
*” ERROR_BIN_TO_XSTRING
*” ERROR_INV_RANG_ZIP
*” ERROR_OVERF_ZIP
*” ERROR_COMPRESION_Z
*”—- —————————————————————–
DATA: lxs_pic TYPE xstring,
lv_lenght TYPE i.
DATA: lxs_pic_zipped TYPE xstring,
li_lenght_zipped TYPE i .
CLEAR tab_len_out.
REFRESH tab_out.
CLEAR: lxs_pic, lv_lenght.
IF tab_in[] IS INITIAL OR tab_len_in IS INITIAL.
RAISE tabla_vacia.
ENDIF.
*”—- —————————————————————–
* BIN to xstring
CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’
EXPORTING
input_length = tab_len_in
IMPORTING
buffer = lxs_pic
TABLES
binary_tab = tab_in
EXCEPTIONS failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE error_bin_to_xstring.
ENDIF.
*”—- —————————————————————–
*”—- —————————————————————–
* Compress binary
TRY. CALL METHOD cl_abap_gzip=>compress_binary
EXPORTING
raw_in = lxs_pic
raw_in_len = tab_len_in
* compress_level = 6
IMPORTING
gzip_out = lxs_pic_zipped
gzip_out_len = li_lenght_zipped .
CATCH cx_parameter_invalid_range .
RAISE error_inv_rang_zip.
CATCH cx_sy_buffer_overflow .
RAISE error_overf_zip.
ENDTRY.
*”—- —————————————————————–
*
*”—- —————————————————————–
* xstring to BIN
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lxs_pic_zipped
IMPORTING
output_length = tab_len_out
TABLES
binary_tab = tab_out.
*
*”—- —————————————————————–
ENDFUNCTION.
*Z_HR_BIN_TABLE_DECOMPRESS*
FUNCTION Z_HR_BIN_TABLE_DECOMPRESS.
*”—- —————————————————————–
*”
*”Interfase local
*” IMPORTING
*” REFERENCE(TAB_IN) TYPE W3MIMETABTYPE
*” REFERENCE(TAB_LEN_IN) TYPE I
*” EXPORTING
*” REFERENCE(TAB_OUT) TYPE UMB_BDS_CONTENT
*” REFERENCE(TAB_LEN_OUT) TYPE I
*” EXCEPTIONS
*” TABLA_VACIA
*” ERROR_BIN_TO_XSTRING
*” ERROR_INV_RANG_ZIP
*” ERROR_OVERF_ZIP
*” ERROR_COMPRES_ERROR
*”—- —————————————————————–
DATA: lxs_pic TYPE xstring,
lv_lenght TYPE i.
DATA: lxs_pic_unzipped TYPE xstring,
li_lenght_unzipped TYPE i .
CLEAR tab_len_out.
REFRESH tab_out.
CLEAR: lxs_pic, lv_lenght.
IF tab_in[] IS INITIAL
OR tab_len_in IS INITIAL.
RAISE tabla_vacia.
ENDIF.
*”—- —————————————————————–
* BIN to xstring
CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’
EXPORTING
input_length = tab_len_in
IMPORTING
buffer = lxs_pic
TABLES
binary_tab = tab_in
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
RAISE error_bin_to_xstring.
ENDIF.
*”—- —————————————————————–
*”—- —————————————————————–
* Decompress binary
TRY.
CALL METHOD cl_abap_gzip=>decompress_binary
EXPORTING
gzip_in = lxs_pic
gzip_in_len = tab_len_in
IMPORTING
raw_out = lxs_pic_unzipped
raw_out_len = li_lenght_unzipped .
CATCH cx_parameter_invalid_range .
RAISE error_inv_rang_zip.
CATCH cx_sy_buffer_overflow .
RAISE error_overf_zip.
CATCH cx_sy_compression_error .
RAISE error_compres_error.
ENDTRY.
*”—- —————————————————————–
*”—- —————————————————————–
* xstring to BIN
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = lxs_pic_unzipped
IMPORTING
output_length = tab_len_out
TABLES
binary_tab = tab_out.
*”—- —————————————————————–
ENDFUNCTION.
* B – How to upload the picture to R3
* the idea is to full the pictures table with binary data compressed from the picture
1- First create two tables with these structures (to save binary data compressed of picture):
zhr_logoh_crtcpc (header information of picture)
zhr_logop_crtcpc (position information of picture)
2- from one internal table (lt_bitmap) with binary data of image (uploaded with gui_upload) convert these information to bds format, with this function:
* Bitmap conversion
CALL FUNCTION ‘SAPSCRIPT_CONVERT_BITMAP_BDS’
EXPORTING
color = l_color “X
format = ‘BMP’
resident = space
bitmap_bytecount = lv_bytecount
compress_bitmap = space
IMPORTING
width_tw = l_width_tw
height_tw = l_height_tw
width_pix = l_width_pix
height_pix = l_height_pix
dpi = p_resolution
bds_bytecount = p_bds_bytecount
TABLES
bitmap_file = lt_bitmap “<– Binary in BMP
bitmap_file_bds = pt_content “–> BMP in BDS
EXCEPTIONS
format_not_supported = 1
no_bmp_file = 2
bmperr_invalid_format = 3
bmperr_no_colortable = 4
bmperr_unsup_compression = 5
bmperr_corrupt_rle_data = 6
OTHERS = 7.
3- then compress the binary data (this function converts the internal table of 1022X to 255X and compress the information)
DATA: lt_content_zipped TYPE w3mimetabtype,
li_len_cont_zipped TYPE i.
CALL FUNCTION ‘Z_HR_BIN_TABLE_COMPRESS’
EXPORTING
tab_in = pt_content
tab_len_in = p_bds_bytecount
IMPORTING
tab_out = lt_content_zipped
tab_len_out = li_len_cont_zipped
EXCEPTIONS
tabla_vacia = 1
error_bin_to_xstring = 2
error_inv_rang_zip = 3
error_overf_zip = 4
OTHERS = 5.
4- Save the compressed information to and ID ‘0000000001’
APPEND LINES OF lt_content_zipped TO zhr_logop_crtcpc
5- Save the long of file and one ID of the picture and ID ”0000000001′
li_len_cont_zipped TO zhr_logoh_crtcpc-len.
‘0000000001’ TO zhr_logoh_crtcpc-id_logo.
Finally the complete code is::
*main code*
* INI – global definitions
DATA: gv_id_logo TYPE zhr_logoh_crtcpc-id_logo VALUE ‘0000000001’.
DATA: gv_nm_img TYPE stxbitmaps-tdname VALUE ‘Y$CERT$0001’.
DATA: gv_pic_from_z TYPE c LENGTH 1 ,
gv_id_logo TYPE zhr_logoh_crtcpc-id_logo VALUE 2,
gv_resolution TYPE stxbitmaps-resolution VALUE 075,
gv_desc TYPE zhr_logoh_crtcpc-DESCRIP.
DATA: gs_logoh TYPE zhr_logoh_crtcpc.
* FIN – global definitions
FORM upload_imagen CHANGING p_bds_bytecount TYPE i
pt_content TYPE umb_bds_content.
DATA: l_filename TYPE string,
lv_bytecount TYPE i,
lt_bitmap TYPE umb_bds_content.
CLEAR: lv_bytecount, p_bds_bytecount.
REFRESH: pt_content, lt_bitmap.
* Obtener nombre de archivo
PERFORM get_filename
CHANGING
l_filename.
IF l_filename IS INITIAL.
MESSAGE ‘No selecciono ningun archivo. Se cancela la operación’ TYPE ‘S’.
RETURN.
ENDIF.
* Levantar el archivo seleccionado
CALL FUNCTION ‘GUI_UPLOAD’
EXPORTING
filename = l_filename
filetype = ‘BIN’
IMPORTING
filelength = lv_bytecount
TABLES
data_tab = lt_bitmap
EXCEPTIONS
file_open_error = 2
file_read_error = 3
no_batch = 1
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
DATA: l_color(1) TYPE c VALUE ‘X’,
l_width_tw TYPE stxbitmaps-widthtw,
l_height_tw TYPE stxbitmaps-heighttw,
l_width_pix TYPE stxbitmaps-widthpix,
l_height_pix TYPE stxbitmaps-heightpix,
l_bds_object TYPE REF TO cl_bds_document_set,
p_resolution TYPE stxbitmaps-resolution.
p_resolution = gv_resolution.
* Bitmap conversion
CALL FUNCTION ‘SAPSCRIPT_CONVERT_BITMAP_BDS’
EXPORTING
color = l_color
format = ‘BMP’
resident = space
bitmap_bytecount = lv_bytecount
compress_bitmap = space
IMPORTING
width_tw = l_width_tw
height_tw = l_height_tw
width_pix = l_width_pix
height_pix = l_height_pix
dpi = p_resolution
bds_bytecount = p_bds_bytecount
TABLES
bitmap_file = lt_bitmap “– Binario en BMP
bitmap_file_bds = pt_content “– BMP en BDS
EXCEPTIONS
format_not_supported = 1
no_bmp_file = 2
bmperr_invalid_format = 3
bmperr_no_colortable = 4
bmperr_unsup_compression = 5
bmperr_corrupt_rle_data = 6
OTHERS = 7.
DATA:
lt_content_zipped TYPE w3mimetabtype,
li_len_cont_zipped TYPE i.
CALL FUNCTION ‘Z_HR_BIN_TABLE_COMPRESS’
EXPORTING
tab_in = pt_content
tab_len_in = p_bds_bytecount
IMPORTING
tab_out = lt_content_zipped
tab_len_out = li_len_cont_zipped
EXCEPTIONS
tabla_vacia = 1
error_bin_to_xstring = 2
error_inv_rang_zip = 3
error_overf_zip = 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.
* Grabar archivo en tablas Z!!!!!!!!! ***************************************************
DATA: gt_logos_p TYPE STANDARD TABLE OF zhr_logop_crtcpc,
ls_logos_h TYPE zhr_logoh_crtcpc.
FIELD-SYMBOLS line LIKE LINE OF lt_content_zipped.
DATA: lv_id_logo TYPE zhr_logoh_crtcpc-id_logo VALUE 44.
* Generar ID del logo!!
lv_id_logo = gv_id_logo .
ls_logos_h-id_logo = lv_id_logo.
ls_logos_h-descrip = ‘desc’.
ls_logos_h-len = li_len_cont_zipped.
* Insertar datos binarios comprimidos de la imagen en la tabla Z cabecera
MODIFY zhr_logoh_crtcpc FROM ls_logos_h.
DATA: lv_sytabix LIKE sy-tabix.
LOOP AT lt_content_zipped ASSIGNING line.
ENDLOOP.
* Insertar datos binarios comprimidos de la imagen en la tabla Z posicion
MODIFY zhr_logop_crtcpc FROM TABLE gt_logos_p.
COMMIT WORK.
***************************************************
ENDFORM. ” UPLOAD_IMAGEN
*used subroutines*
FORM get_filename CHANGING p_filename TYPE string.
DATA: lt_file TYPE filetable,
ls_file LIKE LINE OF lt_file,
lv_rc TYPE i.
*
class cl_gui_frontend_services definition load.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = ‘Seleccionar imagen BMP a cargar’
default_extension = ‘*.bmp’
file_filter = ‘*.bmp’
multiselection = abap_false
CHANGING
file_table = lt_file
rc = lv_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 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.
ELSE.
CHECK NOT lt_file[] IS INITIAL.
READ TABLE lt_file INDEX 1 INTO ls_file.
p_filename = ls_file.
ENDIF.
ENDFORM. ” GET_FILENAME
*main code*
FORM down_pdf .
***************************************************
** INI – Gen form en OTF
***************************************************
DATA : l_x(1) VALUE ‘X’. DATA:
lv_text TYPE char3,
lv_syucomm TYPE char1,
ls_pdf TYPE xstring,
lv_fm_name TYPE rs38l_fnam,
lv_control_parameters TYPE ssfctrlop,
lv_output_options TYPE ssfcompop,
lv_ssf_output TYPE ssfcrescl,
lt_otfdata TYPE TABLE OF itcoo.
DATA: lc_afjp(20) TYPE c,
l_hijos TYPE kdart,
l_remuneracion TYPE inits.
DATA: itab_detalles TYPE STANDARD TABLE OF zhr_detalle_candidato,
s_detalles TYPE zhr_detalle_candidato.
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’
EXPORTING
formname = ‘ZCDGR01’
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Error MESSAGE
ENDIF.
* Set relevant control parameters
lv_control_parameters-getotf = l_x. “OTF output
lv_control_parameters-no_dialog = l_x. “No print dialog
lv_control_parameters-preview = space. “No preview
* Set relevant output options
lv_output_options-tdnewid = l_x. “Print parameters,
lv_output_options-tddelete = space. “Print parameters,
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = lv_control_parameters
output_options = lv_output_options
user_settings = space
IMPORTING
job_output_info = lv_ssf_output
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 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.
REFRESH lt_otfdata.
lt_otfdata[] = lv_ssf_output-otfdata[].
***************************************************
** FIN – Gen form en OTF
***************************************************
***************************************************
** INI – create form con picture
***************************************************
DATA: ls_otfdata LIKE LINE OF lt_otfdata,
lt_otfdata_cpy TYPE TABLE OF itcoo.
FIELD-SYMBOLS LIKE LINE OF lt_otfdata_cpy.
* generate new table
APPEND INITIAL LINE TO lt_otfdata_cpy ASSIGNING .
–tdprintcom EQ ‘OP’.
* Find page configuration in otf table
gv_id_logo = ‘0000000001’.
PERFORM append_imagen USING gv_id_logo CHANGING lt_otfdata_cpy.
ENDIF.
ENDLOOP.
ENDIF.
REFRESH lt_otfdata.
lt_otfdata[] = lt_otfdata_cpy[].
***************************************************
** FIN – create form con picture
***************************************************
DATA: lc_filename TYPE string,
li_filelength TYPE i,
ld_filesize TYPE i,
lt_docs TYPE TABLE OF docs,
lt_lines TYPE TABLE OF tline,
lt_pdf255 TYPE TABLE OF so_text255.
DATA: BEGIN OF lt_objbin OCCURS 0.
INCLUDE STRUCTURE solisti1.
DATA: END OF lt_objbin.
REFRESH: lt_objbin, lt_lines, lt_pdf255.
* Convert OTF to PDF
CALL FUNCTION ‘CONVERT_OTF_2_PDF’
IMPORTING
bin_filesize = ld_filesize
TABLES
otf = lt_otfdata[]
doctab_archive = lt_docs
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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.
* adjust PDF table
CALL FUNCTION ‘SX_TABLE_LINE_WIDTH_CHANGE’
EXPORTING
transfer_bin = ‘X’
TABLES
content_in = lt_lines
content_out = lt_pdf255
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 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.
lt_objbin[] = lt_pdf255[].
lc_filename = ‘c: aja.pdf’.
* download the pdf generated
CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = lc_filename
filetype = ‘BIN’
IMPORTING
filelength = li_filelength
TABLES
data_tab = lt_objbin
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.
ENDFORM. ” DOWN_PDF
*used subroutines*
FORM append_imagen
USING p_id_logo TYPE zhr_logoh_crtcpc-id_logo
CHANGING pt_otfdata TYPE tt_itcoo.
DATA: lv_bds_bytecount TYPE i,
lt_content TYPE umb_bds_content,
l_otf TYPE tt_itcoo. * BDS bitmaps: buffer that holds info on resident bitmaps
DATA BEGIN OF bitmap_buffer_bds OCCURS 10.
INCLUDE STRUCTURE stxbitmaps.
DATA: act_w_tw LIKE stxbitmaps-widthtw,
act_h_tw LIKE stxbitmaps-heighttw,
act_dpi LIKE stxbitmaps-resolution.
DATA END OF bitmap_buffer_bds.
DATA: resident LIKE stxbitmaps-resident,
bds_filesize TYPE i.
FIELD-SYMBOLS LIKE LINE OF pt_otfdata.
DATA: t_img TYPE W3MIMETABTYPE.
* Obtener imagen
PERFORM get_imagen
USING p_id_logo
CHANGING lv_bds_bytecount lt_content t_img.
******************************************************************
*==================== INI CREATE OTF ===========================
REFRESH l_otf. bitmap_buffer_bds-tdbtype = ‘BCOL’.
bitmap_buffer_bds-act_dpi = 100.
“
gv_resolution. bds_filesize = lv_bds_bytecount.
“lv_bytecount.
“lv_graphic_size. “928508.
* convert BIN to OTF
PERFORM fill_otf_from_bds_content IN PROGRAM saplstxbitmaps
TABLES lt_content l_otf USING bitmap_buffer_bds-tdbtype
resident
bitmap_buffer_bds-act_dpi
bds_filesize.
*==================== FIN CREATE OTF ===========================
******************************************************************
* Append OTF records for the picture
APPEND INITIAL LINE TO pt_otfdata ASSIGNING -tdprintcom = ‘MT’.
* Gen position ‘XXXXXYYYYY’ XXXXX=for x axis / YYYYY=for y axis LIKE LINE OF lt_content_zipped.
DATA: lv_id_logo TYPE zhr_logoh_crtcpc-id_logo VALUE 44.
CLEAR: lv_bytecount, p_bds_bytecount.
REFRESH: pt_content, lt_bitmap.
***************************************************
** INI – Get binary information from tables
***************************************************
lv_id_logo = p_id_img .
* Get header data
CLEAR ls_logos_h.
SELECT SINGLE * FROM zhr_logoh_crtcpc INTO ls_logos_h
WHERE id_logo = lv_id_logo.
li_len_cont_zipped = ls_logos_h-len.
REFRESH gt_logos_p.
* Get position data
SELECT * FROM zhr_logop_crtcpc INTO TABLE gt_logos_p
WHERE id_logo = ls_logos_h-id_logo.
* generate zipped information table
REFRESH lt_content_zipped .
LOOP AT gt_logos_p ASSIGNING -line.
ENDLOOP.
***************************************************
** FIN – Get binary information from tables
***************************************************
pt_igm[] = lt_content_zipped[].
* Decompress Binary data
CALL FUNCTION ‘Z_HR_BIN_TABLE_DECOMPRESS’
EXPORTING tab_in = lt_content_zipped
tab_len_in = li_len_cont_zipped
IMPORTING
tab_out = pt_content
tab_len_out = p_bds_bytecount
EXCEPTIONS
tabla_vacia = 1
error_bin_to_xstring = 2
error_inv_rang_zip = 3
error_overf_zip = 4
ERROR_COMPRES_ERROR = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. ” GET_IMAGEN
* D – How to show the picture in R3
* the idea is to show pictures table with binary data compressed from the picture into R/3
1- first, draw a container named ‘PICTURE’ in screen painter.
2- Create the global data
TYPES: pict_line(256) TYPE c.
DATA: pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
DATA: container1 TYPE REF TO cl_gui_custom_container,
picture TYPE REF TO cl_gui_picture.
DATA: lv_bytecount TYPE i,
lv_tdbtype LIKE stxbitmaps-tdbtype,
lv_content TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0.
DATA: lv_graphic_size TYPE i.
DATA: BEGIN OF graphic_table OCCURS 0,
line(255) TYPE x,
END OF graphic_table.
2- Instantiate objects
IF NOT container1 IS BOUND.
CREATE OBJECT: container1
EXPORTING container_name = ‘PICTURE’.
ENDIF.
IF NOT picture IS BOUND.
CREATE OBJECT: picture
EXPORTING parent = container1.
ENDIF.
3- Get the binary information from zhr_logoh_crtcpc and zhr_logop_crtcpc tables
4- Decompress the binary information
CALL FUNCTION ‘Z_HR_BIN_TABLE_DECOMPRESS’
EXPORTING
tab_in = lt_content_zipped
tab_len_in = li_len_cont_zipped
IMPORTING
tab_out = pt_content
tab_len_out = p_bds_bytecount
EXCEPTIONS
tabla_vacia = 1
error_bin_to_xstring = 2
error_inv_rang_zip = 3
error_overf_zip = 4
ERROR_COMPRES_ERROR = 5
OTHERS = 6.
5 – Convert binary data to BDS format
CALL FUNCTION ‘SAPSCRIPT_CONVERT_BITMAP’
EXPORTING
old_format = ‘BDS’
new_format = ‘BMP’
bitmap_file_bytecount_in = lv_bytecount
IMPORTING
bitmap_file_bytecount = lv_graphic_size
TABLES
bds_bitmap_file = lv_content
bitmap_file = graphic_table
EXCEPTIONS
OTHERS = 1.
6- Create url for internal table with picture data
CALL FUNCTION ‘DP_CREATE_URL’
EXPORTING
type = ‘IMAGE’
subtype = ‘BMP’
TABLES
data = graphic_table
CHANGING
url = url.
7- Set url and show picture un container created
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.
CALL METHOD picture->set_display_mode
EXPORTING
display_mode = picture->display_mode_fit_center.
Finally the complete code is:
*main code*
* BEG create global data
TYPES: pict_line(256) TYPE c.
DATA: pict_tab TYPE TABLE OF pict_line,
url(255) TYPE c.
DATA: container1 TYPE REF TO cl_gui_custom_container,
picture TYPE REF TO cl_gui_picture.
DATA: lv_bytecount TYPE i,
lv_tdbtype LIKE stxbitmaps-tdbtype,
lv_content TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0.
DATA: lv_graphic_size TYPE i.
DATA: BEGIN OF graphic_table OCCURS 0,
line(255) TYPE x, END OF graphic_table.
DATA: t_img TYPE W3MIMETABTYPE.
DATA: lv_bds_bytecount TYPE i,
lt_content TYPE umb_bds_content.
* END create global data
IF NOT container1 IS BOUND.
CREATE OBJECT: container1
EXPORTING
container_name = ‘PICTURE’.
ENDIF.
IF NOT picture IS BOUND.
CREATE OBJECT: picture
EXPORTING
parent = container1.
ENDIF.
gv_id_logo = ‘0000000001’. “Cargar nombre de la imagen
PERFORM get_imagen
USING gv_id_logo
CHANGING lv_bds_bytecount lt_content t_img.
v_bytecount = lv_bds_bytecount.
lv_content[] = lt_content[].
CALL FUNCTION ‘SAPSCRIPT_CONVERT_BITMAP’
EXPORTING
old_format = ‘BDS’
new_format = ‘BMP’
bitmap_file_bytecount_in = lv_bytecount
IMPORTING
bitmap_file_bytecount = lv_graphic_size
TABLES
bds_bitmap_file = lv_content
bitmap_file = graphic_table
EXCEPTIONS OTHERS = 1.
* Create url for internal table with picture data
CALL FUNCTION ‘DP_CREATE_URL’
EXPORTING
type = ‘IMAGE’
subtype = ‘BMP’
TABLES
data = graphic_table
CHANGING
url = url.
* Set url and show picture un container created
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.
CALL METHOD picture->set_display_mode
EXPORTING display_mode = picture->display_mode_fit_center.
*used subroutines*
LIKE LINE OF lt_content_zipped.
DATA: lv_id_logo TYPE zhr_logoh_crtcpc-id_logo VALUE 44.
CLEAR: lv_bytecount, p_bds_bytecount.
REFRESH: pt_content, lt_bitmap.
lv_id_logo = p_id_img .
* Obtener los datos de la cabecera
CLEAR ls_logos_h.
SELECT SINGLE * FROM zhr_logoh_crtcpc
INTO ls_logos_h
WHERE id_logo = lv_id_logo.
li_len_cont_zipped = ls_logos_h-len.
REFRESH gt_logos_p.
* Obtener los datos de las posiciones
SELECT * FROM zhr_logop_crtcpc INTO TABLE gt_logos_p
WHERE id_logo = ls_logos_h-id_logo.
* solo para Corroborar
REFRESH lt_content_zipped .
LOOP AT gt_logos_p ASSIGNING -line.
ENDLOOP.
pt_igm[] = lt_content_zipped[].
* Decompress binary table
CALL FUNCTION ‘Z_HR_BIN_TABLE_DECOMPRESS’
EXPORTING
tab_in = lt_content_zipped
tab_len_in = li_len_cont_zipped
IMPORTING
tab_out = pt_content
tab_len_out = p_bds_bytecount
EXCEPTIONS
tabla_vacia = 1
error_bin_to_xstring = 2
error_inv_rang_zip = 3
error_overf_zip = 4
ERROR_COMPRES_ERROR = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. ” GET_IMAGEN
If you show this information get this result:
New NetWeaver Information at SAP.com
Very Helpfull