cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload images on WebDynpro(ABAP) screens

Former Member
0 Kudos

Hello All,

Could any one please help on how to create/change the image (jpeg/any file) dynamically on WebDynpro screen. I have seen couple of examples for uploading the text files in WDR_TEST_EVENTS, WDR_TEST_WEB_ICONS, but not found any standard program that explains about uploading images.

Requirement: User has to select any image/thumbnail from local PC and it should be displayed on main screen, it's not only from MIME directory.

We have the same logic in BSP Application (CFX_RFC_UI) to upload the thumbnail but am not sure whether we can use the same logic in WDC or not?

I have seen the same logic for WebDynpro (JAVA) here:

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

I would really appreciate if you could provide me the code/process ASAP.

Thanks & Regards,

Hari.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

follow-up.

Former Member
0 Kudos

I meet the same as problem with you. I ask some expert from SAP. They tell me to give up this thinking. You put the files into the server file system so that the server file system isn't assurance the file to be safe. So I have to change my idear. I put the file to the mime type repository to display it in the main page.

Former Member
0 Kudos

Hi,

Use FileUpload, give the MimeType as GIF or JPEG. You will get the image as XSTRING, in the attribute of the Node, the data property of FIleUpload is bound to....

You then have to convert XTRING back to image... I foulf following sample code...

try it....

graphic_table is the table with field XSTRING and contains the Image uploaded in XSTRING format

DATA:h_picture TYPE REF TO cl_gui_picture,

h_pic_container TYPE REF TO cl_gui_custom_container.

DATA: graphic_url(255),

graphic_refresh(1),

g_result LIKE cntl_true.

DATA: BEGIN OF graphic_table OCCURS 0,

line(255) TYPE x,

END OF graphic_table.

DATA: graphic_size TYPE i.

CALL FUNCTION 'DP_CREATE_URL'

EXPORTING

type = 'image'

subtype = cndp_sap_tab_unknown " 'X-UNKNOWN'

size = graphic_size

lifetime = cndp_lifetime_transaction "'T'

TABLES

data = graphic_table

CHANGING

url = graphic_url.

CREATE OBJECT h_pic_container

EXPORTING container_name = 'LOGO'.

CREATE OBJECT h_picture EXPORTING parent = h_pic_container.

CALL METHOD h_picture->load_picture_from_url

EXPORTING

url = graphic_url

IMPORTING

RESULT = g_result.

Former Member
0 Kudos

Thanks a lot for all your help, I will apply this way and let you know.

Regards,

Hari.

Former Member
0 Kudos

Hi,

I have written the code as per given logic with no errors, after selecting jpeg file from local PC when I click on 'upload' button it is giving a following short dump.

Could you please let me know how to rectify it.

Error when processing your request

What has happened?

The URL http://rocpld02.wwwint.corp:8000/sap/bc/webdynpro/sap/zms_image_01/ was not called due to an error.

Note

The following error text was processed in the system PLD : Exception condition "CNTL_ERROR" raised.

The error occurred on the application server rocpld02_PLD_00 and in the work process 1 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: CONSTRUCTOR of program CL_GUI_CUSTOM_CONTAINER=======CP

Method: ONACTIONONBUTTONCLICK of program /1BCWDY/1I6RRYQYFWRI2HBZ5MAK==CP

Method: IF_WDR_VIEW_DELEGATE~WD_INVOKE_EVENT_HANDLER of program /1BCWDY/1I6RRYQYFWRI2HBZ5MAK==CP

Method: INVOKE_EVENTHANDLER of program CL_WDR_DELEGATING_VIEW========CP

Method: IF_WDR_ACTION~FIRE of program CL_WDR_ACTION=================CP

Method: DO_HANDLE_ACTION_EVENT of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP

Method: EXECUTE of program CL_WDR_MAIN_TASK==============CP

Method: IF_HTTP_EXTENSION~HANDLE_REQUEST of program CL_WDR_MAIN_TASK==============CP

Regards,

Hari.

Former Member
0 Kudos

Hari,

Are u getting the image as XSTRING in the attribute that is bound to data property of FileUpload.

What Mime type did you give ?

For JPEG image , pls confirm from somewhere that Mime type is JPEG. I am not sure on that.

Try 'image/jpeg' as the mimeType

Thanks

Former Member
0 Kudos

Hi Anand,

I have not found any data type as JPEG/IMAGE so that I have just given STRING as MIME TYPE. I am not taking any global variables in context COMPONENT CONTROLLER is that ok??.

Pls find the below details which I have given for Upload UI element:

Binding details:

data: main_view.upload -> upload TYPE XSTRING

filename: main_view.filename -> filename TYPE STRING

mimetype: main_view.mimetype -> mimetype TYPE STRING

If you have any sample code or document related to image upload then please send it to me. This is very urgent work and a big challenging also.

My persnoal mail : kadirahari@gmail.com

Thanks & Regards,

Hari.

Former Member
0 Kudos

Hari,

There is no MIMETYPE String. What I meant was you type image/jpeg in the mimeType property box of FileUpload

Create a Node in the context of Component Controller, NOdeA. Create a attibute 'image' for this node of type XSTRING. Bind NodeA to the data property of FileUpload.

When you upload the image it will be available as XSTRING in the attribute 'image'. Read this attribute and populate the tablefor feeding the function module 'DP_CREATE_URL'.

data image_As_Xstring type XSTRING.

data NodeA type ref to IF_WD_CONTEXT_NODE.

NodeA = wd_Context->get_child_node( 'NodeA' ).

NodeA->GET_ATTRIBUTE(

NAME = 'IMAGE'

VALUE = image_As_Xstring ).

image_As_Xstring should be passed to the internal table graphic_table , that feeds the FM 'DP_CREATE_URL'.

See what happens.

I don't think anyone has done this type of thing before, so it will be a trial and error....

Thanks

Anand

Former Member
0 Kudos

Hi Anand,

We don't have clear documentation for image upload, that is the main problem here.

As per your logic I have done the coding but it is failing in the custom container creation, I went into the debug mode and found the error type as 3.

CREATE OBJECT h_pic_container

EXPORTING

container_name = 'LOGO'

EXCEPTIONS cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

IF sy-subrc <> 0.

EXIT.

ENDIF.

Do I need to create any seperate window/view for this image??

Regards,

Hari.

Former Member
0 Kudos

Yaa it crashed when I did it inside the WD Component

But it was ok when I ran in a SE38 program.

SO I tried to put the logic in external assistance class and call it from the WD component method...crashed there 2...

Damn!!!!! I guess Web does not support GUI Container

Have to search another way to doing.

Former Member
0 Kudos

Hi Anand,

Can't we use static container (UI element) which is already placed in the layout to put the picture with image URL. Because when we are trying to create custom contatiner dynamically it is not working.

Regards,

Hari.

Former Member
0 Kudos

Hari

The question is once u get the image in XSTRING format, how to convert it back to a URL that has the image ?

So if we create a Image UI element and after getitng the URL from DP_URL_CREATE, give this URL to the Source property of the Image...then it might work.. ?

So put a image UI element on screen and the source property of it bind to a attribute of type STRING.

call DP_URL_CREATE module and the URL u get back , put it in the attribute bound to the source property of the image ...

What do u say ? Worth a try !!!!!!

Former Member
0 Kudos

Hi Arun,

I tried this way also... but still not working. I really wonder why SAP has not given any demo/documentation for this requirement. It is given only how to upload image from MIME repository but in my case user wants to pick any image from local PC.

Anyways thanks for your help and immediate response.

Regards,

Hari.

Former Member
0 Kudos

Hi Anand,

Thanks for your help.

Regards,

Hari.

Former Member
0 Kudos

You still have to use the File_Upload UI element. This element has a property MimeType. Find out the MimeType for a Image and bind a attribute of this value to the MimeType attribute.

I think uploading a image is smae as uploading any other file using File_Upload UI element. Only thing is you have to specify the MimeType for Images.