Saturday, October 27, 2012

SAP ABAP Webdynpro Frequently Asked Questions and answers

Questions
1) What is ABAP Webdynpro
2) What is Floorplan Manager(FPM) and its usage in webdynpro
3) How to close popup window in webdynpro ABAP
4) How to display formatted text in webdynpro ABAP
5) How to control the visibility of webdynpro UI elements
6) Controlling message area height in webdynpro ABAP
7) Coding business logic in assistance class of webdynpro component
8) Webdynpro trace tool and its usage
9) ICM Tracing for webdynpro Application
10)F4 help for inputfields in webdynpro abap
11)Messages in webdynpro abap application
********************************************************************
ABAP Webdynpro
Webdynpro ABAP is the SAP UI technology for building Web based UI's using the programming
language ABAP/ABAP OO. ABAP Webdynpro Components and Design tools can be accessed

using the ABAP workbench transaction SE80.

Advantages of ABAP Webdynpro:
->Webdynpro programming model uses MVC(Model View controller)
  design paradigm.
  -->MVC
->Clear separation between the flow logic and the business logic.
  ->Here the flow logic is written in the views,windows,components and the business
    logic is mostly written in Assistance class.
  ->Refer to the package SWDP_DEMO for sample webdynpro demos components
      and applications
->Complete integration of web  based framework into ABAP workbench.
->Reuse of the components possible
->Reuse of the existing back end programs(ex: function modules,classes)
->with EHP2 no Java stack required to run webdynpro applications
->Specific Layout frameworks are provided to use based on the requirments
  ->Example: GAF,OIF,QAF
->Most of the Layout/UI development can be done using graphical
  designer and the code wizard.
********************************************************************
Floorplan Manager and its usage in Webdynpro
Floorplan Manager is the standard UI framework provided by SAP to build web UI's in an Consistent manner so that all the SAP web UI's will have the same look and feel.

The FPM framework is available with the basis release 7.0, SP13

FPM has 3 floorplan types:
1) Object Instance floorplan(OIF). A OIF has usually the create,edit,display
   attributes and tabs to show data to the user.

2) Guided Activity floorplan(GAF): A GAF has the guided procedure to achieve
   a specific task. Ex: Start->Step1->step2->step3->Confirm to close.

3) Quick Activity floorplan(QAF): A QAF is used to quickly perform a task or
   a activity. QAF is used when a specific has to be performed by the UI.

FPM Concepts in Detail:
********************************************************************
Closing Popup windows in webdynpro ABAP
Here are the steps:
1) Create an outbound plug( ex: exit) in the window which is called as popup and add the following
    parameters to the exit plug.
    parameter1: close_window type wdy_boolean  "This is optional
    parameter2: url type string                "This is optional and
                                                           "is used to navigate to other url
    Note: Plug type should be interface and check the interface option

2) Go the view which is embedded in the window and choose properties tab.
    Press create button and add the window.
3) Go to the action(event method) on which the window should be closed and
     fire the exit plug. Assuming your window is w_win and the view is v_view.
     here is the sample piece of code to fire the exit plug.

    To close the window:

    DATA: lo_W_WIN TYPE REF TO IG_W_WIN .
              lo_W_WIN =   wd_this->get_w_win_ctr).
              lo_w_rule->fire_exit_plg(
              close_window =    abap_true ).

    To navigate to the new URL, you can use the code.

    DATA: lo_W_WIN TYPE REF TO IG_W_WIN .
              lo_W_WIN =   wd_this->get_w_win_ctr).
              lo_w_rule->fire_exit_plg(
              url =    'www.google.com'  ).

****************************************************************
Displaying formatted text in webdynpro UI
Steps:
1) Create the text in SE61 using the document class General text
    ex: my_sample_text
2) Go to view in webdynpro and add the ui element
    formatted textview (ex: ftv )
3) Create a context element for formatted textview ex: text1 of the type string
4) bind the context element text1 to formatted text element ftv
5) Write the followed code to populate data in the formmated text view ftv.

*Code snippet
Data: lo_el_context_ftv type ref to if_wd_context_element,
         lv_ftv_text type string,
         lt_ftv_text TYPE STANDARD TABLE OF tline,
         ls_header TYPE thead,
         lo_format_text TYPE REF TO cl_wd_formatted_text,
         lv_doc_state TYPE dokstate,
         se61_object type dokhl-object value 'my_sample_text',
         lo_ft_text type ref to cl_wd_formatted_text.


* Get the formmated text by passing the se61 text id: my_sample_text
  CALL FUNCTION 'DOCU_GET_FOR_F1HELP'
    EXPORTING
      id         = 'TX'
      langu    = sy-langu
      object   = se61_object
    IMPORTING
      dokstate = lv_doc_state
      head       = ls_header
    TABLES
      line     = lt_ftv_text
    EXCEPTIONS
      ret_code = 1
      OTHERS   = 2.


* Format the se61 text
    CALL METHOD cl_wd_formatted_text=>create_from_sapscript
      EXPORTING
        sapscript_head  = ls_header
        sapscript_lines = lt_ftv_text
        type            = cl_wd_formatted_text=>e_type-formatted_text
      RECEIVING
        formatted_text  = lo_ft_text.
    IF lo_ft_text is not initial.
     lv_ftv_text = lo_ft_text->m_xml_text.
    ENDIF.


