Quantcast
Channel: Web Dynpro ABAP
Viewing all 141 articles
Browse latest View live

Web Dynpro ABAP POWER Lists - Beyond Queries

$
0
0

'Professional Seminars @ SAP' is a new offering by SAP Switzerland with the goal of expert knowledge transfer compressed to short sessions.

 

On December 4th and 5th 2012, I will be covering some advanced topics around Web Dynpro ABAP POWER Lists (also known as POWL). It will take place at the SAP Switzerland offices in Regensdorf near Zurich.

 

This won't be the usual class room event as you know it, but rather a discussion and transfer of knowledge and work experience gained during customer projects over the years of implementing and dealing with POWER lists.

 

Your questions and ideas for discussion are also highly welcome and time is considered to cover them.  

 

As of today, some seats are still available. In case you are interested, more info and the sign-up procedures can be found here.

 

 

Check also this link for an upcoming event in November which is offered by two SAP Mentors,  Greg Myers and Eric Vallo, aiming the BI4 platform.

 

Hope to see you there!


HTML5 islands: How to integrate HTML5 into your Web Dynpro ABAP applications

$
0
0

Summary

 

With Netweaver 7.31 SP5, the Web Dynpro UI elements HTMLIsland, HTMLContainer and HTMLFragment have been introduced. They allow you to embed custom HTML5, JavaScript and CSS sources into your Web Dynpro ABAP applications. Using these new UI elements for HTML5 integration, you can create exciting UIs!

    

Are you ready for an island trip? In this blog post, we will visit some of the use cases of the new UI elements and point out some information sources that will guide you through the process of building an application with an HTMLIsland. 

 

HTML5 integration scenarios

 

You want to build an application containing a Web Dynpro Table but you want to make it look a bit more eye-catching by adding a background image? Then you should use the new HTMLContainer! It allows you to place HTML5 fragments around existing Web Dynpro UI elements. HTML5 is produced on server side and it is possible to re-render it with each server roundtrip, which is useful for decorating or enhancing existing Web Dynpro UI elements.  Your decorated Web Dynpro Table may look like this:

 

pic.jpg

 

 

To illustrate the possibilities offered by HTMLIsland and HTMLContainer a bit further, let’s have a look at an employee data maintenance scenario.You want to allow the user to switch between different views showing employee data. Here the HTMLIsland comes into play: you can use it to embed an org chart to visualize employee relations. The HTMLIsland UI element has rich client side functionality. HTML5 is produced on client side and it can survive round-trips without getting rendered each time. This makes it perfectly suitable for embedding interactive, stateful content into Web Dynpro ABAP applications. To create a Web Dynpro ABAP application with an embedded chart, you need to integrate an HTMLIsland UI element, add references to JavaScript sources and CSS sources to it and model a data connection using the Web Dynpro context. The result may look as follows:

 

Presentation2.gif

 

Information sources

 

If you want to know more about what is possible with the new UI elements for HTML5 integration, you should have a look at the Web Dynpro HTMLIsland & HTMLContainer Developer Guideline.  You can find detailed architectural information along with a step-by-step description of how you built an application containing HTMLIsland from scratch.

 

For more information on the restrictions when working with HTMLIslands and HTMLContainers, see SAP Note 1742528 and SAP Note 1753544.

 

For Help Portal documentation, see SAP Online Help - HTMLIntegration.

 

** TEAM FPM ** - How to use a Java Script Chart Library in Floorplan Manager Applications

Change Logo on Address Bar for WD Appl

$
0
0

Go to Tcode : SE80

  Select MIME Repository

Step1.JPG

 

Select favicon.ico. The path is SAP > PUBLIC > BC > UR > Login > assests.step2.JPG

 

 

Change the icon by Right Click favicon.ico and select Upload and Replace  from Upload/Download dropdown

 

Step3.JPG

 

Then select the image from local disk

 

Step4.JPG

 

Save the properties

 

Step5.JPG

Now if you restart the application. The URL address bar image will be the image you have uploaded. Thus we successfully changed the Logo in Address bar.

Using captcha in ABAP Webdynpro

$
0
0

In this blog I will give a simple example on how to use a captcha in ABAP Webdynpro.

 

Architecture

We generate a simple string in ABAP and send it to a servlet on a J2EE server. This servlet generates an image with SimpleCaptcha. http://simplecaptcha.sourceforge.net/ . The generated images is received on the ABAP stack and copied to a cached response so the captchastring is not in the url of the image.

The source of the java application can be downloaded here. (tested on SAP NW 7.31 SP5)

 

Captcha Servlet

This is a simple servlet application that generates a captcha image from a given string.

 

1.       Download the simplecaptcha library

2.       Create an external library DC and name it captcha/lib

3.       Add the simplecaptcha jar-file to the libraries folder

4.       Add the jar-files to the public part of the library

5.       Create a new web module development component and name it captcha

6.       Add a DC dependency between the web module and the library

7.       Add a new servlet and give it a name and package

8.       Copy the simplecaptcha.jar to the WEB-INF/lib directory

9.       Enter the following code:

 

package com.flexso.captcha;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.flexso.captcha.noise.CustomNoiseProducer;

import nl.captcha.Captcha;
import nl.captcha.servlet.CaptchaServletUtil;

import java.awt.Color;
import java.awt.Font;

public class CaptchaImage extends HttpServlet {
          private static final long serialVersionUID = 1L;            private static int _width = 180;            private static int _height = 60;            private static final List<Color> COLORS = new ArrayList<Color>(2);            private static final List<Font> FONTS = new ArrayList<Font>(3);             static {                        COLORS.add(Color.BLACK);                        COLORS.add(Color.BLUE);                        FONTS.add(new Font("Geneva", 2, 48));                        FONTS.add(new Font("Courier", 1, 48));                        FONTS.add(new Font("Arial", 1, 48));                      }    public CaptchaImage() {        super();    }          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {                    response.setContentType("image/png");                    response.setCharacterEncoding("UTF-8");                    String word = request.getParameter("captcha");                    WordGenerator wordRenderer = new WordGenerator(word);                    Captcha captcha = new Captcha.Builder(_width, _height).addText(wordRenderer)                .gimp()                .addNoise())                .build();              CaptchaServletUtil.writeImage(response, captcha.getImage());          }

}

 

