* _______ _______ _______ _______ _______ _______ ______ _______ _______ ______ _______ * | _ | _ | _ | | | _ | || _ | _ | _ | | _ | * | |_| | |_| | |_| | _ | | |_| | _ | |_| | |_| | | || | |_| | * | | | | |_| | | | | | | | | |_||_| | * | | _ || | ___| _| | |_| | | _ || __ | | * | _ | |_| | _ | | | |_| _ | | _ | |_| | | | | _ | * |__| |__|_______|__| |__|___| |_______|__| |__|______||__| |__|_______|___| |_|__| |__| * www.abapcadabra.com * *------------------------------------------------------------------------------------------- * program : ZABAPCADABRA_GRAPHIC_TO_BMP * title : Download SapScript graphics to .BMP file * functional area : Technical support - development tooling * environment : 4.7 * program Function : Transaction SE78 creates SAP Graphics objects for forms (BDS or * Business Documents Service - graphics). These objects can not * be downloaded from the system. This simple report reads the object * and creates a .BMP from it. * Documentation : Search for "Graphics download" on AbapcadabrA.com * Previous version : This is the initial version * Developer name : Wim Maasdam * Development date : 28/09/2016 * Version : 0.1 *--------------------------------------------------------------------- * Change list: * Date Description * 28/09/2016 Initial release * Credits to Keerthi Hiremath, january 2003. Founder of * the idea. *--------------------------------------------------------------------- REPORT ZABAPCADABRA_GRAPHIC_TO_BMP. type-pools: sbdst . tables: sscrfields. "Selection screen purpose only *--------------------------------------------------------------------- * C L A S S D E F I N I T I O N *--------------------------------------------------------------------- CLASS lcl_controller DEFINITION. PUBLIC SECTION. CLASS-DATA: gw_stxbitmaps type stxbitmaps, gv_filename type rlgrap-filename. CLASS-METHODS: main_process, f4_presentation_file importing title type any changing filepath type any. ENDCLASS. *--------------------------------------------------------------------- * S E L E C T I O N - S C R E E N *--------------------------------------------------------------------- selection-SCREEN: BEGIN OF LINE, COMMENT 1(23) lbl_01 FOR FIELD pa_tdobj. PARAMETERS: pa_tdobj TYPE stxbitmaps-tdobject default 'GRAPHICS' MODIF ID RO. selection-SCREEN: END OF LINE, BEGIN OF LINE, COMMENT 1(23) lbl_02 FOR FIELD pa_tdnam. PARAMETERS: pa_tdnam TYPE stxbitmaps-tdname. selection-SCREEN: END OF LINE, BEGIN OF LINE, COMMENT 1(23) lbl_03 FOR FIELD pa_tdid. PARAMETERS: pa_tdid TYPE stxbitmaps-tdid default 'BMAP' MODIF ID RO. selection-SCREEN: END OF LINE, BEGIN OF LINE, COMMENT 1(23) lbl_04 FOR FIELD pa_tdtyp. PARAMETERS: pa_tdtyp TYPE stxbitmaps-tdbtype default 'BCOL' MODIF ID RO. selection-SCREEN: END OF LINE, SKIP, BEGIN OF LINE, COMMENT 1(23) lbl_05 FOR FIELD pa_filen. PARAMETERS: pa_filen TYPE rlgrap-filename. selection-SCREEN: END OF LINE. SELECTION-SCREEN: SKIP, BEGIN OF LINE, PUSHBUTTON (70) lbl_abca USER-COMMAND ABAPCADABRA VISIBLE LENGTH 5, END OF LINE. AT SELECTION-SCREEN OUTPUT. loop at screen. if screen-group1 = 'RO'. screen-input = '0'. modify screen. endif. endloop. at selection-screen on value-request for pa_tdnam. call function 'SAPSCRIPT_SEARCH_GRAPHIC_BDS' exporting selection_screen = 'X' select_entry = 'X' selection_show = 'X' importing e_object = pa_tdobj e_id = pa_tdid e_name = pa_tdnam e_btype = pa_tdtyp exceptions others = 0. at selection-screen on value-request for pa_filen. lcl_controller=>f4_presentation_file( exporting title = 'Choose file' changing filepath = pa_filen ). AT SELECTION-SCREEN. CASE sscrfields-ucomm. WHEN 'ABAPCADABRA'. CALL FUNCTION 'CALL_BROWSER' EXPORTING URL = 'http://abapcadabra.com' EXCEPTIONS OTHERS = 0. ENDCASE. *--------------------------------------------------------------------- * C L A S S I M P L E M E N T A T I O N *--------------------------------------------------------------------- CLASS lcl_controller IMPLEMENTATION. method main_process. data: lv_bytecount type i, lt_content type sbdst_content, lv_bitmaptypeout type c length 1, lt_rawdata type standard table of w3mime. * Fetch graphics object call function 'SAPSCRIPT_GET_GRAPHIC_BDS' exporting i_object = gw_stxbitmaps-tdobject i_name = gw_stxbitmaps-tdname i_id = gw_stxbitmaps-tdid i_btype = gw_stxbitmaps-tdbtype importing e_bytecount = lv_bytecount tables content = lt_content exceptions others = 4. if sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. exit. endif. * Convert it to a botmap call function 'SAPSCRIPT_CONVERT_BITMAP ' exporting old_format = 'BDS' new_format = 'BMP' bitmap_file_bytecount_in = lv_bytecount itf_bitmap_type_in = '*' importing bitmap_file_bytecount = lv_bytecount itf_bitmap_type_out = lv_bitmaptypeout tables bitmap_file = lt_rawdata bds_bitmap_file = lt_content exceptions others = 4. if sy-subrc <> 0. MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. exit. endif. * And store the result in a local (.BMP) file call function 'WS_DOWNLOAD' exporting bin_filesize = lv_bytecount filename = gv_filename filetype = 'BIN' tables data_tab = lt_rawdata exceptions others = 4. if sy-subrc <> 0. message id sy-msgid type 'S' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. else. message 'File saved' type 'S'. endif. endmethod. method f4_presentation_file. data: lt_files type standard table of sdokpath, lw_file type sdokpath. call function 'TMP_GUI_FILE_OPEN_DIALOG' exporting window_title = title default_filename = filepath tables file_table = lt_files exceptions others = 4. if sy-subrc <> 0. message 'Front end file open error' type 'E'. else. read table lt_files index 1 into lw_file. filepath = lw_file-pathname. endif. endmethod. "f4_presentation_file ENDCLASS. *--------------------------------------------------------------------- * I N I T I T A L I Z A T I O N *--------------------------------------------------------------------- INITIALIZATION. * All texts for this report have been set up as hard-coded texts (no use * of the report text-pool). Reason: easy copying of report source code. lbl_abca = '@N5\QMore on AbapcadabrA.com@'. lbl_01 = 'Application object'. lbl_02 = 'Name'. lbl_03 = 'ID'. lbl_04 = 'Type'. lbl_05 = 'Local file'. *--------------------------------------------------------------------- * S T A R T - O F - S E L E C T I O N *--------------------------------------------------------------------- start-of-selection. lcl_controller=>gw_stxbitmaps-tdobject = pa_tdobj. lcl_controller=>gw_stxbitmaps-tdname = pa_tdnam. lcl_controller=>gw_stxbitmaps-tdid = pa_tdid. lcl_controller=>gw_stxbitmaps-tdbtype = pa_tdtyp. lcl_controller=>gv_filename = pa_filen. lcl_controller=>main_process( ).