cancel
Showing results for 
Search instead for 
Did you mean: 

uploading and displaying image

Former Member
0 Kudos

Hi Experts,

I am very new to web dynpro ABAP. I am trying to learn how to upload image and display that image in the same page.

I searched in SDN threads, and find this steps to upload and displaying in a web page.

*********

You can use fileUpload and file download Uielements

Follow these steps:

1. Create a node 'FILEUPLOAD' with 2 attributes

a) FILECONTENT type XSTRING

b) FILENAME type STRING

2. create a node 'FILEDOWNLOAD' with 1 attribute

a) DOWNLOAD type XSTRING

3. Goto the layout tab

a) Place a fileupload uielement and a button next to it for uploading the image

b) Bind the Data property with the attribute 'FILECONTENT' and filename property with the attribute 'FILENAME'

c) Place a filedownload uielement on the layout

d) Bind the data property of thr filedownload uielement with the attribute 'DOWNLOAD'

4.Create create an action for the button, the Event 'onAction'.

5. In this method write the following code to read the content and set the download attribute

data: l_node type ref to if_wd_context_node.

data: l_content type xstring.

l_node = wd_context->get_child_node( ' FILEUPLOAD' ).

l_node->get_attribute( exporting name = 'FILECONTENT'

importing value = l_content ). " l_content will be your image in xstring format

data: l_node1 type ref to if_wd_context_node.

l_node1->wd_context->get_child_node( ' FILEDOWNLOAD' ).

l_node1->set_attribute( exporting name = 'DOWNLOAD'

value = l_content ) . " retrieved frm above

*************

I followed above steps , But am getting empty page while deploying.

I didn't import image into MIME objects.

Can anyone Help me.

Thanks in Advance!

Regards,

Sreelakshmi.

Edited by: sreelakshmi.B on Jul 1, 2009 4:34 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sreelakshmi,

you dont need to import image in MIME repository.

Jusk check if the data property of both the fileupload and filedownload uielement are bound with attribute of type XSTRING and also chexk if you have implemented the Action method for the button.

Check my replies in this [;

Radhika.

Former Member
0 Kudos

Hi Radhika,

Thanks for your fast reply.

I entered both Data properties of datatype XSTRING only.

I am getting error at

 l_node1->wd_context->get_child_node( ' FILEDOWNLOAD' ). 

The error is "wd_context->get_child_node( ' FILEDOWNLOAD' ). is unknown. It is neither in one of the specified table nor defined by a "DATA" statement... "

I don't know why this error coming!

I followed the same steps in my first thread.

Can you please solve this problem.

Thanks!

Regards,

Sreelakshmi.

Former Member
0 Kudos

Hi,

This syntax is not correct. Replace '->' with '=' as below.

l_node1 = wd_context->get_child_node( ' FILEDOWNLOAD' ).

Regards,

Manne.

Former Member
0 Kudos

l_node should be a returning parameter.

l_node = wd_context->get_child_node( 'NODENAME' ).

Radhika.

Former Member
0 Kudos

Hi,

Thanks for your fast replay.

That error is solved now.

My application is deployed successfully, But after clicking the upload button, i am getting this error....

" Lower-Level Node with Name MAIN_VIEW. FILEDOWNLOAD Does Not Exist ".

But i created FILEDOWNLOAD node in the view context. I am not getting why this is coming?

Can you please help me to solve this problem.

Thanks!

Regards,

Sreelakshmi.

Former Member
0 Kudos

Hi Sreelakshmi,

Actually you dont need a separate node for filedownload in this scenario.

Just bind the same attribute that you have bound to the Fileupload uielement's data property and implement the Action method for the button and keep it blank. no coding..

This approach will reduce your coding to zero and you can escape frm creating an extra attribute as well

Radhika.

Former Member
0 Kudos

if you are getting the above error check if you have spelled your node name correctly in the below line.

Check for spaces left by mistake if any. for eg ' FILEDOWNLOAD' ( space before F ) will give an error it should be 'FILEDOWNLOAD'

l_node = wd_context->get_child_node( 'FILEDOWNLOAD' ).

Radhika.

Former Member
0 Kudos

Hi Radhika,

Thanks for your valuable replies.

I changed my component according to ur advice.

That error is solved ...

But after clicking the button it is displaying empty page , it doesnot showing image.

whether we have to insert "IMAGE " UI Element into the view?

What to do to solve this problem.

Thanks !

Regards,

Sreelakshmi.

Former Member
0 Kudos

Once you browse and select an image, click on the button and then check if you can view the image.

Have you used the same attribute for binding the data property of fileupload and filedownload uielement ?

Have you create a button to uplaod the image and implemented the actionmethod for it ?

Radhika.

Former Member
0 Kudos

Hi Radhika,

I mapped the same context element "FILECONTENT" of type XSTRING for both UI Element's DATA property.

And i created the button and action for it.

Is there any keypoints to check?

thanks!

Regards,

Sreelakshmi.

Former Member
0 Kudos

just make sure that you are binding the Data property of the Filedownload, that could be the only possible problem.

I hope you have not written any code in the Action method to set the attribute etc.

This approach is wrking fine for me...

Radhika.

Former Member
0 Kudos

Check if you have followed these steps;

1.create a node 'FILEUPLOAD' with 2 attributes

a) FILECONTENT type XSTRING

b) FILENAME type STRING

2. Create a uielemet fileuplaod

a) bind the data property with attribute 'FILECONTENT'

b) bind the filename property with attribute 'FILENAME'

3. Create a button 'UPLOAD'

a) create the action method for this button with no coding inside

4. Create a filedownload uielement

a) bind the data property with the attribute 'FILECONTENT' used above for fileupload

Radhika.

Former Member
0 Kudos

Hi radhika,

I checked number of times. I followed the same steps which you have mentioned.

I didn't written any code in onAction method of Button.

And i mapped the same context to both UI Element's DATA property.

But i am not getting the image still.

Can you Please Help me.

Is there any method for uploading image and displaying it!

Thanks for ur continueous replies!

Regards,

Sreelakshmi.

Former Member
0 Kudos

ok..do one thing, place this code in the button action. now place a breakpoint and check the value in ls_stru.

check if ls_stru-filecontent has any value ?

Data l_node type ref to if_wd_context_node.
Data l_stru type wd_this->elements_cn_fileupload.

l_node = wd_context->get_child_node( 'FILEUPLOAD' ).
l_node->get_static_attributes( importing static_attributes = l_stru ).

Radhika.

Former Member
0 Kudos

Hi Radhika,

I read the context of FILECONTENT attribute by placing break point.

It stores the value like this "FFD8FFE000104A46494600010201006000600000FFE........etc.." of type XSTRING.

Thanks!

Redards,

Sreelakshmi.

Former Member
0 Kudos

Thanks! Radhika,

Its working know....

Thanks for ur replies!

Regards,

Sreelakshmi.

Answers (0)