10.   Add a class WordGenerator to be able to decide which word will be used to generate the captcha image.

 

package com.flexso.captcha;
import nl.captcha.text.producer.TextProducer;

public class WordGenerator implements TextProducer
{
  private String text = "";  public WordGenerator(String text){            this.text = text;  }  public String getText(){    return this.text;  }
}

 

11.   Adapt the web.xml

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  <display-name>LocalDevelopment~captcha~flexso.com</display-name>  <servlet>    <description></description>    <display-name>CaptchaImage</display-name>    <servlet-name>CaptchaImage</servlet-name>    <servlet-class>com.flexso.captcha.CaptchaImage</servlet-class>  </servlet>  <servlet-mapping>    <servlet-name>CaptchaImage</servlet-name>    <url-pattern>/captcha.png</url-pattern>  </servlet-mapping></web-app>

12.   Create an enterprise application DC with the name captcha/ear

13.   Add the web module to the captcha/ear project

14.   Adapt the application.xml

<?xml version="1.0" encoding="ASCII"?><application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5">  <display-name>LocalDevelopment~captcha~ear~flexso.com</display-name>  <module>    <web>      <web-uri>flexso.com~captcha.war</web-uri>      <context-root>captcha</context-root>    </web>  </module></application>

 

15.   Deploy the ear file.

16.   Test the captcha http://<portalserver>:<port>/captcha/captcha.png?captcha=test

 

captcha.png

 

ABAP Webdynpro application

In the ABAP WD application we build a random string to send to the captcha application.

We request the captcha image  on the ABAP server and provide it in a cached response to our webdynpro application to hide the captcha string in the url.

 

1.       Create a new web dynpro component

2.       In the component controller create a context node CAPTCHA with 3 strings: SOURCE, ANSWER, IMAGE.

 

context.png

 

3.       Create method generate_captcha in the component controller. In this method we create a random string, with this string we build the url to the J2EE server to generate the captcha image. At the end of the method we copy the image from the java server to a cached response on the ABAP stack and then we fill the context. This is the code:

 

method GENERATE_CAPTCHA .  CONSTANTS: CO_ALFABET type CHAR30 VALUE 'abcdefghijklmnopqrstuvwxyz'.  DATA: lv_captcha type CHAR08,        lv_i   type i,        lv_char type CHAR01,        lv_seed type i,        lo_ran type ref to cl_abap_random_int,        lv_url type string,        lv_length type i value 8.

*   generate a random string with length lv_length  lv_seed = sy-timlo.  lv_i = STRLEN( co_alfabet ) - 1.  lo_ran = cl_abap_random_int=>create( min = 0 max = lv_i seed = lv_seed ).  DO lv_length TIMES.    lv_i = lo_ran->get_next( ).    lv_char = CO_ALFABET+lv_i(1).    lv_i = lo_ran->get_next( ).    if lv_i MOD 2 = 0 .      TRANSLATE lv_char TO UPPER CASE.    endif.    CONCATENATE lv_captcha lv_char into lv_captcha.  ENDDO.
*   build url to generate captcha image  CONCATENATE '/captcha/captcha.png?captcha=' lv_captcha into lv_url.  lv_url = wd_this->GET_CACHED_URL( lv_url ).  " Set data in context  DATA lo_nd_captcha TYPE REF TO if_wd_context_node.  DATA lo_el_captcha TYPE REF TO if_wd_context_element.  DATA ls_captcha TYPE wd_this->Element_captcha.  lo_nd_captcha = wd_context->get_child_node( name = wd_this->wdctx_captcha ).  lo_el_captcha = lo_nd_captcha->get_element( ).  lo_el_captcha->set_attribute( name =  `SOURCE` value = lv_captcha ).  lo_el_captcha->set_attribute( name =  `IMAGE` value = lv_url ).

endmethod.

 

4.       To copy the image from the JAVA response to the ABAP response I created a separate method GET_CACHED_URL. Importing parameter IV_URL (STRING) and returning parameter OV_URL(STRING)

 

