cancel
Showing results for 
Search instead for 
Did you mean: 

How to generate fields dynamically using WDR_SELECT_OPTIONS

former_member198064
Participant
0 Kudos

Hi All,

In my Requirement fields are not coming from context node we need to generate the fields Dynamically through selection screen in WDR_SELECT_OPTIONS.

How to do this?

Thanks,

Durga.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

HI Durga,

        I am assuming that u r using the componet 'WDR_SELECT_OPTIONS' to create some select option fields in your screen. However not sure what r u trying to convey 'by fields are not coming from context node we need to generate the fields Dynamically'.

       When you define a select option field, u dont have to link it to any context , creating the reange table by providing a data element will do the work like below.

   DATA: lt_range_table TYPE REF TO DATA.

" Call the interface controller method init_selection_screen to get the helper class

  WD_THIS->M_WD_SELECT_OPTIONS_REPORT = WD_THIS->WD_CPIFC_SELECT_OPTION( ).
  WD_THIS->M_HANDLER_REPORT = WD_THIS->M_WD_SELECT_OPTIONS_REPORT-

>INIT_SELECTION_SCREEN( ).

  wd_this->m_handler_report->set_global_options(
                              i_display_btn_cancel  = abap_false
                              i_display_btn_check   = abap_false
                              i_display_btn_reset   = abap_true
                              i_display_btn_execute = abap_false ).

* create a range table that consists of this new data element
  lt_range_table = wd_this->m_handler_report->create_range_table( i_typename = 'S_CARR_ID' ).

* add a . field to the selection with description
  wd_this->m_handler_report->add_selection_field( i_id = 'S_CARR_ID'
                                                  I_DESCRIPTION = ' Airline No'
                                                  it_result = lt_range_table ).

Now you might be need some more adding to this, can you explain your requirement in details.

Regards,

Monishankar Chatterjee

Former Member
0 Kudos

Hi,

Based on the fields of WDR_SELCT_OPTIONS build dynamic context in WDDOINIT method of the view.

check the following code which I used to give you an Idea.

1)* get meta data info of root context node

   lo_nd_info_root = wd_context->get_node_info( ).

2) Add node dynamically to context

DATA dref TYPE REF TO data.

FIELD-SYMBOLS <ref> TYPE ref to if_wd_context_node_info.

CONCATENATE 'HEADER_' ls_form-formid into str.

       CONDENSE str.

       CREATE DATA dref TYPE REF TO if_wd_context_node_info.

       ASSIGN dref->* TO <ref>.

       <ref> = lo_nd_info_root->add_new_child_node(

         name                         = str

         is_mandatory                 = abap_true

         is_mandatory_selection       = abap_false

         is_multiple                  = abap_false

         is_multiple_selection        = abap_false

         is_singleton                 = abap_true

         is_initialize_lead_selection = abap_true

         is_static                    = abap_false ).

3) add attributes to node

  ls_attribute-name            = ls_invrules-fieldname.  ->name

       ls_attribute-type_name       = 'CHAR40'.  -> type which comes from your select options

       <ref>->add_attribute( attribute_info = ls_attribute ).

Hope this helps..

Thanks

former_member198064
Participant
0 Kudos

Hi Sukumar,

Can you give me some example program for this clearly.

Former Member
0 Kudos

Hi Durga,

Try this tutorial for creating select options.

http://webdynproabap.wordpress.com/2012/07/14/select-options-set/

Regards,

Arun Krishnamoorthy

former_member210804
Active Participant
0 Kudos

Hi,

Procedure to achieve SELECT OPTIONS for a field

  • Create Web Dynpro Component with Window and View.(Automatically View is embedded into Window). 
  • Define Component Use for the WDR_SELECT_OPTIONS under Used Components tab of Web Dynpro Component.  
  • Define Controller usage for WDR_SELECT_OPTIONS in the Properties tab of view.  
  • Create ViewContainerUIElement in the view Layout.  
  • Do the following in WDDOINIT hook method. 
    • Instantiate Used Component  WDR_SELECT_OPTIONS.

    • Instantiate Used Component Controller IWCI_WDR_SELECT_OPTIONS and and Call method INIT_SELECTION_SCREEN
    • Create Range Table using IF_WD_SELECT_OPTIONS->CREATE_RANGE_TABLE
    • Add Selection field by passing Range table and Field to IF_WD_SELECT_OPTIONS-> ADD_SELECTION_FIELD
  • Go to Window of the component->View->ViewContainerUIElement  
  • Embed the view WND_SELECTION_SCREEN of Used Component WDR_SELECT_OPTIONS into ViewContainerUIElement of Web Dynpro Component. 
  • Activate Web Dynpro Component 
  • Create Web Dynpro Application and Run.