cancel
Showing results for 
Search instead for 
Did you mean: 

how to open a word docu on click of a button

Former Member
0 Kudos

Hi,

I need to open a word document on clicking of a button which contains some information.

In the same way,on clicking of another button i need to provide options to the users to select one of the 3 or 4 attached documents can be ppt, word, excel etc..

how to achieve this?

Regards,

Lakshmi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

->To open a file on the click of button you can place the file in Mime Repository(Right click on your component ->Create ->Import ->Browse the file and it will be plaed in Mime )

Now you can retrieve the file on the click of Button using the following code :

data:

mime_repository type ref to if_mr_api,

content type xstring,

mime_type type string,

url type string value 'SAP/BC/BSP/SAP/myBSPapplication/yourfile.jpg'.

mime_repository = cl_mime_repository_api=>get_api( ).

call method mime_repository->get

exporting

i_url = url

importing

e_content = content.

e_mime_type = mime_type.

Now you have that file in the Content.

Finally You can bind the Content with Attribute of File Download UI.

This way you can have different Files kept in Mime and on the click of button you can give user different FileDownload links to choose the file from.

Former Member
0 Kudos

Hi,

Thanks for your quick reply.

My requirement here is i need to open a word document which contains some data.that means the document contains content also.

how to do this?

Regards,

Lakshmi.

Former Member
0 Kudos

hi,

You can upload any file with content into Mime and from there you can access those files.

ok, your document has content. Is your document stored in Dekstop or you are putting content in doc at runtime also ?

thanx.

Former Member
0 Kudos

Hi Lakshmi,

You can use OfficeControl UiElement.

Check this link [OfficeControl|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/d1/af8841349e1909e10000000a155106/content.htm]

Regards,

Radhika.

Former Member
0 Kudos

Hi All,

i have placed a word document with some data in MIME repository.

now i want to open this document on clicking of a button.

for this i followed these steps.

1) i imported a file called Feedback.doc into MIME

2) i placed a button on the view.

3) on action event handler of button i wrote the following code.

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

EXPORTING

i_filename = 'C:\Documents and Settings\s8rxcn\Desktop\Feedback.doc'

i_content = content

i_mime_type = 'MS_WORD'.

here what is content... how to get the document with content?

Regards,

Lakshmi.

Former Member
0 Kudos

Content is your file/document in XSTRING format.

Regards,

Radhika.

Former Member
0 Kudos

Hi ,

how do i convert content to xstring. here i am not trying to upload or download the file contents.

i want to open up a word document ( or file ) which has some data,on clicking of a button.

Regards,

Lakshmi.

Former Member
0 Kudos

hi,

->Here Content is the Attribute of Type XString which is having your File now.

->Now you can use FileDownload UI Element. Bind the Data Property with this Attribute Content.

->Change the Text of FileDownload UI to what ever text you want.

-> Finally a Link will appear to the User and On the Click this link , you will get your File(whether doc or .ppt. )

Thanx.

Chaitanya_Priya
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lakshmi,

For the requirement yoy have asked please follow the below steps..

1.You need to get the MIME object ref and then get the content of that MIME object.

2.Open the file with this content on click of the button.

DATA : mime_repository TYPE REF TO if_mr_api,

content TYPE xstring,

url TYPE string ,

lv_fnam TYPE string..

DATA: l_component TYPE REF TO if_wd_component,

l_component_info TYPE REF TO if_wd_rr_component,

l_name TYPE string.

lv_fnam = wd_assist->if_wd_component_assistance~get_text( 'MIM' ).

l_component = wd_this->wd_get_api( ).

l_component_info = l_component->get_component_info( ).

l_name = l_component_info->get_name( ).

mime_repository = cl_mime_repository_api=>get_api( ).

CALL METHOD cl_wd_utilities=>construct_wd_url( EXPORTING application_name = l_name

IMPORTING out_local_url = url ).

CONCATENATE url '/' lv_fnam INTO url.

CALL METHOD mime_repository->get

EXPORTING

i_url = url

i_check_authority = ' '

IMPORTING

e_content = content

EXCEPTIONS

parameter_missing = 1

error_occured = 2

not_found = 3

permission_failure = 4

OTHERS = 5

.

cl_wd_runtime_services=>attach_file_to_response(

EXPORTING

i_filename = lv_file_name

i_content = lv_xfile

i_mime_type = 'APPLICATION/MSWORD').

Regards,

Priya

Answers (0)