method GET_CACHED_URL .  DATA : lo_http_client TYPE REF TO if_http_client,         lo_cached_response TYPE REF TO IF_HTTP_RESPONSE,         lv_image TYPE xstring,         lv_guid TYPE GUID_32.  " read the image on the java server  CALL METHOD cl_http_client=>create_by_url    EXPORTING      url    = 'http://<javaserver>:<port>'    IMPORTING      client = lo_http_client    EXCEPTIONS      OTHERS = 1.  CALL METHOD lo_http_client->request->set_header_field    EXPORTING      name  = '~request_uri'      value = iv_url.  CALL METHOD lo_http_client->send    EXCEPTIONS      http_communication_failure = 1      http_invalid_state         = 2      http_processing_failed     = 3.  CALL METHOD lo_http_client->receive    EXCEPTIONS      http_communication_failure = 1      http_invalid_state         = 2      http_processing_failed     = 3.  lv_image = lo_http_client->response->get_data( ).  " send the image to the cached response on the ABAP server  CREATE OBJECT lo_cached_response TYPE CL_HTTP_RESPONSE EXPORTING ADD_C_MSG = 1.  " SET IMAGE TO MIME  lo_cached_response->SET_DATA( lv_image ).  lo_cached_response->SET_HEADER_FIELD( NAME = IF_HTTP_HEADER_FIELDS=>CONTENT_TYPE VALUE = 'image/png' ).  lo_cached_response->SET_STATUS( CODE = 200 REASON = 'OK' ).  lo_cached_response->SERVER_CACHE_EXPIRE_REL( EXPIRES_REL = 100 ).  " generate an url  CALL FUNCTION 'GUID_CREATE'    IMPORTING      EV_GUID_32 = lv_guid.  CL_WD_UTILITIES=>CONSTRUCT_WD_URL( EXPORTING  APPLICATION_NAME = 'Z_CAPTCHA' "WEBDYNPRO APPLICATION NAME  IMPORTING OUT_LOCAL_URL = OV_URL ).  CONCATENATE OV_URL '/' lv_guid sy-uzeit '.png' INTO OV_URL.  CL_HTTP_SERVER=>SERVER_CACHE_UPLOAD( URL = OV_URL RESPONSE = lo_CACHED_RESPONSE ).


endmethod.

 

5.       Open the view of the webdynpro

6.       In the context tab, bind the CAPTCHA node from the componentcontroller.

 

context2.png

 

7.       In the layout tab add following elements to the view:

     a.       An image and bind the source property to attribute IMAGE af the CAPTCHA node.

     b.      An input field and bind the property value to attribute ANSWER of the CAPTCHA node.

     c.       A button ‘check captcha’ and assign an action CHECK

     d.      A button refresh and assign an action REFRESH

 

8.       Implement the 2 actionhandlers

 

method ONACTIONCHECK.    DATA lo_nd_captcha TYPE REF TO if_wd_context_node.    DATA lo_el_captcha TYPE REF TO if_wd_context_element.    DATA ls_captcha TYPE wd_this->Element_captcha.
*     get message manager    data lo_api_controller     type ref to if_wd_controller.    data lo_message_manager    type ref to if_wd_message_manager.    data: lv_Str type string,          lv_text type string,          lv_type type I.    " read context    lo_nd_captcha = wd_context->get_child_node( name = wd_this->wdctx_captcha ).    lo_el_captcha = lo_nd_captcha->get_element( ).    lo_el_captcha->get_static_attributes( IMPORTING static_attributes = ls_captcha ).    " get message manager    lo_api_controller ?= wd_This->Wd_Get_Api( ).    CALL METHOD lo_api_controller->GET_MESSAGE_MANAGER      RECEIVING        MESSAGE_MANAGER = lo_message_manager        .    lv_type = IF_WD_MESSAGE_MANAGER=>CO_TYPE_ERROR.    lv_text = 'ERROR!'.    TRANSLATE LS_CAPTCHA-SOURCE TO UPPER CASE.    TRANSLATE LS_CAPTCHA-ANSWER TO UPPER CASE.
"   compare captcha answer with the source    if LS_CAPTCHA-SOURCE = LS_CAPTCHA-ANSWER.      lv_type = IF_WD_MESSAGE_MANAGER=>CO_TYPE_STANDARD.      lv_text = 'OK!'.    endif.

*     report message    CALL METHOD lo_message_manager->REPORT_MESSAGE      EXPORTING        MESSAGE_TEXT              = lv_text        MESSAGE_TYPE              = lv_type      RECEIVING        MESSAGE_ID                = lv_str        .


endmethod.




method ONACTIONREFRESH .
  WD_COMP_CONTROLLER->GENERATE_CAPTCHA( ).
endmethod.

 

Create a web dynpro application object and test the application!

Result:

 

result.png

How to display GOS PDF document from Webdynpro

$
0
0

Dear All; One of the way to display the GOS PDF document via Webdynpro; hope this will help; Step1: Select the list of attachments from the business document using function module BDS_ALL_CONNECTIONS_GET; for this you need the following inputs; Classname, Classtype and objkey Step2: Convert the file ID (loio_id from the above function module) to xstring using the method “attachment_get_detail” from the class “cl_hap_wd_document_ui” Data:     lv_aid  type bds_docid,     lv_fcon  type string,     lv_fchex type xstring,     lv_mftyp type string,     lv_ret  type bapiret2. attachment_get_detail(       exporting         attachment_id    = lv_aid         attachment_type  = 'pdf'       importing         file_content    = lv_fcon         file_content_hex = lv_fchex         mime_file_type  = lv_mftyp         s_return        = lv_ret                           ). Step3: Display the document in new browser; using the method attach_file_to_response from class cl_wd_runtime_services; data:     l_file    type string,     l_mime    type string,     pdf_data  type xstring. l_mime = 'application/pdf' . l_file = 'title.pdf' . call method cl_wd_runtime_services=>attach_file_to_response     exporting       i_filename  = l_file       i_content  = lv_fchex       i_mime_type = l_mime.

Navigation from one component view to other componet view without adding Used Components

$
0
0

This blog explains how to navigate from one component view to other component view without adding Used Components.

 

Scenario: Source component contains View with LinkToAction UI element, on click of this Link navigates to Destination component View without adding Used Component in the Source Component.This is can be achieved using Dynamic Navigation by following interface: IF_WD_NAVIGATION_SERVICES and method: do_dynamic_navigation.

 

Prerequisites: Should have basic knowledge on Web Dynpro ABAP

 

Create Two Web Dynpro Component by following

 

Destination Component :

 

Create Web Dynpro with View and Window. 

Insert Caption UI Element in the View.

1.png

 

Embed the View into Window.Activate whole component.

2.png

 

Source Component :

 

Create Web Dynpro with View and Window. See below there is no Used Component,

3.png

 

Insert LinkToAction UI Element in the View and Create Action write the below code assign this action to LinkToAction UI Element.

3.1.png

 

Code:

 

  data : lv_view_api type ref to if_wd_view_controller,
         lv_nav_serv type  ref to if_wd_navigation_services.

  lv_view_api = wd_this->wd_get_api( ).
  lv_nav_serv  ?= lv_view_api.

lv_nav_serv->do_dynamic_navigation(
     source_window_name        = 'W_COMP2'
     source_vusage_name        = 'V_COMP2_USAGE_1'
     source_plug_name          = 'DEFAULT'
*     PLUG_PARAMETERS           = PLUG_PARAMETERS
     target_component_name     = 'ZTEST_COMP1'
     target_component_usage    = 'ZTEST_COMP1'
     target_view_name          = 'W_COMP1'
     target_plug_name          = 'DEFAULT'
*     TARGET_EMBEDDING_POSITION = TARGET_EMBEDDING_POSITION
        ).

 

5.png

 

Embed this View into Window. Activate whole component.

6.png

 

Create the Webdynpro Application by following

 

7.png

 

Demo : Select the above application Right click and Test. When you clicks on below link it navigates to Destination Components View.

 

8.png

 

9.png

Call the other component from ur component

$
0
0

Create one webdynpro component in se80 like below screen shot

 

1w.PNG

then create one button in your view controller layout->for that button create one custom action.

then click on that action write the following code.

 

9.PNG

DATA LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER.

DATA LO_API_COMPONENT  TYPE REF TO IF_WD_COMPONENT.

DATA LO_WINDOW         TYPE REF TO IF_WD_WINDOW.

data lv_str type string .

 

 

LO_API_COMPONENT  = WD_COMP_CONTROLLER->WD_GET_API( ).

LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).

 

