SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Export Graphics from SE78 SAP Form Graphics Administration using ABAP Program

ABAP developers can export graphics from SAP Form Graphics administration SE78 transaction using ABAP report whose source codes are shared in this ABAP tutorial. Unfortunately there is not a single click solution on SE78 SAP transaction screen to export graphics, logos or export images from SAP BDS system. This ABAP tutorial provides an easy program to extract bitmap images from SAP BDS (Business Document Service) and save on a local folder as a bitmap .bmp image file.

As well as uploading bitmap images or graphics to SAP images document server, it is sometimes a requirement to download and export images from SAP document server where ABAP developers and SAP customization specialists manage using SE78 tcode.

In this SAP tutorial, I will show and demonstrate how you can export images (for this tutorial SAP LOGO BMP). This is a color bitmap image as shown in below SE78 transaction UI screenshot.

export graphics from SAP SE78 transaction using ABAP
Export images and graphics from SAP SE78 transaction

Let's start out tutorial by creating a new ABAP report using ABAP Workbench.

export graphics ABAP report

First, we will start by building the selection-screen codes.
Here as you see below, the ABAP report requests a file name in an input text area.
An other parameter that the user will provide is if the image is black and white bitmap image or a color bitmap image.
This parameter is displayed using a radiobutton group in the selection screen.

SELECTION-SCREEN: BEGIN OF BLOCK sel WITH FRAME TITLE text-000.

PARAMETERS: pa_image LIKE rstxt-tdname.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 30.
PARAMETERS: bw RADIOBUTTON GROUP icol DEFAULT 'X'.
SELECTION-SCREEN COMMENT 35(30) text-001.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 30.
PARAMETERS: color RADIOBUTTON GROUP icol.
SELECTION-SCREEN COMMENT 35(30) text-002.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN: END OF BLOCK sel.
Code

Above provided ABAP source codes of the SAP selection screen generates the below screen for the user interface. This selection screen enables the user to enter the name of the bitmap image which is desired to export from SAP system.

selection screen for ABAP report

To get the stored images in SAP BDS (Business Document Service), ABAP developers can call function module SAPSCRIPT_GET_GRAPHIC_BDS.
ABAP SAPSCRIPT_GET_GRAPHIC_BDS function module gets the binary data from SAP for a given specific bitmap image uploaded to BDS (SE78 tcode).

CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
 EXPORTING
  i_object = 'GRAPHICS' " STXBITMAPS-TDOBJECT
  i_name = pa_image " STXBITMAPS-TDNAME, image name
  i_id = 'BMAP' " STXBITMAPS-TDID
  i_btype = lv_tdbtype " STXBITMAPS-TDBTYPE, black/white or color
 IMPORTING
  e_bytecount = lv_bytecount " I, size of binary image data
 TABLES
  content = lv_content " SBDST_CONTENT, binary data
 EXCEPTIONS
  not_found = 1
  bds_get_failed = 2
  bds_no_content = 3
  OTHERS = 4.
Code

The next step in our sample ABAP code is to call function module "SAPSCRIPT_CONVERT_BITMAP" to convert the returned binary data into bitmap file.

ABAP function module SAPSCRIPT_CONVERT_BITMAP converts graphics in BDS file format into BMP bitmap image format. Here is how ABAP developers can use SAPSCRIPT_CONVERT_BITMAP function module.

CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
 EXPORTING
  old_format = 'BDS' " source image file type
  new_format = 'BMP' " target image file type => .bmp
  bitmap_file_bytecount_in = lv_bytecount
 IMPORTING
  bitmap_file_bytecount = graphic_size
 TABLES
  bitmap_file = graphic_table
  bds_bitmap_file = lv_content " SBDST_CONTENT
 EXCEPTIONS
  OTHERS = 1.
Code

After BDS file in lv_content is converted to bitmap image and returned within graphic_table internal table variable, we are now ready to export bmp image to a predefined file folder. In order to export SAP BDS graphics file to a system folder, ABAP developers can use WS_DOWNLOAD function module.

ABAP developers should set the filename parameter of the WS_DOWNLOAD ABAP function module in the format including the full file path.
In this ABAP tutorial sample case, I used a constant file folder to store exported BDS images.
Perhaps it is a better idea to use ABAP folder selector or Display File Dialog control using cl_gui_frontend_services=>FILE_SAVE_DIALOG method. But this is a topic of an other ABAP tutorial.

