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 SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.




CRM Companies List
Web Based CRM Software


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.

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.

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.

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.

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.

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 Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table






Related Articles and Tutorials(http://www.kodyaz.com/sap-abap/export-graphics-se78-using-abap-code.aspx)
Export SAP Data to Fixed Length Text File
Complete List of SAP Modules
Free Adobe LiveCycle Designer Download
Main program for include RV61Bxxx not found
How to Upload Data to SAP from Excel File using alsm_excel_to_internal_table Function Module
Upload Data from Excel File in ABAP using TEXT_CONVERT_XLS_TO_SAP
Email Spool Request using SAPOffice - Spool to PDF
How to Create SAPScript Text using SO10 Transaction Code
How to Display SAP Graphics using SE78 Transaction Code
SAP Tutorial - Convert Spool Request to PDF File using RSTXPDFT4 ABAP Report
ABAP Debugging using Log Point and Break Point
ABAP Runtime Error ST22 Transaction using Short Dump Analysis
ABAP Shared Memory Objects Tutorial with Sample ABAP Code
Add Web Dynpro Applications to SAP Favorites Menu
ABAP Authority-Check Object For User Other Than Current
Call Function Module using RFC Destination in ABAP
Change Fields for Selection in SE11 ABAP Data Browser
Compare Code in ABAP using SE39 SplitScreen Editor
Connect SAP from Eclipse using ABAP Project
Convert Smartform to PDF in Print Preview Mode
Convert the table using the Database Utility (SE14)
Convert Sales Unit into Text using Function Module in Target Language
Create Business Object in SAP
ABAP Code Inspector Check Variants for HANA Migration Optimization
Create SAP Dynamic Variant using Date Calculation
Create Scheduled Job using SAP SM36 Transaction
Create Search Help in ABAP for Web Dynpro Component
Create Transaction Code for Web Dynpro Application
Create SAP Transaction to Maintain ABAP Table using SM30
Create Transport Request for Text Translations using RS_LXE_RECORD_TORDER
Delete All Data from SAP Database Table
Prevent DYNPRO_SEND_IN_BACKGROUND Error in Background Process
How to Execute SAP Program in Background Task
List Locks in SAP system using SM12 Transaction Code
Enable Remote Debugging in ABAP using RSRDEBUG
Export Graphics from SE78 SAP Form Graphics Administration using ABAP program
How to Export IDOC as Excel and Save as Local File from WE02 Transaction
Export SAP Spool Requests as PDF using SP01 Transaction
How to Find SAP Role Users Assigned for Transaction Code
How to Delete Standard Text using SO10 SAP Transaction
How to Find User Exits in ABAP Codes of SAP Transaction
How to Transport SAP Graphics using SE78 Transaction
Import and Export SO10 Standard Text using RSTXSCRP ABAP Program
Business Document Service Error: Error when accessing graphic (BDS), RC = 5
Get SAP Document Flow using SD_DOCUMENT_FLOW_GET ABAP Function Module
SAP Purchase Order Tables, Transaction Codes and Output
Graphics White Background Displayed Grey on SAP Smartform Output
Export Table Contents into Text File and Download File
SE63 Smartform Translation and Export using SLXT Program
Search and Find SAP Transaction Code using SE93 or SEARCH_SAP_MENU
How to Set Start Transaction in SAP GUI
Unicode Character Problem in IFS File Interface
Web Dynpro Text Translation using Assistance Class
Transport Variants of an ABAP Program into Workbench Request
TVAP Item Category and SAP Table TVAPT for Text Translations
Unlock Objects Locked in Request or Task using Transport Organizer Tools
Update Database Table Data using ABAP SE16N_INTERFACE
VF31 SAP Transaction to Reprocess Billing Output Messages
Function module is not released for the Internet


Copyright © 2004 - 2017 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems