Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select option for selection valid and invalid data.

Former Member
0 Likes
2,070

Hi All,

Any one pleas help in validating following case :-

In the selection screen there is a select option for equipment number like EQUI-EQUNR

if any user will give wrong equipment no. It will generate an error message from the range of equipment no.

and put it to an internal table it error.

and if any value in between the select option(equipment no) is correct then that value I need to proceed for some other logic.

Iu2019d appreciate if some one help me in generation code for the above case or logic.

Thanks

6 REPLIES 6
Read only

Former Member
0 Likes
1,596

see the data you have input you can tht from the DATA DICTIONARY table its exist ot not .

if exist then

Message 'equipment exist' . type 'E' .

else do the execution which u want .

rgds aryan

Read only

Former Member
0 Likes
1,596

Hi,

Use FM 'RS_REFRESH_FROM_SELECTOPTIONS'

DATA: RSPAR TYPE STANDARD TABLE OF RSPARAMS.

REFRESH RSPAR.

CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'

EXPORTING

CURR_REPORT = 'prog name'

  • IMPORTING

  • SP =

TABLES

SELECTION_TABLE = RSPAR

EXCEPTIONS

NOT_FOUND = 1

NO_REPORT = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

  • MESSAGE I000.

ENDIF.

In table parameter you ll get the all entries entered .

Check out the values with respective tables.If value is not correct tk it into internal table

else proceed ahead. You can Remove incorrect entries this way.

regards,

ajit.

Read only

Former Member
0 Likes
1,596

Loop at sel_ot_parameter.

check for existance of equip_mber.

if sy-subrc <> 0 .

message error.

else.

do_ur_processing.

endif.

endloop.

Gives error mssage for wrong equip number...and processess correct equip numbrs..

or

Loop at sel_ot_parameter.

check for existance of equip_mber.

if sy-subrc <> 0 .

delete sele_opt_parameter.

endif.

endloop.

Finall u will have only the correct equip_numbers.

Read only

Former Member
0 Likes
1,596

Please check the below logic.

ranges: r_correct for EQUI-EQUNR.

loop at select-option.

if the value value selection-option-low is incorrect then append this value to error table.

else.

r_correct-sign = 'I'

r_correct-sign = 'Equi'

r_correct-low = selection-option-low.

endif.

if selection-option-high is not initial.

if the value selection-option-high is incorrect then append this value to error table.

else.

r_correct-high = selection-option-high.

append r_correct.

endif.

else.

append r_correct.

endif.

endloop.

Edited by: Sheelesh on Jun 4, 2009 12:15 PM

Edited by: Sheelesh on Jun 4, 2009 12:21 PM

Read only

Former Member
0 Likes
1,596

In the at selection screen event.

write a logic like,

select field1

from table

into wa where <fieldname> in [select=option].

if sy-subrc is not initial.

Append the work area entry into an internal table.

endif.

endselect.

So if you move it into a work area, the select statement would execute for every single entry that is there in the select option.

Read only

former_member585060
Active Contributor
0 Likes
1,596

Hi,

The below logic works only if the EQUNR number contains numeric values, if it contains other character other than number it may trigger endless loop.

TABLES : equi.

TYPES : BEGIN OF ty_itab,
         equnr TYPE equnr,
        END OF ty_itab.

TYPES : BEGIN OF ty_err,
         equnr TYPE equnr,
         message(50) TYPE c,
        END OF ty_err.

DATA : it_itab TYPE TABLE OF ty_itab,
       it_err TYPE TABLE OF ty_err,
       ls_itab TYPE ty_itab,
       ls_err TYPE ty_err.

DATA : lv_equnr TYPE equnr.

SELECT-OPTIONS : s_equnr FOR equi-equnr.


AT SELECTION-SCREEN ON  s_equnr.

  SELECT equnr FROM equi INTO TABLE it_itab
                         WHERE equnr IN s_equnr.


  lv_equnr = s_equnr-low.

  WHILE lv_equnr LE s_equnr-low.

    READ TABLE it_itab INTO ls_itab WITH KEY equnr = lv_equnr.

    IF sy-subrc <> 0.

      ls_err-equnr = lv_equnr.
      ls_err-message = ' Number not forund'.

      APPEND ls_err TO it_err.

    ENDIF.
    CLEAR ls_err.

    ADD 1 TO lv_equnr.

  ENDWHILE.


START-OF-SELECTION.

Regards

Bala Krishna