CALL FUNCTION 'WS_DOWNLOAD'
 EXPORTING
  bin_filesize = graphic_size
  filename = lv_export_file_name " 'u:\export.bmp'
  filetype = 'BIN'
 TABLES
  data_tab = graphic_table
 EXCEPTIONS
  invalid_filesize = 1
  invalid_table_width = 2
  invalid_type = 3
  no_batch = 4
  unknown_error = 5
  gui_refuse_filetransfer = 6.
Code

After recognizing the ABAP function modules that the developers can use in their ABAP programs to export SE78 images from Business Document Service (BDS), I can share the all source codes of the sample ABAP report Z_EXPORT_GRAPHICS created for this tutorial.

REPORT z_export_graphics.

SELECTION-SCREEN: BEGIN OF BLOCK sel WITH FRAME TITLE text-000.

PARAMETERS: pa_image LIKE rstxt-tdname.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 30.
PARAMETERS: bw RADIOBUTTON GROUP icol DEFAULT 'X'.
SELECTION-SCREEN COMMENT 35(30) text-001.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 30.
PARAMETERS: color RADIOBUTTON GROUP icol.
SELECTION-SCREEN COMMENT 35(30) text-002.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN: END OF BLOCK sel.


CHECK pa_image IS NOT INITIAL.

DATA :
 lv_bytecount TYPE i,
 lv_tdbtype LIKE stxbitmaps-tdbtype,
 lv_content TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0.

DATA: graphic_size TYPE i.

DATA:
BEGIN OF graphic_table OCCURS 0,
 line(255) TYPE x,
END OF graphic_table.

DATA: lv_export_file_name TYPE RLGRAP-FILENAME.

CONCATENATE 'u:\' pa_image '.bmp' INTO lv_export_file_name.


IF bw EQ 'X'.
 lv_tdbtype = 'BMON'. " Black and White Bitmap Image
ELSE.
 lv_tdbtype = 'BCOL'. " Color Bitmap Image
ENDIF.


*** get binary data from SAP BDS for specific graphics image
CALL FUNCTION 'SAPSCRIPT_GET_GRAPHIC_BDS'
 EXPORTING
  i_object = 'GRAPHICS' " STXBITMAPS-TDOBJECT
  i_name = pa_image " STXBITMAPS-TDNAME
  i_id = 'BMAP' " STXBITMAPS-TDID
  i_btype = lv_tdbtype " STXBITMAPS-TDBTYPE
 IMPORTING
  e_bytecount = lv_bytecount " I
 TABLES
  content = lv_content " SBDST_CONTENT
 EXCEPTIONS
  not_found = 1
  bds_get_failed = 2
  bds_no_content = 3
  OTHERS = 4.

CHECK sy-subrc IS INITIAL.



*** convert graphics in BDS file format to BMP bitmap image format
CALL FUNCTION 'SAPSCRIPT_CONVERT_BITMAP'
 EXPORTING
  old_format = 'BDS' " source image file type
  new_format = 'BMP' " target image file type => .bmp
  bitmap_file_bytecount_in = lv_bytecount
 IMPORTING
  bitmap_file_bytecount = graphic_size
 TABLES
  bitmap_file = graphic_table
  bds_bitmap_file = lv_content " SBDST_CONTENT
 EXCEPTIONS
  OTHERS = 1.

CHECK sy-subrc IS INITIAL.



CALL FUNCTION 'WS_DOWNLOAD'
 EXPORTING
  bin_filesize = graphic_size
  filename = lv_export_file_name " 'u:\export.bmp'
  filetype = 'BIN'
 TABLES
  data_tab = graphic_table
 EXCEPTIONS
  invalid_filesize = 1
  invalid_table_width = 2
  invalid_type = 3
  no_batch = 4
  unknown_error = 5
  gui_refuse_filetransfer = 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.
Code

After you activate your ABAP report, you can now export SAP logo from SAP BDS system. If you run the ABAP program z_export_graphics and enter "SAP LOGO BMP" as the name of the bitmap image and choose Color Bitmap Image option and execute the report, a graphics file will be created in the target folder with the same image name.

export SAP logo from BDS - SE78 transaction



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.