12-02-2008 8:46 AM
Hi Guru's
Please Help me out.
Bussiness users want to convert Classic report output to any of the Image format(e.g. Bitmap, jpg. etc.....) and then store in MIME Repository.
Please help me in this .
thanks Arbind
12-03-2008 2:00 PM
Not sure how you would convert the list to an image format, but you can convert to PDF and upload to the mime. Here is an example.
Report program...
REPORT zrich_0002.
DATA : lv_spool LIKE tsp01-rqident.
START- OF -SELECTION .
* Write the report.
DO 20 TIMES .
WRITE 😕 sy- index .
ENDDO .
* Export this spool number to memory
lv_spool = sy-spono.
EXPORT lv_spool = lv_spool TO MEMORY ID 'ZRICH_0002_SPOOL_NUMBER' .
Then you need the driver program which will submit the report program and convert to PDF, then save to Mime.
REPORT zrich_0001.
DATA : lv_spool LIKE tsp01-rqident.
DATA : lt_pdf TYPE TABLE OF tline.
DATA : ls_pdf LIKE LINE OF lt_pdf.
DATA : lv_bytecount TYPE i .
DATA : lv_buffer TYPE string.
DATA : lv_content TYPE xstring.
DATA : lr_mime_rep TYPE REF TO if_mr_api.
DATA : lv_path TYPE string VALUE 'SAP/PUBLIC/yourReport.pdf' . "<<-- Mime path, save to path
START- OF -SELECTION.
* Run the report program, in this program you need to export the
* spool id to memory.
SUBMIT zrich_0002 TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
DESTINATION space
COVER TEXT ' Your Report Title'
NEW LIST IDENTIFICATION 'X'
IMMEDIATELY space
AND RETURN .
* import spool number from memory
IMPORT lv_spool = lv_spool FROM MEMORY ID 'ZRICH_0002_SPOOL_NUMBER' .
* Convert the spool request to PDF format.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool
IMPORTING
pdf_bytecount = lv_bytecount
TABLES
pdf = lt_pdf
EXCEPTIONS
OTHERS = 12 .
* Transfer the 132-long strings to 255-long strings
LOOP AT lt_pdf INTO ls_pdf.
TRANSLATE ls_pdf USING ` ~` .
CONCATENATE lv_buffer ls_pdf INTO lv_buffer.
ENDLOOP .
TRANSLATE lv_buffer USING `~ ` .
* Convert the string to xstring field
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_buffer
IMPORTING
buffer = lv_content
EXCEPTIONS
failed = 1
OTHERS = 2 .
* Get a instance of the API.
lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
* Put the document via path
lr_mime_rep->put(
EXPORTING
i_url = lv_path
i_content = lv_content
I_DEV_PACKAGE = '$TMP' "<< setting this will make it not throw dialog
EXCEPTIONS
parameter_missing = 1
error_occured = 2
cancelled = 3
permission_failure = 4
data_inconsistency = 5
new_loio_already_exists = 6
is_folder = 7
OTHERS = 8 ).
Hope this helps,
Regards,.
Rich Heilman
12-02-2008 9:30 AM
Hi
I think u can save the report in ur destop HTML format using gui_download
Regards
Rasheed
12-03-2008 2:00 PM
Not sure how you would convert the list to an image format, but you can convert to PDF and upload to the mime. Here is an example.
Report program...
REPORT zrich_0002.
DATA : lv_spool LIKE tsp01-rqident.
START- OF -SELECTION .
* Write the report.
DO 20 TIMES .
WRITE 😕 sy- index .
ENDDO .
* Export this spool number to memory
lv_spool = sy-spono.
EXPORT lv_spool = lv_spool TO MEMORY ID 'ZRICH_0002_SPOOL_NUMBER' .
Then you need the driver program which will submit the report program and convert to PDF, then save to Mime.
REPORT zrich_0001.
DATA : lv_spool LIKE tsp01-rqident.
DATA : lt_pdf TYPE TABLE OF tline.
DATA : ls_pdf LIKE LINE OF lt_pdf.
DATA : lv_bytecount TYPE i .
DATA : lv_buffer TYPE string.
DATA : lv_content TYPE xstring.
DATA : lr_mime_rep TYPE REF TO if_mr_api.
DATA : lv_path TYPE string VALUE 'SAP/PUBLIC/yourReport.pdf' . "<<-- Mime path, save to path
START- OF -SELECTION.
* Run the report program, in this program you need to export the
* spool id to memory.
SUBMIT zrich_0002 TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
DESTINATION space
COVER TEXT ' Your Report Title'
NEW LIST IDENTIFICATION 'X'
IMMEDIATELY space
AND RETURN .
* import spool number from memory
IMPORT lv_spool = lv_spool FROM MEMORY ID 'ZRICH_0002_SPOOL_NUMBER' .
* Convert the spool request to PDF format.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spool
IMPORTING
pdf_bytecount = lv_bytecount
TABLES
pdf = lt_pdf
EXCEPTIONS
OTHERS = 12 .
* Transfer the 132-long strings to 255-long strings
LOOP AT lt_pdf INTO ls_pdf.
TRANSLATE ls_pdf USING ` ~` .
CONCATENATE lv_buffer ls_pdf INTO lv_buffer.
ENDLOOP .
TRANSLATE lv_buffer USING `~ ` .
* Convert the string to xstring field
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_buffer
IMPORTING
buffer = lv_content
EXCEPTIONS
failed = 1
OTHERS = 2 .
* Get a instance of the API.
lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
* Put the document via path
lr_mime_rep->put(
EXPORTING
i_url = lv_path
i_content = lv_content
I_DEV_PACKAGE = '$TMP' "<< setting this will make it not throw dialog
EXCEPTIONS
parameter_missing = 1
error_occured = 2
cancelled = 3
permission_failure = 4
data_inconsistency = 5
new_loio_already_exists = 6
is_folder = 7
OTHERS = 8 ).
Hope this helps,
Regards,.
Rich Heilman
12-03-2008 2:39 PM
Now here is an example of how you can display this PDF from the MIME into a container on a screen. For this we will use the HTML control.
REPORT zrich_0003.
DATA: lr_mime_rep TYPE REF TO if_mr_api.
DATA: lv_url TYPE char255.
DATA: lv_content TYPE xstring.
DATA: lv_repid TYPE sy-repid.
DATA: lt_data TYPE STANDARD TABLE OF x255.
DATA: lo_docking TYPE REF TO cl_gui_docking_container.
data: lo_html TYPE REF TO cl_gui_html_viewer.
DATA: p_path TYPE string VALUE 'SAP/PUBLIC/yourReport.pdf'.
PARAMETERS: p_check.
AT SELECTION-SCREEN OUTPUT.
* Create controls
CREATE OBJECT lo_docking
EXPORTING
repid = lv_repid
dynnr = sy-dynnr
side = lo_docking->dock_at_left
extension = 1500.
CREATE OBJECT lo_html
EXPORTING
parent = lo_docking.
lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).
lr_mime_rep->get(
EXPORTING
i_url = p_path
IMPORTING
e_content = lv_content
EXCEPTIONS
not_found = 3 ).
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_content
TABLES
binary_tab = lt_data.
* Load the HTML
lo_html->load_data(
exporting
type = `application`
subtype = `pdf`
IMPORTING
assigned_url = lv_url
CHANGING
data_table = lt_data
EXCEPTIONS
dp_invalid_parameter = 1
dp_error_general = 2
cntl_error = 3
OTHERS = 4 ).
* Show it
lo_html->show_url( url = lv_url in_place = 'X').
Regards,
Rich Heilman