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-OPTIONS:

Former Member
0 Likes
706

Hi Experts,

I have to validate many fields for select-options,so can any guide me regarding the same.

SELECT-OPTIONS: A1 for bsad-kunnr,

a2 for bsad-belnr,

a3 for bsad-blart,

a4 for bsad-waers,

a4 for bsad-bldat,

a5 for bsad-budat,

a6 for bsad-sgtxt.

Rewarded if helpful.

7 REPLIES 7
Read only

Former Member
0 Likes
675

Hi,

Use Event AT SELECTION SCREEN on <Field>.

Regards,

Krishna

Read only

Former Member
0 Likes
675

hi,

Do check the example code, this might give you some idea how to do it.


REPORT zdummy_atg_2 message-id 000.
 
TABLES: SPFLI.
 
SELECTION-SCREEN BEGIN OF BLOCK TEST.
SELECT-OPTIONS:
              S_CARRID FOR SPFLI-CARRID.
SELECTION-SCREEN END OF BLOCK TEST.
 
AT SELECTION-SCREEN.
READ TABLE S_CARRID INDEX 1.
IF S_CARRID-HIGH LT S_CARRID-LOW.
  MESSAGE E000 WITH 'Error'.
ENDIF.

Hope this helps, Do reward.

Read only

Former Member
0 Likes
675

hi,

select-options p1 for zcust_master2-zcustid.

at selection-screen.

if p1-high < p1-low.

message ...

regards,

Arunsri

Read only

0 Likes
675

Hi all,

I want to validate field with respective table bsad, whether the entry made in select-option is ther in the database or not? if not it has to throw error message???

Read only

0 Likes
675

try this.......

 data it_bsad type table of bsad.
SELECT-OPTIONS: A1 for bsad-kunnr,
a2 for bsad-belnr,
a3 for bsad-blart,
a4 for bsad-waers,
a5 for bsad-bldat,
a6 for bsad-budat,
a7 for bsad-sgtxt.

at selection-screen

select * from bsad into table it_bsad
where kunnr in a1 
and     belnr in a2
and 	blart in a3
and     waers in a4
and     bldat in a5
and     budat in a6
and     sgtxt in a7.

if sy-subrc NE 0.
 message 'Entry not found' type 'E'.
endif.

Note: I'm not sure the order of the fields in the where clause . So ensure the order of the fields in the where clause is as same as they appear in the bsad.

Now the at selection-screen event will be called after u press enter or execute on the selection screen , if any of the select option is empty, it will be ignored in the select query and the records fetched from the database will be fetched which meet criteria with the entered values in the selection screen (its almost like accessing data from data browser se16) .

Hope it solves your problem. Don't forget to reward points

Edited by: Advait Gode on Mar 1, 2008 7:11 PM

Read only

Former Member
0 Likes
675

hi moni,

the above code will work fine if you want o/p with any one or more select option. but if u want to validate each individyual filed then you have to proceed as follow..

1. use event 'AT SELECTIOON SCREEN ON FILED<F1>'

WRITE A SELECT QUERY AS..

SELECT * FROM TAB1 UP TO 1 ROW WHERE FILED <x> IN S_FILED<X>.

IF SY-SUBRC<> 0.

MESSAGE e001(00) WITH S_FIELD1

ENDIF.

REAPEAT ABOVE CODE FOR ALL THE FILEDS IN RESPECTIVE AT SELECTION SCREEN ON ...EVENT.

IF U HAVE THE SAME TABLE , THINK OF WRITING ONE SUBROUTINE AND PASS THE SELCT OPTION ONLY AS PARAMETER.

SO EACH TIME JUST CALL THE SAME SUBROUTINE.

THIS WILL GIVE YOU MODULERISED CODE AND SOLVE YOUR PURPOSE TO..

Read only

Former Member
0 Likes
675

Also we need not to check for high and low value , system automatically detects the same.