* Bind the text to the context
  lo_el_context_ftv = wd_context->get_element(  ).
  lo_el_context_ftv->set_attribute(
    EXPORTING
      name =  `TEXT1`
      value = lv_ftv_text ).
****************************************************************

Controlling the visibility of the webdynpro UI elements
-Every webdynpro ui lement has a visibility property with options visible and none. To dynamically
 control the visibility of the ui element refer to the below steps.

1) Create a context attribute called visibility referring to data element wdui_visibility.
   data element wdui_visibility has possible values 01 for invisible and 02 for visible.
2) bind the context attribute visibility to the webdynpro ui elements (ex: tv_textview1) property visible.
3) write code to set the value of the context attribute visibility to 01 to hide the text view ui element
    and 02 to make the text view visible.
****************************************************************
Controlling message area height in webdynpro ABAP

Create a transparent container and under that create a message area. Create a context attribute scroll_mode type WDUI_SCROLLING_MODE and bind the scrolling mode property of the transparent container to context attribute scroll_mode.

Now code to set the scroll_mode to '02' for no scroll, '01' for scroll and '00' for auto scroll.

****************************************************************
Coding business logic in assistance class of webdynpro component

-->It is advised to code the business logic of webdynpro application in an assistance
     class because it adheres to MVC design paradigm and it refers to Model part of MVC.
     it is also called Model class.
-->Coding Business logic in assistance class improves performance and also there is
     a clear separation between the flow logic and the business logic
-->For the management of the dynamic texts by creating text symbols and accessing the
     For ex: if the assistance class has the text symbol: 999, it can be accessed using 
the code:
     dyn_text = wd_assist->if_wd_component_assistance~get_text( key = '999' ).
-->The assistance class is instantiated when the webdynpro component is called
     and an assistance class is inherited from the abstract class 
    
     CL_WD_COMPONENT_ASSISTANCE, a
n object wd_assist is created after
     instantiation. No explicit instantiation is required here.
****************************************************************
Using webdynpro trace tool

-webdynpro trace tool is used to analyse the problems and issues with webdynpro application.
 the trace can be switched on in the transaction WD_TRACE_TOOL for a given user.
 Once this trace is set it is active for 30 minutes and when the application is run during that time trace is
 recorded and that can downloaded.
-The trace tool is shown in the bottom of the webdynpro application.
-To download the trace file, choose the option trace as zip and exit.
****************************************************************
ICM Tracing for webdynpro Application

ICM(Internet Communication Manager)
ICM is used to communicate between the SAP web application server and the outside world
using http,https protocols. ICM trace is use to analyze the behaviour of the webdynpro application on the serverside and see for any communication and performance issues.
ICM trace can be set from the transaction SMICM.
All the ICM parameters can also be used in SMICM transaction: ex: server details,
time out settings etc.Here are the steps
1) Go to transaction: SMICM
2) click on the menu option goto->trace file->Start
   there are different levels of 1 is the lowest and 3 is the highest.
   the data traffic is analysed all the highest level.
****************************************************************
F4 help for inputfields in webdynpro abap
F4 help for inputfields in webdynpro can be achieved in 3 ways:
1) F4 help based on R/3 DDIC searchhelp concept.
    if the inputfield refers to DDIC object and if it has search help, A search help is automatically
    assigned to the inputfield and shown.
2) OVS(Object Value Selection
     you can achieve f4 help by using the standard component wdr_ovs, event: ovs.
3) Freely programmable Input help.  
    you can achieve f4 help by implementing the interface IWD_VALUE_HELP
****************************************************************   

Messages in webdynpro application
You can show messages in the webdynpro application by using the ui element message_area.
note message_area ui element is mandatory to trigger messages in webdynpro application. messages can be triggered using the code wizard and it uses the message manager interface  IF_WD_MESSAGE_MANAGER.

Here are a set of frequently used method to trigger messages.
1) report_success: report a success message on the webdynpro application
2) report_warining: report a warning message on the webdynpro application
3) report_error: report a error message on the webdynpro application
4) report_t100_message: reports a message from the t100 table.
5) clear_messages: clears the messages from the webdynpro application, however this will
   happen automatically on the next event on the ui.
6) is_empty: checks for any messages already raised.
7) report_attribute_error_message: reports an error for the context attribute

Sample code snippet to generate a t100 message.

**Get the message manager
data: lref_current_controller type ref to if_wd_controller.
data: lref_message_manager type ref to if_wd_message_manager.
data: lv_msgv1 type symsgv.
data: lv_msgv2 type symsgv.
data: lv_msgv3 type symsgv.
data: lv_msgv4 type symsgv.

lref_current_controller ?= wd_this->wd_get_api( ).

call method LREF_CURRENT_CONTROLLER->GET_MESSAGE_MANAGER
  receiving
    MESSAGE_MANAGER = LREF_MESSAGE_MANAGER.

* report t100 message
call method LREF_MESSAGE_MANAGER->REPORT_T100_MESSAGE
  exporting
    MSGID         =’ZZZZ’   "Message class
    MSGNO       =’999’    "Message Number
    MSGTY        =’E’         "Message type
    P1                 = lv_msgv1
    P2                 = lv_msgv2
    P3                 = lv_msgv3
    P4                 = lv_msgv4.
****************************************************************  
Post a Comment