cancel
Showing results for 
Search instead for 
Did you mean: 

Select-options disable/enable based on radiobutton in Webdynpro

former_member187692
Participant
0 Kudos


Hi,

     I need to enable/disable the select-options based on radio button selected in Webdynpro. Below is the requirement.

I have 2 radiobuttons, one for Customer & another for Sales Order. Now when I click on customer radiobutton, the VBELN select-options should be disable and KUNNR select-options should be their to enter values (by default Customer button is clicked and KUNNR select-options is available to enter entries)

AND when I click on Sales Order radiobutton, KUNNR select-option to be disabled and VBELN should be enabled.

I am declaring select-options using the used comp. wdr_select_options.

PS:- I have done this using a Parameters(single values) using the Visibility option in the layout.

Regards,

Krishna.

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

You can achieve your requirement as below


  • Go to attributes tab of your view and create attributes GV_READ_KUNNR & GV_READ_VBELN
  • Let us say we have created a method CONFIG_SEL_SCREEN( ) in view and it has configuration logic of selection screen
  • Call the above method in WDDOINIT( ) method to initialize the selection screen
  • Pass these attributes while adding parameter field to the selection screen for READ_ONLY parameter as below

       wd_this->m_sel_options->add_parameter_field(

       EXPORTING

        i_id                         = 'KUNNR'    " ID of Selection Field

        i_value                      = lv_param1

       i_read_only                  = wd_this->gv_read_KUNNR

  • Now, on select event of radio button group, you can set the value of attributes as below

CASE lv_index.

    WHEN 1.

      wd_this->gv_kunnr = abap_false.

      wd_this->gv_vbeln = abap_true.

    WHEN 2.

      wd_this->gv_kunnr = abap_true.

      wd_this->gv_vbeln = abap_false.

  ENDCASE.

  • Rebuild the selection screen again i.e. call the method CONFIG_SEL_SCREEN( ) to reconstruct the selection screen with updated read_only parameter

Hope this helps you.

Regards,

Rama

former_member187692
Participant
0 Kudos

What is this config_sel_screen( what r the parameters req. )

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

config_sel_screen( ) is the custom method ( created by you ) which just builds the selection screen. No need to have parameters as we are having view attributes to set.

If you dont want to have view attributes you can pass the parameters based on radio button selection.

Regards,

Rama

former_member187692
Participant
0 Kudos

Ok. Also regarding the "lv_index" you mentioned above, I trying to get the index using the "get_lead_selection_index" . (from context node  methods)

There is an error when I swap the radiobuttons(when i remove the index code and check the output, its working fine without the radiobutton functionality)

Below is the on radiobutton select code:- 

   DATA LW_INDEX TYPE I.

  LO_ND_RADIO_NODE1 = WD_CONTEXT->GET_CHILD_NODE( NAME =

   WD_THIS->WDCTX_RADIO_NODE1 ).


CALL METHOD LO_ND_RADIO_NODE1->GET_LEAD_SELECTION_INDEX
  RECEIVING
    INDEX = LV_INDEX.


CASE LV_INDEX.
  WHEN 1.

..

..

ENDCASE.

former_member187692
Participant
0 Kudos

and in the above code i have also called

  LO_EL_RADIO_NODE1 = WD_CONTEXT->GET_ELEMENT( ).

after "Get_lead_selection_index method."             (failed to mention before)

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

Are you using RadioButtonGroupByIndex ui element

Please find the below code to be written in OnSelect event handler method your radio button


METHOD onactionselect .
  DATA lv_index TYPE i.


  wdevent->get_data(
  EXPORTING name = 'INDEX' IMPORTING value = lv_index ).

  CASE lv_index.
    WHEN 1.
      wd_this->gv_read_param1 = abap_false.
      wd_this->gv_read_param2 = abap_true.
    WHEN 2.
      wd_this->gv_read_param1 = abap_true.
      wd_this->gv_read_param2 = abap_false.
  ENDCASE.

  wd_this->config_sel_screen( ).
ENDMETHOD.

Please modify the logic as per your requirement.

Regards,

Rama

former_member187692
Participant
0 Kudos

  WDEVENT->GET_DATA(
       EXPORTING
           NAME  = 'INDEX'
       IMPORTING
           VALUE = LV_INDEX ).

CASE LV_INDEX.


  WHEN 1.

      WD_THIS->GV_KUNNR = ABAP_FALSE.
      WD_THIS->GV_VBELN = ABAP_TRUE.
WHEN 2.

     WD_THIS->GV_KUNNR = ABAP_TRUE.
      WD_THIS->GV_VBELN = ABAP_FALSE.
ENDCASE.

WD_THIS->M_WD_SELECT_OPTIONS->INIT_SELECTION_SCREEN( ).

I have used this method which builds the selection screen " init_selection_screen( )"

The index is not being read in mine I believe.... bcoz when I mentioned like case ... endcase( no select- option is disabled  but if I give "abap_true" in the 'read_only' parameters, atleast 1 select-option field is getting disabled.) Could you please elaborate the code and gv_kunnr and gv_vbeln are of type  character or Integer will do, right .

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

The attributes GV_KUNNR & GV_VBELN are of type WDY_BOOLEAN.

Here lv_index is just tells you option1 or option2 from radio button group.

Any way, I will prepare a document on the same and provide the link very soon.

Regards,

Rama

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

Please find the below document which meets your requirements.

Hope this resolves your issue.

Regards,

Rama

former_member187692
Participant
0 Kudos

Really thanks for your document but i am trying to create a range of value and i am doing this way

to create a range of it .... i am doing it this way

    LV_VBELN = WD_THIS->M_SEL_OPTIONS->CREATE_RANGE_TABLE( I_TYPENAME = 'VBELN' ).

    WD_THIS->M_SEL_OPTIONS->ADD_PARAMETER_FIELD(
      EXPORTING
        I_ID                         = 'VBELN'
        I_VALUE                      = LV_VBELN
        I_READ_ONLY                  = WD_THIS->GV_READ_VBELN
    ).

     {I actually needed the range of values ...}

It shows an error..... says " dynamics type conflicts with reference "

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

Error is because, ADD_PARAMETER_FIELD does not cater for ranges.

You need need to use the method ADD_SELECTION_FIELD( ) which supports the range table input

Hope this helps you.

Regards,

Rama

former_member187692
Participant
0 Kudos

Thanks Rama,

            

           

Regards,

Krishna.

ramakrishnappa
Active Contributor
0 Kudos

You are welcome

Regards,

Rama

former_member187692
Participant
0 Kudos

Hi Rama,

I had a query regarding the same requirement, so I thought i better post it here.

Now I have created link to action on VBELN which opens up VA03 app along with its value skipping the initial screen. But when I add another Link to action on KUNNR( which should go to XD03 ) both the apps are opening up in 2 windows simultaneously.

Now my ques is where do I put the "IF clause" so as to control the T-code and open based on the feild clicked on ALV table. 

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

You can achieve your requirement as below


  • Let us say you have link to action ui elements name KUNNR & VBELN in the view
  • Create an action "ON_CLICK" in the view and assign SAME action to both ui elements event "OnAction"
  • Now, inside the event handler method "ONACTIONON_CLICK", you get get the ui element name on which the click event taken place by using ID from WDEVENT

Sample code:

METHOD onactionon_click .


  DATA lv_id TYPE string.

  wdevent->get_data( EXPORTING name = 'ID' IMPORTING value = lv_id ).
 
  CASE LV_ID.


   WHEN 'KUNNR'.
      " Open T-code XD03


   WHEN 'VBELN'.
      " Open T-code VA03


   WHEN OTHERS.


  ENDCASE.


ENDMETHOD.

Hope this helps you.

Regards,

Rama

former_member187692
Participant
0 Kudos

    WDEVENT->GET_DATA(
  EXPORTING NAME = 'ID'.....

here " ID " is ... ?

( should i just give ID or change it to sth else ?)

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

Its standard parameter, no need to change.

You will receive your ui element name with this parameter.

Regards,

Rama

former_member187692
Participant
0 Kudos

   *DATA: LV_ID TYPE STRING.
*
*WDEVENT->GET_DATA( EXPORTING NAME = 'ID'
*                   IMPORTING VALUE = LV_ID ).
*
*CASE LV_ID.
*
*WHEN 'KUNNR'.
*
** DATA DECLARATION
*  DATA :
** Variable to get the url
*        LV_URL            TYPE STRING,
** Variable to get the host name
*        LV_HOST           TYPE STRING,
** Variable to get the Port number
*        LV_PORT           TYPE STRING,
** Window manager
*        LO_WINDOW_MANAGER TYPE REF TO IF_WD_WINDOW_MANAGER,
*        LO_API_COMPONENT  TYPE REF TO IF_WD_COMPONENT,
*        LO_WINDOW         TYPE REF TO IF_WD_WINDOW.
*  FIELD-SYMBOLS: <L_VALUE> TYPE ANY.
** Get the invoice number clicked on the screen
*  ASSIGN R_PARAM->VALUE->* TO <L_VALUE>.
*
** Call below method to get host and port
*  CL_HTTP_SERVER=>IF_HTTP_SERVER~GET_LOCATION(
*     IMPORTING
*       HOST = LV_HOST
*       PORT = LV_PORT ).
** Get the URL by combining the port and host. We can also pass values
** To the transaction. The below code will open VA03 transaction
*
*  CONCATENATE
*    'HTTP://'
*    LV_HOST
*    ':'
*    LV_PORT
*    '/SAP/BC/GUI/SAP/ITS/WEBGUI?~transaction=*XD03 KNA1-KUNNR='
*    <L_VALUE> INTO
*    LV_URL.
*
** Get the current component
*  LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
** Get reference to window manager
*  LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
** create External Window
*  LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW(
*    EXPORTING
*      URL = LV_URL
*    RECEIVING
*      WINDOW = LO_WINDOW ).
** Open the Invoice details VA03 in separate browser
*  LO_WINDOW->OPEN( ).
*
*WHEN 'VBELN'.
** DATA DECLARATION
*  DATA :
** Variable to get the url
*        LV_URL1            TYPE STRING,
** Variable to get the host name
*        LV_HOST1           TYPE STRING,
** Variable to get the Port number
*        LV_PORT1           TYPE STRING,
** Window manager
*        LO_WINDOW_MANAGER1 TYPE REF TO IF_WD_WINDOW_MANAGER,
*        LO_API_COMPONENT1  TYPE REF TO IF_WD_COMPONENT,
*        LO_WINDOW1         TYPE REF TO IF_WD_WINDOW.
*  FIELD-SYMBOLS: <L_VALUE1> TYPE ANY.
** Get the invoice number clicked on the screen
*  ASSIGN R_PARAM->VALUE->* TO <L_VALUE1>.
*
** Call below method to get host and port
*  CL_HTTP_SERVER=>IF_HTTP_SERVER~GET_LOCATION(
*     IMPORTING
*       HOST = LV_HOST1
*       PORT = LV_PORT1 ).
** Get the URL by combining the port and host. We can also pass values
** To the transaction. The below code will open XD03 transaction
*
*  CONCATENATE
*    'HTTP://'
*    LV_HOST1
*    ':'
*    LV_PORT1
*    '/SAP/BC/GUI/SAP/ITS/WEBGUI?~transaction=*VA03 VBAK-VBELN='
*    <L_VALUE1> INTO
*    LV_URL1.
*
** Get the current component
*  LO_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).
** Get reference to window manager
*  LO_WINDOW_MANAGER = LO_API_COMPONENT->GET_WINDOW_MANAGER( ).
** create External Window
*  LO_WINDOW_MANAGER->CREATE_EXTERNAL_WINDOW(
*    EXPORTING
*      URL = LV_URL1
*    RECEIVING
*      WINDOW = LO_WINDOW1 ).
** Open the Invoice details XD03 in separate browser
*  LO_WINDOW1->OPEN( ).
************************
*ENDCASE.

In my above code, the hyperlink is visible but nothing works on_click.( for both VBELN & KUNNR ).

With the above code for only one field, its working fine.

ramakrishnappa
Active Contributor
0 Kudos

Hi Krishna,

This is different requirement than your current question. You should have posted it separately.

Any way, please modify the code as below


  DATA lv_tcode_text    TYPE string.

  FIELD-SYMBOLS:<LV_VALUE> TYPE any.

  ASSIGN r_param->value->* to <lv_value>.

  CASE r_param->attribute.
    WHEN 'KUNNR'.
      " Open T-code XD03

      CONCATENATE '~transaction=XD03&KNA1-KUNNR='
      <lv_value> '&~OKCODE=SHOW'
      INTO lv_tcode_text.
    WHEN 'VBELN'.
      " Open T-code VA03
      CONCATENATE '~transaction=VA03&VBAK-VBELN='
      <lv_VALUE>   '&~OKCODE=SHOW'
  INTO lv_tcode_text.
    WHEN OTHERS.
  ENDCASE.

*  ** DATA DECLARATION
  DATA :
* Variable to get the url
        lv_url            TYPE string,
* Variable to get the host name
        lv_host           TYPE string,
* Variable to get the Port number
        lv_port           TYPE string,
* Window manager
        lo_window_manager TYPE REF TO if_wd_window_manager,
        lo_api_component  TYPE REF TO if_wd_component,
        lo_window         TYPE REF TO if_wd_window.
  FIELD-SYMBOLS: <l_value> TYPE any.

* Call below method to get host and port
  cl_http_server=>if_http_server~get_location(
     IMPORTING
       host = lv_host
       port = lv_port ).


* Get the URL by combining the port and host. We can also pass values
* To the transaction. The below code will open VA03 transaction

  CONCATENATE
    'HTTP://'
    lv_host
    ':'
    lv_port
    '/SAP/BC/GUI/SAP/ITS/WEBGUI?' lv_tcode_text
    INTO
    lv_url.

* Get the current component
  lo_api_component = wd_comp_controller->wd_get_api( ).
* Get reference to window manager
  lo_window_manager = lo_api_component->get_window_manager( ).
* create External Window
  lo_window_manager->create_external_window(
    EXPORTING
      url = lv_url
    RECEIVING
      window = lo_window ).

  lo_window->open( ).

Hope this resolves your issue.

Regards,

Rama

Answers (1)

Answers (1)

former_member222068
Active Participant
0 Kudos

Hi Krishna,

Based on the condition, set the field to editable or non-editable:

Within the method ADD_SELECTION_FIELD( ), set the parameter I_READ_ONLY = abap_true or abap_false based on the conditions.

Hope this should help you.

Thanks & Regards,

Sankar Gelivi