CALL METHOD CL_WD_UTILITIES=>CONSTRUCT_WD_URL

   EXPORTING

     APPLICATION_NAME              = 'ZWD_TRAINING_FEEDBACK'

   IMPORTING

     OUT_ABSOLUTE_URL              = lv_str.

 

In the above screen shot mention your webdynpro component name and defined variable name to hold the component url.

4.PNG

CALL METHOD LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW

     EXPORTING

       URL            = lv_str

       MODAL          = ABAP_true

       HAS_MENUBAR    = ABAP_TRUE

       IS_RESIZABLE   = ABAP_TRUE

       HAS_SCROLLBARS = ABAP_TRUE

       HAS_STATUSBAR  = ABAP_TRUE

       HAS_TOOLBAR    = ABAP_TRUE

       HAS_LOCATION   = ABAP_TRUE

     RECEIVING

       WINDOW         = LO_WINDOW

       .

 

LO_WINDOW->OPEN( ).

 

In the above screen shot call external popup window and also pass the  component url.

then right on your webdynpro component->webdynpro application.

save, active and test your application it will call the other component.

Admin Personalization, Component Customization and Code Free Enhancements of your SAP Standard WDA application – How To? (1)

$
0
0

So you want to adapt/change your SAP standard Web Dynpro ABAP (WDA) application but you’d like to avoid using code enhancements if possible. One way to achive this is Administrator Personalization and in this blog I'll explain and give examples of this. In section (2) of this blog (to be created...) I'll explain a couple of other ways to perform code free changes to WDA applications namely Component Customization and Enhancements.

 

The list of options is not exhaustive and the recommendations are my personal opinions and not necessarily based on SAP recommendations.

 

 

1. Admin Personalization (Application Customization)

If you want to perform small changes like hiding an input field, changing a label, rearranging a table column or field then this is the way to go. If you come from a Web Dynpro Java background the options at your hand using this technique are very similar to the old "ctrl+right click" technique.

 

To get started log on to your development system and simply locate the Web Dynpro application in SE80 or SE84. Now you might want to take a copy of the SAP standard application to perform the customization on so that you keep a clean SAP version. I would recommend taking a copy but up to you and your companies policies. If you chose to customize directly on the standard application your changes will not be lost during an upgrade and you can always go back and check which elements where changed and reset the changes (I will show that towards the bottom of this blog).

 

You now need to execute the application using "shift+F8" or "Web dynpro application->Test-> In browser - admin mode".

You can also do the same from your development portal by executing the iview in preview mode (but I have not tested this out in the portal so can't say if you get prompts for transports etc?).

 

Then locate the UI object you wish to change, right click it and chose "Settings for current configuration". Below I've given a couple of examples and hints:

  • If you clicked on a table column you will be able to rearrange it and Add/Remove columns

Capture.JPG

  • If you click on an input field you can change text, make it invisble, add a tooltip and even mark it as mandatory using the state property
    • NOTE: If you mark a field as mandatory it simply gives you a * indicator on the field and you need to ensure that a check for mandatory attributes has or is also implemented for example using cl_wd_dynamic_tool=>check_mandatory_attr_on_view( view_controller = l_view_controller display_messages = abap_true ).

Capture.JPG

  • If you want to rearrange the input fields you have to click on the container element for example "Grouping of UI Elements" as shown below. You then press the Re-Sort link and you will be able to move them Up and Down.

Capture.JPG

 

 

When your done and click the "Save and Close" button in the bottom right hand corner you will be prompted to save your changes in a customization transport. As a result you only need to do this on your development system/client - nice!

 

Remember this customization is done on the application NOT the application configuration which means:

a) The admin personalization of the application will be available on all the application configurations associated with it

b) You can perform admin personalization even if the application doesn't have a configuration

 

If you want to check which parts of an application has been customized select the drop down option "Personalized Elements" and you will get a list of customized elements and be able to reset them to standard.

Capture.JPG

 

So this is one way to achieve the described changes. In section 2 of this blog (to be done) I'll explain a couple of other options.

 

NOTE: In a lot of SAP standard applications it is also possible to achieve similar things in IMG customizing so ask your functional IMG expert first.

 

Here are some useful links:

End User and Administrator Personalization (SAP Library - Web Dynpro for ABAP)

   

Personalization and Customizing - Web Dynpro ABAP Configuration Framework - SAP Library

 

