Application Development 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: 

SELECT-OPTIONS - How to get the output other than of the mentioned range

Former Member
0 Kudos

Hi Friends,

I need the output in my ABAP Query to display entries out of the date range that I enter in the selection screen.

Supose I enter Date: 1st Jan 09 to 15th Apr 09, I should get an output out of this range.

How do I do that with select options ? what do I give in the date-option and date-sign, etc., ?

Please help.

Thanks,

Dikshitha

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi!

on your selection screen in the side there is a icon of '->' if u click on it a screen comes where u can give multiple different selections.

There in 'Exclude Ranges' tab u can give the date range that u want to exclude and then execute your program....those dates will be excluded in your output.

or else u can directly do it in the program in initialization event.....

s_carrid-sign = 'E'.

s_carrid-low = '20090101'.

s_carrid-option = 'BT'.

s_carrid-high = '20090415'.

append s_carrid.

Edited by: Richa Tripathi on Apr 15, 2009 11:23 AM

12 REPLIES 12

Former Member
0 Kudos

Hi,

Date option should be 'BT' and Date sign should be 'E'.

Low value should be the first value (from date). High value should be the second value (To value).

Best Regards,

Suresh

former_member203501
Active Contributor
0 Kudos

hi i think we can use like this ...

r_range-sign = 'E'. <----


exclude

r_range-low = 'Value1'.

r_range-option = 'BT'.

r_range-high = 'Value2'.

append r_range.

faisal_altaf2
Active Contributor
0 Kudos

Hi,

Use NOT IN like bellow.

TABLES: kna1.
SELECT-OPTIONS: sokunnr FOR kna1-kunnr.

DATA: it_kna1 LIKE STANDARD TABLE OF kna1 WITH HEADER LINE.

SELECT * FROM kna1
  INTO CORRESPONDING FIELDS OF TABLE it_kna1
  WHERE kunnr NOT IN sokunnr.

Best Regards,

Faisal

Former Member
0 Kudos

Hi,

USe the following piece of code


TYPE-POOLS : SCCR.
DATA : g_optlist TYPE sscr_opt_list,
       g_ass TYPE sscr_ass.


INITIALIZATION.
  CLEAR g_ass.
  g_ass-kind    = 'S'.
  g_ass-name    = 'S_USER'. "select-option field
  g_ass-sg_main = 'I'. " this u can change to exclude ur values accordingly
  g_ass-op_main = 'TEXT'.
  APPEND g_ass TO g_t_restrict-ass_tab.

  g_optlist-name = 'TEXT'.
  g_optlist-options-ne = 'X'.
  g_optlist-options-eq = 'X'.
  APPEND g_optlist TO g_t_restrict-opt_list_tab.

  CALL FUNCTION 'SELECT_OPTIONS_RESTRICT'
    EXPORTING
      restriction            = g_t_restrict
    EXCEPTIONS
      too_late               = 1
      repeated               = 2
      selopt_without_options = 3
      selopt_without_signs   = 4
      invalid_sign           = 5
      empty_option_list      = 6
      invalid_kind           = 7
      repeated_kind_a        = 8
      OTHERS                 = 9.

Former Member
0 Kudos

'BT' in option and 'E' in sign gives me 'No data selected'.

Thanks,

Dikshitha

Former Member
0 Kudos

Hi!

on your selection screen in the side there is a icon of '->' if u click on it a screen comes where u can give multiple different selections.

There in 'Exclude Ranges' tab u can give the date range that u want to exclude and then execute your program....those dates will be excluded in your output.

or else u can directly do it in the program in initialization event.....

s_carrid-sign = 'E'.

s_carrid-low = '20090101'.

s_carrid-option = 'BT'.

s_carrid-high = '20090415'.

append s_carrid.

Edited by: Richa Tripathi on Apr 15, 2009 11:23 AM

Former Member
0 Kudos

Hi SAP USER,

There is no type pool SCCR. Is there anyting else I can use other than SCCR ?

Thanks,

Dikshitha

I355602
Advisor
Advisor
0 Kudos

Hi,

>

> I need the output in my ABAP Query to display entries out of the date range that I enter in the selection screen.

>

> Supose I enter Date: 1st Jan 09 to 15th Apr 09, I should get an output out of this range.

>

Refer:-


SELECT-OPTIONS : s_datum FOR <db_table>-<field_name>.

SELECT <field 1> <field 2> ... <field n>
FROM <db_table>
INTO TABLE <internal_table>
WHERE <date_field_name> NOT IN s_datum.

IF sy-subrc NE 0.
  MESSAGE 'No records found.' TYPE 'E'.
ENDIF.

This will return records which dont like in the date range, that you specified on the selection screen.

Hope this helps you.

Regards,

Tarun

Former Member
0 Kudos

Hi,

You can simply use a select query with "where date not in <select option range>".

Former Member
0 Kudos

Hi,

This Eg may help you,

SELECTION-SCREEN BEGIN OF BLOCK ABC WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS date for ZACCIDENT-doa.

SELECTION-SCREEN END OF BLOCK ABC.

data itab like ZACCIDENT OCCURS 100 WITH HEADER LINE.

*

select * from ZACCIDENT into CORRESPONDING FIELDS OF TABLE itab where doa not BETWEEN date-low

and date-high.

Use select query in this manner.

Regards,

Himanshu

Former Member
0 Kudos

Hi,

You can create a range for this kind of requirement,



data: r_date type sy-datum.

Initialization.
r_date-low = 'lower date value'.
r_date-high = 'higher date value'.
r_date-sign = 'BT'.

append r_date.

And you can use this range further according to your reqmt.

Hope it helps

Regards

Mansi

former_member181962
Active Contributor
0 Kudos

Hi Dikshita,

If you have defined a select-option for your date field,

you can directly enter the range that you want to exclude in the 4th tab of the select option(PRess F4) and go to the 4th tab Exclude selections). NO Need to code any thing.

Regards,

Ravi