cancel
Showing results for 
Search instead for 
Did you mean: 

Smartforms - Print a Jpg file on form - Is it possible ?

Former Member
0 Kudos

Hello,

I have to create a new form by smartforms... On the first page I have to show a picture (is a file *.jpg stored on a shared dossier).

This file is not imported on sap server.

There's a way to do it ? How ?

Thanks for your reply.

Roberto

Accepted Solutions (1)

Accepted Solutions (1)

former_member196280
Active Contributor
0 Kudos

Convert to BMP( open Jpeg in Paint brush and Save it as BMP- 256 Color Bit Map, if you want a color logo/image) and load using SE78 transaction code.

Call the loaded image inside your smartform.

Regards,

SaiRam

Answers (3)

Answers (3)

former_member1125862
Participant
0 Kudos

Dear Roberto,

Good to see you.

I am facing the same problem in using the JPEG files in SMART FORMS.

I think you solved the problem right.

Can you please share the solution regarding this..

Thanks in advance,

Kruthik..

Former Member
0 Kudos

hii,

how to save it in the MIME.

REPORT zrich_0001.

DATA: lr_mime_rep TYPE REF TO if_mr_api.

DATA: lv_filename TYPE string.

DATA: lv_path TYPE string.

DATA: lv_fullpath TYPE string.

DATA: lv_content TYPE xstring.

DATA: lv_length TYPE i.

DATA: lv_rc TYPE sy-subrc.

DATA: lt_file TYPE filetable.

DATA: ls_file LIKE LINE OF lt_file.

DATA: lt_data TYPE STANDARD TABLE OF x255.

PARAMETERS: p_path TYPE string

DEFAULT 'SAP/PUBLIC/Test.jpg'. "<<-- Mime path, save to path

cl_gui_frontend_services=>file_open_dialog(

CHANGING

file_table = lt_file " Table Holding Selected Files

rc = lv_rc ). " Return Code, Number of Files or -1 If Error Occurred

READ TABLE lt_file INTO ls_file INDEX 1.

IF sy-subrc = 0.

lv_filename = ls_file-filename.

ENDIF.

cl_gui_frontend_services=>gui_upload(

EXPORTING

filename = lv_filename " Name of file

filetype = 'BIN'

IMPORTING

filelength = lv_length " File length

CHANGING

data_tab = lt_data " Transfer table for file contents

EXCEPTIONS

OTHERS = 19 ).

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

input_length = lv_length

  • first_line = 0

  • last_line = 0

IMPORTING

buffer = lv_content

TABLES

binary_tab = lt_data

EXCEPTIONS

failed = 1

OTHERS = 2.

lr_mime_rep = cl_mime_repository_api=>if_mr_api~get_api( ).

lr_mime_rep->put(

EXPORTING

i_url = p_path

i_content = lv_content

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 ).

And when you are ready to show the image in a picture control on a screen. You can do something like this. This uses a docking container so that you don't have to create a screen, but it works the same way with a customer container.

REPORT zrich_0001.

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_picture TYPE REF TO cl_gui_picture.

DATA: p_path TYPE string VALUE 'SAP/PUBLIC/Test.jpg'.

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 = 200.

CREATE OBJECT lo_picture

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.

CALL FUNCTION 'DP_CREATE_URL'

EXPORTING

type = 'IMAGE'

subtype = 'JPG'

TABLES

data = lt_data

CHANGING

url = lv_url.

lo_picture->load_picture_from_url_async( lv_url ).

regards,

Sri.

Former Member
0 Kudos

Hello Sridhar Vukanti

tks for reply.

When I run the first report... the system ask me for a transport order... to save the image on MIME.

So... it's seam not the best for an automatic program... ?!?!?!?!

Former Member
0 Kudos

Hi Roberto,

Did you get the solution for your issue?if yes could you please share.I am facing the same problem now.

Thanks,

Vara.

Former Member
0 Kudos

hii,

1)se78 for uploading the image in .bmp.

2)use rstxldmc program to convert.

regards,

Sri.

Former Member
0 Kudos

Hello,

I don't want upload the file on sap server (se78) !!!

Maybe a solution is :

by bapi or module fonction:

1°. upload the image on se78 (I mean upload the file on sap server )

2°. print document

3°. delete image on sap server....

What do you think ? There's a Bapi or MF to do it ?

Tks for your reply

Roberto