And even though this document is written for FPM it has a brilliant section regarding adaptation options that some of the way are also applicable for standard WDA applications: 

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c0a2b7c2-1598-2e10-45bc-c556df3b9576?QuickLink=index&overridelayout=true&51591147228485

 

Best Regards, Jan


How to display GOS PDF document from Webdynpro

$
0
0

Dear All;

One of the way to display the GOS PDF document via Webdynpro; hope this will help; 

 

Step1: Select the list of attachments from the business document using function module BDS_ALL_CONNECTIONS_GET; for this you need the following inputs; Classname, Classtype and objkey.

 

Step2: Convert the file ID (loio_id from the above function module) to xstring using the method “attachment_get_detail” from the class “cl_hap_wd_document_ui” 

 

Data:
lv_aid  type bds_docid,    
lv_fcon  type string,    
lv_fchex type xstring,    
lv_mftyp type string,    
lv_ret  type bapiret2.

 

attachment_get_detail
  (exporting       
     attachment_id    = lv_aid        
     attachment_type  = 'pdf'      
   importing        
     file_content     = lv_fcon        
     file_content_hex = lv_fchex        
     mime_file_type   = lv_mftyp        
     s_return         = lv_ret ). 

 

Step3: Display the document in new browser; using the method attach_file_to_response from class cl_wd_runtime_services;


data:    
l_file    type string,    
l_mime    type string,    
pdf_data  type xstring.

l_mime = 'application/pdf' .
l_file = 'title.pdf' . 

 

call method
  cl_wd_runtime_services=>attach_file_to_response    
     exporting      
        i_filename  = l_file      
        i_content  = lv_fchex      
        i_mime_type = l_mime.

Method invocation queue

$
0
0

Popups in Webdynpro for ABAP are annoying

Recently I had the pleasure to show one of these "Are you sure?" popups in the UI. The issue with popups in webdynpro is, due to the web based architecture, the fact that there is no real synchronous program flow as we were used to in SAP GUI.

Instead of stopping the program flow when a popup is shown, the Webdynpro runtime continues in order to fulfill the HTTP web request.

This means, instead of receiving the result of the user's decision right after the popup call, we usually need to implement callback methods which are called when the user presses either "Ok", "No" and so on.

In the sample this would be the view's method ONACTIONAPPLY_CONFIRM.

 

DATA lo_comp_api TYPE REF TO if_wd_component.
DATA lo_controller_api TYPE REF TO if_wd_controller.
DATA ls_config TYPE wdr_popup_to_confirm.
DATA: lt_text_table TYPE string_table,          lv_text_table TYPE string,          lv_title TYPE string.
ls_config-button_cancel-enabled = abap_false.
lo_controller_api = wd_this->wd_get_api( ).
lo_comp_api = wd_comp_controller->wd_get_api( ).
lv_title = 'Are you sure?'.
lv_text_table = 'Really???'.
APPEND lv_text_table TO lt_text_table.

TRY.
          CALL METHOD cl_wd_popup_factory=>popup_to_confirm          EXPORTING            component        = lo_comp_api            text             = lt_text_table            window_title     = lv_title            configuration    = ls_config          RECEIVING            popup_to_confirm = wd_this->mo_popup.        wd_this->mo_popup->subscribe_to_events(          controller = lo_controller_api          handler_name = 'ONACTIONAPPLY_CONFIRM' ).

*retrieve backend call parameters
DATA lv_p1 TYPE i.
DATA lv_p2 TYPE string.
*...retrieve parameters
*store backend call parameters in the view's attributes
wd_this->mv_p1 = lv_p1.
wd_this->mv_p2 = lv_p2.

 

Did you recognize line 29 - 34? Actually, what is done here is the preparation of the backend call which is to be executed depending on the user's decision. The method parameters are already stored in some attributes and read for later purpose.

In the callback method, the backend invocation might look like the code below.

METHOD ONACTIONAPPLY_CONFIRM.  CHECK wd_this->mo_popup->answer = if_wd_popup_to_confirm=>co_button_1_pressed.  wd_this->mo_some_weird_backend->perform_some_weird_operation( iv_p1 = wd_this->mv_p1 iv_p2 = wd_this->mv_p2 )
ENDMETHOD.

 

Every parameter that will conditionally passed to the backend will have to be stored somewhere.

You do this kind of work one time, maybe two times or three times and you are going to be annoyed at it.

Couldn't this behaviour be achieved easier and more conventiently?

 

What is a method invocation queue?

A method invocation queue records method calls for later execution. Instead of storing parameters for later usage, you will store the objects and their method calls including parameters for later usage. As ABAP still lacks function pointers we will need to implement it manually.

Compare the above shown coding, starting at line 29 with this one.

*retrieve backend call parameters and record backend calls
DATA lv_p1 TYPE i.
DATA lv_p2 TYPE string.
*...retrieve parameters
wd_this->mo_method_queue = zcl_method_queue=>new_method_invocation( ).
wd_this->mo_method_queue->with( wd_this->mo_some_weird_backend )->on( 'perform_some_weird_operation' ).
wd_this->mo_method_queue->add_parameter( iv_name = 'iv_p1' iv_value = lv_p1 ).
wd_this->mo_method_queue->add_parameter( iv_name = 'iv_p2' iv_value = lv_p2 ).

Looks more complicated at the beginning. But the big advantage of this concept is, that you will now only have to keep track of the method invocation queue, not method parameters. No further attributes are required.

Actually, using the fluent API, you could write lines 6 to 8 in just one single line.

 

The popup's callback method now looks like this.

METHOD ONACTIONAPPLY_CONFIRM.  CHECK wd_this->mo_popup->answer = if_wd_popup_to_confirm=>co_button_1_pressed.  wd_this->mo_method_queue->flush( ).
ENDMETHOD.

 

