cancel
Showing results for 
Search instead for 
Did you mean: 

Can mime object be created at run-time?

Former Member
0 Kudos

Hi Expert,

Can mime object be created at run-time in Web Dynpro?

If I use such code, will it has any authority problem?

lv_url = '/SAP/BC/WebDynpro/SAP/ZENHANCE_IA/test1.jpg'.

lo_mine_rep = cl_mime_repository_api=>get_api( ).

lo_mine_rep->put(

EXPORTING

i_url = lv_url

i_content = lv_file_string ).

Thanks for your reply!

Best Regards,

Derek

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You should also consider that objects in the MIME repository are development objects. When creation occurs, they are inserted into transport requests like any other development object type. Therefore you could hit authorization as well as system settings and transport workflow problems.

Perhaps you should describe a little more what you are trying to acomplish. If you just want to store images as transactional data, you can store them in any customer created table as an XSTRING field. That is often advisable for storage directly in production systems particularly if the volumes will be high.

Former Member
0 Kudos

Hi Mr. Chinnu and Mr. Jung,

Yes, I want to store the image as transaction data, and I will store the image in customer created table as XString field.

I want to display the image in Formatted-Text-Edit/Formatted-Text-View,

Formatted-Text-Edit/View can only display the image in such tag:

<img src="/SAP/BC/WebDynpro/.../test.jpg />

So I mannually create a mime object(test.jpg) in my web dynpro component.

Every time user insert a image file into Formatted-text-edit/view,

I store the content of the image file in the mime object, at the same time, I insert a line "<img src="/sap/.../test.jpg />" into Formatted-Text-Edit/View, thus the image file can be displayed in Formatted-Text-Edit/View.

but actually user can simultaneously insert arbitary number(5 or 10) of image file into formatted-text-edit/view,

what can I do then? create 5 or 10 mime object firstly?

Can you give me some suggestions? Thanks a lot.

Best Regards,

Derek

Former Member
0 Kudos

Hello Derek Zhao,

How are the users going to insert the image? I think it is must that users should upload file to get its XSTRING form.

If the user is going to upload the file using file upload UI element, you can get the XSTRING form of the mime object.

Below links can help you with File upload ui element and an example.

[WebDynpro ABAP File upload UI Element|http://help.sap.com/saphelp_nw70/helpdata/en/b3/be7941601b1d09e10000000a155106/frameset.htm]

[WebDynpro ABAP File Upload example|http://wiki.sdn.sap.com/wiki/display/WDABAP/FileUploadusingcl_fitv_gosclass]

Also, you can find examples of this interface element in the system in the Web Dynpro application WDR_TEST_UI_ELEMENTS, and in the component WDR_TEST_EVENTS in the View FileUpload.

If user is going to upload more than one file,e very time user uploads a file, save the information into a context node with cardinality 0..n

Best regards,

Chinnu

Former Member
0 Kudos

Hi Mr. Chinnu,

Thanks for your reply.

I know the XString content of an image file can be get through File-Upload UI element.

But when I display the image file in Formatted-Text-Edit/View, I should give the image file a URL, such as:

<img src="/SAP/Public/BC/.../test.jpg />, only this case, the image can be displayed in Formatted-Text-Edit/View.

In order to assign the image file with a URL, I have to use mime object.

The question is: I couldn't create mime object at run-time in Web Dynpro.

In case user upload several image files, I have to display these image files in one Formatted-Text-View.

I have to use the same number mime object as the image file that user upload.

Can you and other expert give me some solutions?

Many thanks in advance.

Best Regards,

Derek

Former Member
0 Kudos

Hi Derek,

Can you try this code to get the URL. Got this from another forum.


DATA:url TYPE string,
guid TYPE guid_32,
cached_response TYPE REF TO if_http_response.

CREATE OBJECT cached_response
TYPE
cl_http_response
EXPORTING
add_c_msg = 1.

* set image to mime
cached_response->set_data( w_file ).
cached_response->set_header_field( 
name = if_http_header_fields=>content_type 
value = 'image/pjpeg' ).

cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 
180 ).

CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.

cl_wd_utilities=>construct_wd_url( EXPORTING
application_name = 'ZTEST1' "Webdynpro application name
IMPORTING out_local_url = url ).

CONCATENATE url '/' guid sy-uzeit INTO url.
cl_http_server=>server_cache_upload(
url = url 
response = cached_response ). 

w_file should contain the xtring of the uploaded file.

Best regards,

Chinnu

Former Member
0 Kudos

Hi Mr. Chinnu,

Thank you very much.

Your answer resolve my question.

Best Regards,

Derek

Former Member
0 Kudos

welcome

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

I have a kin of same requirement.

i have got the URL. but it is not giving me the data like an image.

It is giving a .dll file.

CAn you please help me in that

Thanks,

Akriti

Former Member
0 Kudos

You definitely will have problem.

Say, the mime repository is protected, and user executing the application does not have required access level on the mime repository. Also, another mime with same name exists in the mime repository (name conflict) and user should have permission on the object to replace...

But, can you tell me the scenario that demands creation of mime from WD application... I came across file uploads but not on mime creations. Just for info sake.

Best regards,

Chinnu

Former Member
0 Kudos

Hi Chinnu,

Thanks for your reply, below is my scenario:

Can you give me some suggesion?

Best Regards,

Derek