2003 Dec 09 11:21 AM
Hello everybody,
Any idea on how to show a JPEG file from SAP?
What the user wants is to be able to push a button, doubleclick on an icon or such, and get a picture of the product to be ordered. The pictures are stored in a directory on the SAP server. The users will add JPEG files to that directory themselves, respecting a certain naming convention. So there's no telling how many files there will be, and the user can't maintain urls in table WWWPARAMS or such...
2003 Dec 09 6:44 PM
The following is a very simple example that does much of what I think you want to do. It was developed in a 46C system, so I hope you are at the level or higher. Basically it uses the SAP function module, EPS_GET_DIRECTORY_LISTING, to get get a list of files in a particular directory. It then fills this list into a drop down list box on a screen. When the user choses a value in the list box and then press a button, the file is read from the SAP server file system and displayed in a Picture control on the screen. My screen contains a drop down list box named file1, a button with an OKCode of DISP, and a custom container named CUSTOM_CONTAINER. I have removed all error handeling to keep the example small.
REPORT yes_picture_1 .
DATA: dir_name TYPE epsdirnam VALUE '/erp/D10/088/data/'.
TYPE-POOLS: vrm.
DATA: dir_list TYPE TABLE OF epsfili.
DATA: file1(132) TYPE c.
DATA: custom_container TYPE REF TO cl_gui_custom_container.
DATA: picture TYPE REF TO cl_gui_picture.
DATA:
g_list1 TYPE vrm_values, "Liste für Listbox Status
g_value LIKE LINE OF g_list1."einzelne Zeile in Listbox
DATA: okcode TYPE sy-ucomm.
START-OF-SELECTION.
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = dir_name
TABLES
dir_list = dir_list.
CALL SCREEN 100.
*&----
*
*& Module STATUS_0100 OUTPUT
*&----
*
* text
*----
*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
IF g_list1 IS INITIAL.
DATA: wa_dir_list LIKE LINE OF dir_list.
LOOP AT dir_list INTO wa_dir_list.
IF wa_dir_list-name CS 'JPG' OR
wa_dir_list-name CS 'jgp'.
g_value-key = wa_dir_list-name.
g_value-text = wa_dir_list-name.
APPEND g_value TO g_list1.
ENDIF.
ENDLOOP.
****Force the values into the screen
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'FILE1'
values = g_list1.
ENDIF.
IF custom_container IS INITIAL.
CREATE OBJECT custom_container
EXPORTING
container_name = 'CUSTOM_CONTAINER'.
CREATE OBJECT picture
EXPORTING
parent = custom_container.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*&----
*
*& Module USER_COMMAND_0100 INPUT
*&----
*
* text
*----
*
MODULE user_command_0100 INPUT.
DATA: data1 TYPE TABLE OF char255.
DATA: wa_data1(255) TYPE c.
DATA: url TYPE url.
CASE okcode.
WHEN 'EXIT' OR 'BACK' OR 'QUIT'.
LEAVE TO SCREEN 0.
WHEN 'DISP'.
CLEAR url.
clear data1.
clear wa_data1.
DATA: file2(255) TYPE c.
CONCATENATE dir_name
file1
INTO file2.
OPEN DATASET file2 FOR INPUT IN BINARY MODE.
WHILE sy-subrc = 0.
READ DATASET file2 INTO wa_data1.
APPEND wa_data1 TO data1.
ENDWHILE.
CLOSE DATASET file2.
CALL METHOD picture->clear_picture.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'JPG'
TABLES
data = data1
CHANGING
url = url.
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
SCREEN 100 Flow Logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
2003 Dec 10 3:03 PM
Thomas,
Thanks a million.
This does exactly what I needed.
Thanks again,
Ioana
2003 Dec 09 7:09 PM
Hi Ioana,
The normal way would be using attached documents. Also good for any attached file.
You may see an example of using that for adding and dispalying a document in transaction POP2 or MM02.
there is also the option of disply only with :
program = 'SAPLCV140'.
sub_screen = '0204'.
Regards
Noam
2003 Dec 10 3:05 PM
Noam,
Thanks for the info but setting up the document service would also require some customizing and that's exactly what my colleagues don't want to do at this stage...
Ioana