Interested?

So here is the coding. Please be aware, this is just experimental and not meant for productive usage.

This code lacks the support of any other parameter type than IMPORTING parameters as well as proper exception handling. However you may consider to enhance it and write about what you found out ;-)

CLASS zcl_method_queue DEFINITION   PUBLIC   FINAL   CREATE PROTECTED .   PUBLIC SECTION.     TYPE-POOLS abap .     CLASS-METHODS new_method_invocation       RETURNING         value(ro_method_queue) TYPE REF TO zcl_method_queue .     METHODS with       IMPORTING         !io_caller TYPE REF TO object       RETURNING         value(ro_method_queue) TYPE REF TO zcl_method_queue .     METHODS on       IMPORTING         !iv_method TYPE seocpdname       RETURNING         value(ro_method_queue) TYPE REF TO zcl_method_queue .     METHODS add_parameter       IMPORTING         !iv_name TYPE abap_parmname         value(iv_value) TYPE any       RETURNING         value(ro_method_queue) TYPE REF TO zcl_method_queue .     METHODS finalize .     METHODS flush       RAISING         zcx_method_queue .   PROTECTED SECTION.     TYPES:       BEGIN OF ty_s_method_invocation,         caller TYPE REF TO  object,         method TYPE  seocpdname,         parameters TYPE  abap_parmbind_tab,       END OF ty_s_method_invocation .     DATA ms_method_invocation TYPE ty_s_method_invocation .     DATA:       mt_method_invocations TYPE TABLE OF ty_s_method_invocation .     METHODS copy_value       IMPORTING         !ir_ref TYPE REF TO data       RETURNING         value(rr_ref) TYPE REF TO data .     METHODS constructor .   PRIVATE SECTION.
 ENDCLASS.

 CLASS ZCL_METHOD_QUEUE IMPLEMENTATION.
   METHOD add_parameter.     ro_method_queue = me.     DATA ls_parameter TYPE abap_parmbind.     DATA lr_value TYPE REF TO data.     ls_parameter-name = iv_name.     TRANSLATE ls_parameter-name TO UPPER CASE.     ls_parameter-kind = cl_abap_objectdescr=>exporting.     GET REFERENCE OF iv_value INTO lr_value.     ls_parameter-value = copy_value( lr_value ).     INSERT ls_parameter INTO TABLE ms_method_invocation-parameters.   ENDMETHOD.                    "add_parameter   METHOD constructor.   ENDMETHOD.                    "CONSTRUCTOR   METHOD copy_value.     FIELD-SYMBOLS <lv_in> TYPE any.     FIELD-SYMBOLS <lv_out> TYPE any.     ASSIGN ir_ref->* TO <lv_in>.     CREATE DATA rr_ref LIKE <lv_in>.     ASSIGN rr_ref->* TO <lv_out>.     <lv_out> = <lv_in>.   ENDMETHOD.   METHOD finalize.     CHECK: ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL.     APPEND ms_method_invocation TO mt_method_invocations.     CLEAR: ms_method_invocation.   ENDMETHOD.   METHOD flush.     FIELD-SYMBOLS <ls_call> TYPE ty_s_method_invocation.     DATA lo_cx_root TYPE REF TO cx_root.     DATA lo_objectdescr TYPE REF TO cl_abap_classdescr.     DATA lo_cx_sy_dyn_call_illegal_meth TYPE REF TO cx_sy_dyn_call_illegal_method.     DATA ls_method TYPE abap_methdescr.     DATA lv_has_method_been_called TYPE abap_bool.     DATA lv_count TYPE i.     DATA lt_method_parts TYPE string_table.     DATA lv_method_name TYPE string.     finalize( ).     LOOP AT mt_method_invocations ASSIGNING <ls_call>.       TRY.           CALL METHOD <ls_call>-caller->(<ls_call>-method) PARAMETER-TABLE <ls_call>-parameters.         CATCH cx_sy_dyn_call_illegal_method INTO lo_cx_sy_dyn_call_illegal_meth.
 *         no such method - try to call named method in any interface that the current object might implement           lv_has_method_been_called = abap_false.           lo_objectdescr ?= cl_abap_classdescr=>describe_by_object_ref( <ls_call>-caller ).           LOOP AT lo_objectdescr->methods INTO ls_method.             TRY.                 lv_method_name = ls_method-name.                 SPLIT lv_method_name AT '~' INTO TABLE lt_method_parts.                 FIND <ls_call>-method IN TABLE lt_method_parts MATCH COUNT lv_count.                 IF lv_count > 0.                   CALL METHOD <ls_call>-caller->(ls_method-name) PARAMETER-TABLE <ls_call>-parameters.                   lv_has_method_been_called = abap_true.                   EXIT.                 ENDIF.               CATCH cx_root INTO lo_cx_root.                 CONTINUE.             ENDTRY.           ENDLOOP.

 *         has method been found?           IF lv_has_method_been_called = abap_false.             RAISE EXCEPTION TYPE zcx_method_queue               EXPORTING                 previous = lo_cx_root                 method   = <ls_call>-method.           ENDIF.         CATCH cx_root INTO lo_cx_root.           RAISE EXCEPTION TYPE zcx_method_queue             EXPORTING               previous = lo_cx_root               method   = <ls_call>-method.       ENDTRY.     ENDLOOP.   ENDMETHOD.                    "flush   METHOD new_method_invocation.     CREATE OBJECT ro_method_queue.   ENDMETHOD.                    "new_method_invocation   METHOD on.     ro_method_queue = me.     ms_method_invocation-method = iv_method.     TRANSLATE ms_method_invocation-method TO UPPER CASE.   ENDMETHOD.                    "on   METHOD with.     ro_method_queue = me.     IF ms_method_invocation-caller IS NOT INITIAL AND ms_method_invocation-method IS NOT INITIAL.       finalize( ).     ENDIF.     ms_method_invocation-caller = io_caller.   ENDMETHOD.                    "with
 ENDCLASS.

 

