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

Ranges for screen elements?

naveen_inuganti2
Active Contributor
0 Likes
1,257

Hi.....

Iam Having 4 fields in my screen...

1. date1

2. date2

3. Company code

4. Employee code

Now according to above fields input i have to fill following TABLE CONTROL.

Ok.. We can write select statement with where condition.

As you know we can get any output with following select query if company code is initial.

SELECT  * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE DATE = DATE1
                  AND DATEA = DATE2
                 AND BUKRS = COMPANY CODE
                 AND PERNR = EMPLOYEE CODE.

So My requirement is to get data for 1 input, two inputs, all input and none inputs of above 4 fields..

I mean it has to consider empty field as all entries i.e like empty slect-option...

Thanks,

Naveen.I

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,216

simpliest thig I've ever seen...

declare the above variables as ranges

DATA : range_date TYPE RANGE OF sy-datum, 
range_ccode TYPE RANGE OF bukrs, 
range_pernr TYPE RANGE OF pa0001-pernr.

than assign the values from the screen:

IF date1 IS NOT INITAIL OR
date2 IS NOT INITIAL.
range_date-sign = 'I'.
range_date-option = 'BT'.
IF date1 IS INITiAL.
range_date-low = '19000101'.
ELSE.
range_date-low = date1.
ENDIF.
IF date2 IS INITiAL.
range_date-high = '99991231'.
ELSE.
range_date-high = date2.
ENDIF.
APPEND range_date.
ENDIF.

IF company code IS NOT INITIAL.
range_bukrs-sign = 'I'.
range_bukrs-option = 'EQ'.
range_bukrs-low = company code.
APPEND range_bukrs.
ENDIF.

IF Employee code IS NOT INITIAL.
range_pernr-sign = 'I'.
range_pernr-option = 'EQ'.
range_pernr-low = Employee code.
APPEND range_pernr.
ENDIF.

now you can go with your select:

select *( from dbtable into coreesponding fileds of table itab where date in RANGE_DATE
and bukrs in RANGE_CCODE
and pernr in RANGE_PERNR.

11 REPLIES 11
Read only

Former Member
0 Likes
1,216

In select-option dont give mandatory or obligatory.So it will execute with out input.

Regards:

Prabu

Read only

0 Likes
1,216

Hi.. Prabhu....

Now give me answer for MY question...

Thanks,

Naveen.I

Read only

Former Member
0 Likes
1,216
Read only

Former Member
0 Likes
1,216

Create all parameters as select options with no-interval no-extension and modify code as below

SELECT * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE DATE in DATE1

AND DATEA in DATE2

AND BUKRS in COMPANY CODE

AND PERNR in EMPLOYEE CODE.

Regards

Sathar

Read only

Former Member
0 Likes
1,216

Hi naveen,

Declare all the screen fields as select-options .Empty select-options is equivalent to selecting all entries.Then modify your copde as below.

SELECT  * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE DATE IN DATE1
                              AND DATEA IN DATE2
                              AND BUKRS INCOMPANY CODE
                              AND PERNR IN EMPLOYEE CODE.

Best of luck,

Bhumika

Read only

Subhankar
Active Contributor
0 Likes
1,216

Hi..

One thing you can do is make all field as select options.

If these are parameter make range table for each field.

r_date1 type range of date1.

;

Make the select statement as..

SELECT * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE DATE in R_DATE1...............> use IN staement

AND DATEA in R_DATE2

AND BUKRS IN R_COMPANY CODE

AND PERNR in R_EMPLOYEE CODE.

Read only

Former Member
0 Likes
1,216

Hi,

If you want to fill table control with your requirement then its easy...

Just define four ranges as per your requirement..

RANGES for

1. date1 : DT1

2. date2 : DT2

3. Company code : COCODE

4. Employee code : EMPCODE

now fill the ranges if input is passed.. otherwise it will be blank..

then use this ranges in your select querry...

SELECT * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE DATE in DT1

AND DATEA in DT2

AND BUKRS in COCODE

AND PERNR in EMPCODE.

Hope it will help you...

Regards,

Meet

Read only

0 Likes
1,216

Hi....

My problem not solved

Yes we can do it select-options...

But here in my case those are not select options they are just screen elements.

And...

Ranges is also not working for my reuirement...

What is happening is...,

If i leave all fields or one of those is as empty its not giving any output...

Because one if range table is empty...

Here my select statement with ranges...

select *( from dbtable into coreesponding fileds of table itab where date in RANGE_DATE

and bukrs in RANGE_CCODE

and pernr in RANGE_PERNR.

Let me know what I have to do....???

If I dont want to modify my screen elemnts as slect-options, then is it not possible...???

Once again my requirement is....

I wnat to get data from database table by checking three fields in where condition... where those three are 
screen fields...'
And now iam getting data if i enter three inputs...
Not for None...
Not for any one...
Not for any two inputs...
But I want that...!!!
How???
( We can use more than 6 select statement with IF condition , But is it proper way? )

Thanks,

Naveen.I

Read only

former_member217544
Active Contributor
0 Likes
1,216

Hi Naveen,

Try this way. I think it will work out.


DATA: v_where type string,
          lv_variable(1) type c.

if date1 is not initial.

lv_variable = 'X'.
concatenate ' date = date1'
                   v_where 
            into  v_where
separated by space.
 
endif.

if date2 is not initial.
if lv_variable = 'X' .
 concatenate v_where
                    ' and datea = date2'
             into v_where
  separated by space.

else.
lv_variable = 'X'.
concatenate ' datea = date2'
                   v_where 
            into  v_where
separated by space.   

endif.
endif.

if COMPANY CODE is not initial
if lv_variable = 'X'.

 concatenate v_where
                    ' and BUKRS = COMPANY CODE'
             into v_where
  separated by space.

else.
lv_variable = 'X'.
concatenate ' BUKRS = COMPANY CODE'
                   v_where 
            into  v_where
separated by space.   

endif.
endif.

Now write the Select Query as



SELECT  * FROM DBTABLE IN CORRESPONDING FIELDS OF TABLE ITAB WHERE (v_where).

Hope this will help.

Regards,

Swarna Munukoti.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,217

simpliest thig I've ever seen...

declare the above variables as ranges

DATA : range_date TYPE RANGE OF sy-datum, 
range_ccode TYPE RANGE OF bukrs, 
range_pernr TYPE RANGE OF pa0001-pernr.

than assign the values from the screen:

IF date1 IS NOT INITAIL OR
date2 IS NOT INITIAL.
range_date-sign = 'I'.
range_date-option = 'BT'.
IF date1 IS INITiAL.
range_date-low = '19000101'.
ELSE.
range_date-low = date1.
ENDIF.
IF date2 IS INITiAL.
range_date-high = '99991231'.
ELSE.
range_date-high = date2.
ENDIF.
APPEND range_date.
ENDIF.

IF company code IS NOT INITIAL.
range_bukrs-sign = 'I'.
range_bukrs-option = 'EQ'.
range_bukrs-low = company code.
APPEND range_bukrs.
ENDIF.

IF Employee code IS NOT INITIAL.
range_pernr-sign = 'I'.
range_pernr-option = 'EQ'.
range_pernr-low = Employee code.
APPEND range_pernr.
ENDIF.

now you can go with your select:

select *( from dbtable into coreesponding fileds of table itab where date in RANGE_DATE
and bukrs in RANGE_CCODE
and pernr in RANGE_PERNR.

Read only

0 Likes
1,216

Oooops....

My problem solved...

We just need to check that variable empty or not before populating the ranges table.

Because...

If even that ranges table not filling with screen variable, It fillls with SIGN and OPTION...

That is the reason I am getting problem before....

Thank you Eric,

Naveen Inuganti.,