For displaying an image/logo in Web Dynpro application, usually a MIME object is created where a image is uploaded from a legacy.
But what if an image or logo is stored in document server (Transaction SE78) or what if the image is required to be fetched from R3??
In simple words this article will help in displaying an image from SE78 transaction to the Web Dynpro application.
The 6 steps in the whole process are described below. Code mentioned in step 2-5 needs to be provided in WDDOINIT method of view.
1. Create a Web dynpro component ZTEST1.
Create a view FIRST_VIEW for a Web Dynpro component. Insert a image element 'IMAGE' in view layout.
Create an attribute IMAGE_URL of type STRING in view context.
Assign the above created attribute to the SOURCE property of IMAGE element
Create a window ZTEST1 for Web Dynpro component and drag the view inside the window.
Also create an application 'ZTEST1' for a Web Dynpro component.
2. Get the Binary contents of image/logo from BDS (Business document store). Go to the WDDOINIT method of view and call the below Function module for getting the binary contents of a image. I am calling this FM for a specific image. To make it a dynamic call, select query on table STXBITMAPS is required. Thus it can help in deciding the image at run time. For black & White images pass 'BMON' in parameter I_BTYPE (graphic type) and for color images pass 'BCOL' in parameter I_BTYPE. Data: i_name TYPE STXBITMAPS-TDNAME value 'ZLOGOTEST', 3. Convert the binary contents into BITMAP format. BITMAP format is file format for digital images. So a conversion from BDS to BMP is required. Call the below FM after the code in step 2. Data: l_length TYPE i, 4. Convert BITMAP to Byte stream (XSTRING). Now table L_CONTENT contains the required data of image. But to link it with the Image element, we need to convert the Bitmap data into XSTRING format. Below source code can be used for it. This custom logic is picked up from FM SCMS_BINARY_TO_XSTRING and is modified according to needs. Data: w_file TYPE xstring, 5. Generate a URL which will be linked with Image UI element. After step 4, we have image data (xstring) in W_FILE parameter. Now a URL needs to be generated which image UI element will point to. DATA:url TYPE string, 6. Set the above generated URL in Image UI element's source property. In step1, we have created a Context attribute named IMAGE_URL which is linked to Image element's Source property. In this step, we will set the value (url created in above step) in this attribute. DATA lo_el_context TYPE REF TO if_wd_context_element. Now activate the Web Dynpro component and test the application to see output. | |
No comments:
Post a Comment