Drawbacks of this approach

However, there's no such thing as a free lunch.

If you decide to use such a method invocation queue, you lose the where-used-list support of your backend's methods.

Also, you can only access real backend methods and not component controller methods, as they are accesssible for their views or windows, but not for any other objects, unless these methods are declared public.

 

So stay careful, be watchful and enjoy...

Read selected values from table in webdynpro ABAP

$
0
0

Step to read the selected data from the table in webdynpro abap.

1. Create a method for the table in the property onselect  ( like get_data ) . Please find the screen shot below .

method.png

2. Declare the internal table and work area for the attribute to fetch which is selected.

3. Give the reference to the table which you want to have use method get_selected_elements for the node which is declared above to fetch the data .

4. Loop the selected elements and extrat the exact data which is present in the selected instance .

 

Sample code

 

  DATA :   lt_sel_elem       TYPE wdr_context_element_set.
  FIELD-SYMBOLS <ls_sel_elem> TYPE REF TO if_wd_context_element.

 

  DATA lo_nd_n_result TYPE REF TO if_wd_context_node.

 

  DATA ls_n_result TYPE wd_this->element_n_result.
  DATA lt_n_result TYPE wd_this->elements_n_result.

 

*   navigate from <CONTEXT> to <N_RESULT> via lead selection
  lo_nd_n_result = wd_context->get_child_node( name = wd_this->wdctx_n_result ).

 

*   @TODO handle non existant child
*   IF lo_nd_n_result IS INITIAL.
*   ENDIF.

 


  CALL METHOD lo_nd_n_result->get_selected_elements
    RECEIVING
      set = lt_sel_elem.

 

**fetching selected entries
  LOOP AT lt_sel_elem ASSIGNING <ls_sel_elem> .
    CALL METHOD <ls_sel_elem>->get_static_attributes
      IMPORTING
        static_attributes = ls_n_result.
    APPEND ls_n_result TO lt_n_result .
  ENDLOOP.

Calling of different component from select option F4 and using the value which are selected in different component

$
0
0

Steps of calling of different component from select option F4 and using the value which are selected in different component

1.     Create a component ZTEST. This component will have our select option . Also make component usage of WDR_SELECT_OPTIONS  in the used components. In our example we have made GC_SELECT1 .

 

1.png

2. Go to main view . Make a components add the component usage from step 1 ( which is created in component controller )

 

2.png

 

3. Create a viewContainer  UI element in your MAIN view.

 

3.png

4. Add the WND_SELECTION_SCREEN view in the viewContainer  UI element . Go to MAIN window , expand the window and in the viewContainer  UI element right click and embed .

 

5. Code in DOINIT method of view  to create select option with a m_value_help_id  = ‘GC_SELECT1 which is created as a used component.

6. Go to WDR_SELECT_OPTIONS component . Click on enhancement . add the component which you wants to add which should be called at the click of select option .

 

4.png

 

7. Once added when you click on select option F4 the component added in WDR_SELECT_OPTIONS is called .

 

6.png

 

8 . What ever value are entered can be passed back to the select option from where it is called .

Edit Web Dynpro ABAP themes in ABAP in Eclipse

$
0
0

We have published a survey (link) to check with Web Dynpro ABAP community, if they want a more modern and productive development environment for Web Dynpro ABAP applications development.

The results were quite positive and ABAP in Eclipse is going in the direction to provide support for Web Dynpro ABAP applications development.

 

ABAP in Eclipse 2.0 is just out as trial. Refer to blog to check how to download it: SCN Trial: ABAP Development Tools 2.0

 

ABAP in Eclipse doesn't come bundled with Theme editor.Theme editor is available as standalone delivery which you can use to edit Web Dynpro Themes.

What about having Theme Editor installed within ABAP in Eclipse IDE !!!

One of the main objectives of ABAP in Eclipse was to bring all development scenario's into one IDE. Using eclipse as a base it is enabled automatically.

 

Execute following steps to install Theme Editor in ABAP in Eclipse:

  1. Open the link Theme Editor download link
  2. Download "Eclipse PlugIn" from the list of available downloads
  3. Install ABAP in Eclipse. Follow the blog to check exact steps: Enabling ABAP in Eclipse
  4. Open ABAP in Eclipse.
  5. Go to Help->Instal New Software and choose Add option.
  6. Choose "Archive" option and select the zip file downloaded from step 2.
  7. Follow the wizard. ABAP in Eclipse will be restarted

And you have Theme editor installed in ABAP in Eclipse. Now, you can do your ABAP development and also edit Web Dynpro ABAP themes using same IDE.

Refer to the document (Link) to know more about theme editor:

Raising the event from one view and handling the same event in another view .

$
0
0

Please find the list of step need to perform to achieve the handling of event from source view to target view .

 

Step 1 . Identify the source view from where the event will be triggered.

 

Step 2 . Identify the target view where the event should be handled.

 

Step 3 . Register the listener name, handle name , controller and event name in the targeted view .

               ·         Listener name – name of the view where even will be handled.

               ·        Handler name – the method in the target view which will handle the event raised in source view

               ·         Controller name – Name of the component controller used.

               ·         Event name – Name of the event which is raised.

1.png

Sample code for target view written in DOINIT method .

 

DATA: lo_componentcontroller     TYPE REF TO ig_componentcontroller,

          lo_api_componentcontroller TYPE REF TO if_wd_component.

 

       lo_api_componentcontroller->add_event_handler(

        listener_name    = 'V_MAIN'

        handler_name     = 'OK_HANDLE_MAIN'

        controller_name  = 'COMPONENTCONTROLLER'

        event_name       = 'OK_CLICKED_MAIN' ).

 

