cancel
Showing results for 
Search instead for 
Did you mean: 

validate select option fields

Former Member
0 Kudos

Hi all,

I have two fields on my selection screen(Select Options). Now I want to validate if the user the entered the values in the select options or not.

I have used the following code which are not working.

data: range_table_chn type ref to data,

range_table_chn = WD_THIS->M_HANDLER->GET_VALUE_OF_PARAMETER_FIELD( i_id = 'KUNNR' ).

if not range_table_chn is initial.

Message.

endif.

and

data: range_table_chn type ref to data,

range_table_chn = WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD( i_id = 'KUNNR' ).

if not range_table_chn is initial.

Message.

endif.

Both of these are not working . Can any one suggest me the correct way of validating the select options if the user entered or not?

Thanks,

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Try the Below code. make the changes accordingly

data:lr_data     type ref to data.
    field-symbols: <lt_mod> type table.
    
    data:
    lt_selop_tbl type zst_selop_tbl, " range table
    lst_selop_tbl type zst_selop_row. " row

    lr_data = wd_this->mr_selopt->get_range_table_of_sel_field( i_id = 'CAND' ).
    assign lr_data->* to <lt_mod>.
    
    loop at <lt_mod> into lst_selop_tbl.

    if lst_selop_tbl-low = ' ' and  lst_selop_tbl-high = ' '.
       " blank
        exit. 
    else.
         "no blank 
    endif.

    endloop.

Greetings

Prashant

Former Member
0 Kudos

thanks prashant, that solved my problem

Former Member
0 Kudos

Hi Manoj,

I am also facing the same problem for validation.

The code that u have given can u tell how do i define the range =table(zstselop_tbl) in my code?

DATA rt_ranges TYPE REF TO data.

DATA selection_criteria TYPE pobjs_srch_sel_changeselection.

DATA selection_fields TYPE if_wd_select_options=>tt_selection_screen_item.

DATA selection_field TYPE LINE OF if_wd_select_options=>tt_selection_screen_item.

DATA lo_interfacecontroller TYPE REF TO iwci_wdr_select_options .

DATA lo_r_helper_class TYPE REF TO if_wd_select_options.

data ls_select_table like line of lt_select_table.

data lv_msg type bapi_msg.

data ex_error_flag type wdy_boolean.

data range_tab_value type zst_selop_tbl.

lo_interfacecontroller = wd_this->wd_cpifc_select_options( ).

  • init the select screen

lo_r_helper_class = lo_interfacecontroller->init_selection_screen( ).

CLEAR selection_fields.

if lo_r_helper_class IS NOT INITIAL.

lo_r_helper_class->get_selection_fields(

IMPORTING

et_fields = selection_fields ).

ENDIF.

  • Retrieve the data from the select option

LOOP AT selection_fields INTO selection_field.

selection_criteria-range_table = lo_r_helper_class->get_range_table_of_sel_field(

i_id = selection_field-m_id ).

selection_criteria-fieldname = selection_field-m_id.

move-corresponding selection_criteria to ls_select_table.

Append ls_select_table to lt_select_table.

ENDLOOP.

former_member402443
Contributor
0 Kudos

Hi,

Try this code for validation.

METHOD onactionsearch_data .

  • Processing For OnAction ´SEARCH` on Screen

DATA:lo_po_list TYPE REF TO if_wd_context_node ,

lo_el_po_list TYPE REF TO if_wd_context_element ,

lo_werks TYPE REF TO data ,

lo_ebeln TYPE REF TO data ,

lo_ebdat TYPE REF TO data .

DATA lt_werks TYPE if_wd_select_options=>tt_selection_screen_item.

DATA:lt_po_list TYPE /bay0/msdts_cl_whp_goods_rcp=>tt_po_list ,

lv_valid TYPE abap_bool .

DATA lv_text_key TYPE wdr_text_key .

FIELD-SYMBOLS: <lt_ebeln> TYPE ANY TABLE,

<lt_ebdat> TYPE ANY TABLE.

**----Get the Data from the select Option&Parameter-----***

    • Returns the data from a parameter field-P_WERKS*

wd_this->m_handler->get_parameter_fields( IMPORTING et_fields = lt_werks ).

    • Retrieve the data from the select option*

lo_ebeln = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'SO_EBELN' ).

    • Assign it to a field symbol*

ASSIGN lo_ebeln-> TO .*

  • Retrieve the data from the select option

lo_ebdat = wd_this->m_handler->get_range_table_of_sel_field( i_id = 'SO_EBDAT' ).

  • Assign it to a field symbol

ASSIGN lo_ebdat-> TO .*

**----Data access using the methods of Assistance Class-----***

  • Validate the entered data on Selection Screen

wd_assist->validate_sel_screen_data( EXPORTING it_so_ebeln = lo_ebeln

it_p_werks = lt_werks

IMPORTING ev_valid = lv_valid

ev_text_key = lv_text_key ).

  • Display Message if LV_VALID = X means when input is Invalid

IF lv_valid EQ 'X'.

  • Msg-Please enter correct Purchase Order Num.

EXIT.

ENDIF.

ENDMETHOD.

METHOD validate_sel_screen_data.

DATA ls_ekko TYPE ekko.

DATA lv_werks TYPE werks_d.

DATA ls_werks TYPE if_wd_select_options=>t_selection_screen_item.

FIELD-SYMBOLS: TYPE ANY .

READ TABLE it_p_werks INTO ls_werks INDEX 1.

IF sy-subrc EQ 0.

  • Assign it to a field symbol

ASSIGN ls_werks-m_value->* TO IS not ASSIGNED.

  • MOVE '106' TO ev_text_key.

ev_valid = 'Y'.

exit.

ENDIF.

  • Validate Plant eneterd on selection screen

SELECT SINGLE werks

FROM t001w

INTO lv_werks

WHERE werks EQ .

IF sy-subrc EQ 0.

  • Do the Authority Check

AUTHORITY-CHECK OBJECT 'M_BEST_WRK'

ID 'ACTVT' FIELD '03'

ID 'WERKS' FIELD lv_werks.

IF sy-subrc NE 0.

MOVE '105' TO ev_text_key.

ev_valid = abap_true.

exit.

ENDIF.

ELSE.

MOVE '104' TO ev_text_key.

ev_valid = abap_true.

exit.

ENDIF.

ENDIF.

  • Assign it to a field symbol

ASSIGN it_so_ebeln->* TO IS NOT INITIAL.

  • Get Purch. Order from EKKO table

SELECT ebeln

FROM ekko

INTO ls_ekko

UP TO 1 ROWS

WHERE ebeln IN .

ENDSELECT.

IF sy-subrc EQ 0.

ev_valid = abap_false.

ELSE.

MOVE '102' TO ev_text_key.

ev_valid = abap_true.

ENDIF. "if sy-subrc eq 0.

ENDMETHOD.

Regard

Manoj Kumar

Edited by: Manoj Kumar on Mar 10, 2009 10:30 AM

Former Member
0 Kudos

Hi,

use the field symbols here,

assign range_table_chn->* to <range_t_chn>.

now you can check the table <range_t_chn>.

or pass this table info to other process:

loop at <range_t_chn> into <range_w_chn>.

passwhere ever you ened = <range_w_chn>-fields..............

endloop.

it will work now...

Thanks,

naresh

Former Member
0 Kudos

Naresh I was basically asking for the select option validation. Manoj thanks for the code I will try out this code

thanks.

Former Member
0 Kudos

Manoj,

the code you have given basically tries to see if the data entered is in the database or not. I just need to validate the select option is initial or not.