Tuesday, April 17, 2012

Getter - Setter methods in Web UI


Using Get and Setter methods you can retrieve data to field and set specific data to field.
Using Get_I method you can make your field as grade out based up on any condition.
Using  Get_M method you can manage meta data of the field.
Using Get_P method you can define property of the field like text, dropdown etc and you can call specific even handler using P method
Using Get_V method you can retrieve the dropdown values based up on your condition

Code examples :


  • Get_I method you can make your field as grade out based up on any condition.
If you want to make a field  editable /display

METHOD GET_I_COMM_TYPE_TEXT.

  rv_disabled = 'TRUE'.

ENDMETHOD.

If u want to make a field editable  rv_disabled = 'FALSE'
                                         and for display   rv_disabled = 'TRUE'



  • Get_P method to change the property of the field . 

Field properties modification using the GET_P

In the CRM webclient, the properties of a field can be changed.
The change can vary from changing the field type, for instance changing a dropdown listbox to an ordinary input field or a checkbox or a radiobutton, to changing the tooltip text, to implementing navigation to another screen when clicking on the field.
The changes are done in the GET_P of an attribute of the context node.

1. Determine the component and view to be changed.
In the CRM webclient navigate to the search screen to be adjusted, click in a field and press . Note the component and the viewname.

2. Enhance the component and view
First enhance the component and enhance the view. How to enhance a component and a view can be found here.

3. Redefine the method DO_INIT_CONTEXT.
Redefine the DO_INIT_CONTEXT Remember to always call the super class. How to redefine a method can be found here.

[IMG OF WORKBENCH SELECTING THE CONTEXT NODE].

The GET_P is run several times when adding the field to the screen at runtime.
Examples:
Changing a field to a hyperlink:The following example changes the field to a hyperlink, which when clicked upon, will navigate to a different screen

CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
    WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
      rv_value = 'NAVIGATE_TO_TARGET'.
ENDCASE.

Of course, you will also need to implement the event EH_ONNAVIGATE_TO_TARGET. 

Changing a field to a checkbox and adding a tooltip.
CASE iv_property.
  WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_checkbox.
  WHEN if_bsp_wd_model_setter_getter=>fp_tooltip.
      rv_value = text-001.
ENDCASE.
Additional comments.
One of the importing parameters of the get_p is the field IV_DISPLAY_MODE. This field can be checked to see whether the field is in change or in display mode. You can implement different properties to the field in change and in display mode.
Another of the importing parameters is the IV_INDEX. This can be used to determine in which line you are in the table.


One more code example 
CASE iv_property.
    WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.(change this value for the property)
    WHEN if_bsp_wd_model_setter_getter=>fp_onclick.(for link )
      rv_value = 'NAVIGATE_TO_TARGET'.
  ENDCASE.


**************************************

Implementing a valuehelp using the GET_V for a DDLB

In the CRM webclient you implement or redefine the valuehelp logic. Sometimes a valuehelp is not implemented in the standard, or you might want to implement a more company-specific valuehelp. This can be done by redefining the GET_V of an attribute of a context node.
A GET_V for a DDLB (DropDown List Box) would particularly contain the following code:
----------------------------------------------------------
DATA:  lt_ddlb  TYPE             bsp_wd_dropdown_table,
          lr_ddlb TYPE REF TO cl_crm_uiu_ddlb.

lt_ddlb = cl_crm_uiu_bt_tools=>get_strcmp_ddlb(
                iv_structure = [name of the structure the field is part of]
                iv_component = [Fieldname])
                .

IF NOT lr_ddlb IS BOUND.
     CREATE OBJECT lr_ddlb EXPORTING iv_source_type = 'T'.
ENDIF.
lr_ddlb->set_selection_table( it_selection_table = lt_ddlb ).

rv_valuehelp_descriptor = lr_ddlb.

----------------------------------------------------------
If you want the dropdown listbox to be occupied with values from a domain, you can use the following code:
----------------------------------------------------------

  DATA:lt_ddlb TYPE bsp_wd_dropdown_table.  
  SELECT domvalue_l ddtext INTO TABLE lt_ddlb FROM dd07t WHERE
      domname = [domain] AND ddlanguage = sy-langu.

  INSERT INITIAL LINE INTO lt_ddlb INDEX 1.
  SORT lt_ddlb BY value.
  IF sy-subrc = 0.
       CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_pldescr
        EXPORTING
            iv_source_type = 'T' -> this specifies table 
            iv_selection_table = lt_ddlb.
 ENDIF.

----------------------------------------------------------

The values from the valuehelp are determined when building the screen (do_prepare_output). This means, that if you want the available values to vary based on the contents of another field, you only have to trigger a roundtrip to the server (like raising a server event, which can be implemented in the get_p) when the contents of the field which it depends on are changed.

Furthermore, you will have to implement in the get_v of the field how the available values are filtered.



No comments:

Post a Comment