Step 4 .  you want the target view to handle the source view event just raise the event which is declared in component controller like below :

wd_comp_controller->fire_ok_clicked_main_evt( ) .

1.png

 

 

Resultant :  Now  once the ok_clicked_main event is raised from source view , the same event can be handled in the target view method OK_HANDLE_MAIN . You can perform any action/population in this method .

Difference among component configuration, application configration and controller configuration?

$
0
0

Hi,

can any one  provide clarity on these plz

 

 

 

 

Thanks

Aashish


Corbu Theme for WebDynpro ABAP

$
0
0

Below are the highlights of the new SAP Corbu theme for Web Dynpro ABAP.

 

Highlights of the new SAP Corbu theme for Web Dynpro ABAP:

  • A new modern, simple looking theme with improved overall look;
    • Neutral design with light panes and flat surfaces
    • Reduced contrasts & gradients create a light and clear user interface
    • Color: Reduced use of neutral and dimmed colors increases the compatibility with other SAP designss
    • Structure: Less structuring and separating elements to support a flat and lightweight appearance
    • Correct Prioritization: Visual focus is on the content, instead of on navigation and functions
    • Tables & Containers: Reduced colors and line contrast creates a less block-like appearance
  • Increased font sizes to improve readability
    • Readability: Enlarged and easier to read typography, for example, larger font
  • Enhanced look for specific controls
    • new panel stack visualizations
    • new calendar design
  • Large set of new icons and pictograms that are modernized with new theme without affecting existing icons in older themes -
    • new icon style with 16 x16 pixel size icons
    • All icons referenced as ~Icon/* are automatically replaced, based on the used theme.
    • Icons from the old icon library, referenced as ICON_* or @nn@ are not automatically replaced.

 

Prerequisite

SAP Corbu theme is available for the following support packs:

  • NW 731 SP02
  • the new theme is delivered with further optimizations in NW 731 SP03 and SP04

 

How To Apply Corbu Theme to Web Dynpro for ABAP application

To apply or activate the newly-delivered SAP CORBU theme you have to simply append the URL parameter &sap-theme=sap_corbu to your application

(otherwise by default Wedynpro for ABAP applications use the SAP Tradeshow Plus theme. )

 

 

Development Effort Required

the Corbu theme works for all WD ABAP applications out of the box with no additional development effort.

Please perform visual verification of UIs to ensure no truncation of texts or misalignment occurs due to increased font sizes and line height


Direct and Reverse mapping

$
0
0
Direct MappingReverse Mapping
Please refer to picture 6.26.Please refer to picture 6.28.
Component: Component:
   Y_EM_CONTEXT :   Y_EM_CONTEXT_RM :
      1.  get records from Database      1.  get records from Database
      2. doesn't contain any view      2. a view to embed interface view
      3. define a node STUDENT with attribute                            3. define usage of component Y_EM_LAYOUT_RM
          Interface Node:  Yes (can access by other component)      4. define a InterfaceController_usage, mapping Student to that of  Y_EM_LAYOUT_RM.         
          Input Element:    NO (can't Input by other comp. )      5. In WDDOINIT, append some records to  Node STUDENT.
      4. In WDDOINIT, append some records to  Node STUDENT.   Y_EM_LAYOUT_RM:
   Y_EM_LAYOUT:      1. show records  in a table
      1.  show records in a table      2. define a node STUDENT with attribute                     
      2. define usage of  component Y_EM_CONTEXT           Interface Node:  Yes (can access by other component)
      3. mapping the two STUDENT from Y_EM_CONTEXT and Y_EM_LAYOUT in tab  context.                   Input Element:    Yes ( Input by Y_EM_CONTEXT_RM)

EXTERNAL_MAPPING.gif

NOT or NOT Web dynpro ABAP?

$
0
0

Weird question isn't it ? The main purpose of this article is not to discuss about Web Dynpro ABAP but just to show you how to use NOT pattern in your context binding

 

Let me show you with an example: when you use boolean attributes, often we want to have the opposite value depending on how you think : isActivated or isDisable ?

 

Static option

The easiest way to do this NOT operation is using the wizard when you bind context attribute to graphical element property. On the bottom of the wizard you will appear an option called : INVERT. Select it and that's it !

 

Thus, each TRUE value will be FALSE for the property element, and each FALSE will be TRUE for that element.

 

Dynamic option

Now, how to do the same thing but in dynamic context, such as in ALV element?

 

The key of the problem is: ":NOT"

 

Here is an easy example in ALV context to add button and bind the enabled property to the context and invert the value.

 

CREATE OBJECT lo_button.
lo_button->set_enabled_fieldname( 'ALV_MD__SAVED_ACTION:NOT' ).

 

Conclusion

It is easy to use the NOT operator in the context binding so do not hesitate to use it. I would like to thanks a friend of my Guillaume G. who ask me the question and bring me the ALV example.

 

Enjoy

Automation of "All measuring points on object" in transaction IK22 through WDA

$
0
0

HI All,

 

Here i have a requirement for Automation of 'All measuring point on object" in transaction IK22, through WDA....

 

I am executing the standard transaction through URL in webdynpro abap.. In transaction IK22 i am able to skip the first screen  but could not able to trigger button 'All measuring point on object" automatically in second screen.

 

Kindly let me know how to trigger the above button automatically.

 

Thanks in advance!

how to raise a popup window with out using create_window method

$
0
0

can any one plz explain how to raise a pop up window with out using CREATE_WINDOW method of interface IF_WD_WINDOW_MANAGER ,

My requirement is i have to crate three buttons for ex button 1, button 2, button 3 in main view .when i click on the button 1 a pop up window should be raised . similarly for the remaining but here i must use the window which is created by default with webdynpro component.

Viewing all 141 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>