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

Populating select-options through code

Former Member
0 Likes
6,624

Hi Experts,

I have a requirement like in my selection screen I will have a select-options which will be input disabled. But in the initialization event I want to populate some values through coding. How can I populate multiple values. I should not use variant. I have to code only.

Expecting your help,

Venkatraman.

1 ACCEPTED SOLUTION
Read only

Former Member
3,373

there are four fields of a select option.

SIGN

OPTION

HIGH

LOW

select options are tables with header line.

say you write like :

select-options s_unam for sy-uname. "just press F1 on select-option to know what values to pass

INITIALIZATION.
p1-sign = 'I'. "another option is 'E'.
p1-OPTION = 'BT'. "you can put 'EQ'
p1-low = 'ZA'.
p1-high = 'ZZ'.
APPEND p1.

START-OF-SELECTION.
...
..

Edited by: Soumyaprakash Mishra on Sep 2, 2009 8:41 AM

5 REPLIES 5
Read only

Former Member
3,374

there are four fields of a select option.

SIGN

OPTION

HIGH

LOW

select options are tables with header line.

say you write like :

select-options s_unam for sy-uname. "just press F1 on select-option to know what values to pass

INITIALIZATION.
p1-sign = 'I'. "another option is 'E'.
p1-OPTION = 'BT'. "you can put 'EQ'
p1-low = 'ZA'.
p1-high = 'ZZ'.
APPEND p1.

START-OF-SELECTION.
...
..

Edited by: Soumyaprakash Mishra on Sep 2, 2009 8:41 AM

Read only

Former Member
0 Likes
3,373

Hi Venkatraman,

In intialization event .

you should build range.

e.g.

select-option : s_matnr for mara-matnr.

Initialization.

s_matnr-low = 'M1'.

s_matnr-high = 'M1'.

s_matntr-option = 'BT'.

s_matnr-sign = 'I'.

append s_matnr.

clear s_matnr.

then use this in select query.

Hope this is useful for you.

Regards,

Vijay

Read only

GauthamV
Active Contributor
0 Likes
3,373

Try like this.


Tables: mara.

select-options: matnr for mara-matnr.

INITIALIZATION.

 matnr-sign = 'I'.
 matnr-option = 'BT'.
 matnr-low = '0000000001'.
 matnr-high = '0000000010'.
 append matnr.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.
    IF screen-name CS 'MATNR'  .
      screen-input = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

Read only

venkat_o
Active Contributor
0 Likes
3,373

Hi Venkatraman, Try this way.


REPORT ztest_notepad.
TABLES marc.
SELECT-OPTIONS : s_werks FOR marc-werks.

INITIALIZATION.
  s_werks-low    = 'CMM1'.
  s_werks-sign   = 'I'.
  s_werks-option = 'EQ'.
  APPEND s_werks.
  CLEAR  s_werks.

  s_werks-low    = 'CMM2'.
  s_werks-sign   = 'I'.
  s_werks-option = 'EQ'.
  APPEND s_werks.
  CLEAR  s_werks.
AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name EQ 'S_WERKS-LOW' OR
       screen-name EQ 'S_WERKS-HIGH'.
      screen-input = '0'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP..
Thanks Venkat.O

Read only

faisalatsap
Active Contributor
0 Likes
3,373

Hi,

As problem has Solved but following my Sample Code can help People who will Search, in fact i am posting this one because it is different from all the previous replies i am using Macro to populate Select-Options or you can do the Same for Ranges.

DEFINE fill_select_options.
  clear: &1.  &1-sign = &2.    &1-option = &3.   &1-low = &4. &1-high = &5.  append &1.
END-OF-DEFINITION.

SELECT-OPTIONS: sodate FOR sy-datum.

INITIALIZATION.

  fill_select_options sodate 'I' 'BT' '20080101' '20080131'.
  fill_select_options sodate 'E' 'BT' '20080110' '20080115'.
  fill_select_options sodate 'I' 'EQ' '20080201' '20080201'.
  fill_select_options sodate 'I' 'EQ' '20080205' '20080205'.

Regards,

Faisal