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

Trivial Problem With Select-option

Former Member
0 Likes
871

Folks,

i am using ABAP-OO and i have not defined Select-option on selection screen rather i have defined parameters.Now once i get input from user i wrote this code to convert parameters into select-option (in internal table).


wa_It_brd_selopt-sign = 'I'.
  wa_It_brd_selopt-option = 'BT'.
  wa_It_brd_selopt-LOW = Stru_Cn_Selcrtr-ca_brand.
  wa_It_brd_selopt-HIGH = Stru_Cn_Selcrtr-ca_brand.
  APPEND wa_It_brd_selopt TO It_brd_selopt.


  wa_It_slsrl_selopt-sign = 'I'.
  wa_It_slsrl_selopt-option = 'BT'.
  wa_It_slsrl_selopt-LOW = Stru_Cn_Selcrtr-ca_slsrl.
  wa_It_slsrl_selopt-HIGH  = Stru_Cn_Selcrtr-ca_slsrl.
  APPEND wa_It_slsrl_selopt TO It_slsrl_selopt.

  wa_It_crtby_selopt-sign = 'I'.
  wa_It_crtby_selopt-option = 'BT'.
  wa_It_crtby_selopt-LOW = Stru_Cn_Selcrtr-ca_crtby.
  wa_It_crtby_selopt-HIGH = Stru_Cn_Selcrtr-ca_crtby.
  APPEND wa_It_crtby_selopt  TO It_crtby_selopt.

inthis way i got select option internal table.


select * from ZNSLVWHDIMMD_LCL
             into corresponding fields of table IT_VIEW
             WHERE SALESRLNO in  It_slsrl_selopt
             and   CREATEDBY in It_crtby_selopt
             and   BRANDID   in It_brd_selopt.

but when i give input to SALESRLNO ,CREATEDBY and BRANDID then and then this selection statement runs and sy-subrc = 0.If i dont give only 2 input it does not work..i dont know why it is happening.It is because its ABAP-OO.I dont have any clue.Please help.Points will be rewarded.

Folks,

i am using ABAP-OO and i have not defined Select-option on selection screen rather i have defined parameters.Now once i get input from user i wrote this code to convert parameters into select-option (in internal table).


wa_It_brd_selopt-sign = 'I'.
  wa_It_brd_selopt-option = 'BT'.
  wa_It_brd_selopt-LOW = Stru_Cn_Selcrtr-ca_brand.
  wa_It_brd_selopt-HIGH = Stru_Cn_Selcrtr-ca_brand.
  APPEND wa_It_brd_selopt TO It_brd_selopt.


  wa_It_slsrl_selopt-sign = 'I'.
  wa_It_slsrl_selopt-option = 'BT'.
  wa_It_slsrl_selopt-LOW = Stru_Cn_Selcrtr-ca_slsrl.
  wa_It_slsrl_selopt-HIGH  = Stru_Cn_Selcrtr-ca_slsrl.
  APPEND wa_It_slsrl_selopt TO It_slsrl_selopt.

  wa_It_crtby_selopt-sign = 'I'.
  wa_It_crtby_selopt-option = 'BT'.
  wa_It_crtby_selopt-LOW = Stru_Cn_Selcrtr-ca_crtby.
  wa_It_crtby_selopt-HIGH = Stru_Cn_Selcrtr-ca_crtby.
  APPEND wa_It_crtby_selopt  TO It_crtby_selopt.

inthis way i got select option internal table.


select * from ZNSLVWHDIMMD_LCL
             into corresponding fields of table IT_VIEW
             WHERE SALESRLNO in  It_slsrl_selopt
             and   CREATEDBY in It_crtby_selopt
             and   BRANDID   in It_brd_selopt.

but when i give input to SALESRLNO ,CREATEDBY and BRANDID then and then this selection statement runs and sy-subrc = 0.If i dont give only 2 input it does not work..i dont know why it is happening.It is because its ABAP-OO.I dont have any clue.Please help.Points will be rewarded.

5 REPLIES 5
Read only

Former Member
0 Likes
776

It does not work because it is searching for blank values.

What you can do is, you can put a condition whether the parameter contains any value or not.

And i assume that it_brd_selopt is a range variable here.

If not, then plz make it a range variable.

if not Stru_Cn_Selcrtr-ca_brand is initial.

wa_It_brd_selopt-sign = 'I'.

wa_It_brd_selopt-option = 'BT'.

wa_It_brd_selopt-LOW = Stru_Cn_Selcrtr-ca_brand.

wa_It_brd_selopt-HIGH = Stru_Cn_Selcrtr-ca_brand.

APPEND wa_It_brd_selopt TO It_brd_selopt.

endif.

Like wise keep condition for all of them.

And one more thing,

rather than using 'BT', you can use 'EQ' like this:

if not Stru_Cn_Selcrtr-ca_brand is initial.

wa_It_brd_selopt-sign = 'I'.

wa_It_brd_selopt-option = 'EQ'.

wa_It_brd_selopt-LOW = Stru_Cn_Selcrtr-ca_brand.

APPEND wa_It_brd_selopt TO It_brd_selopt.

endif.

Read only

Former Member
0 Likes
776

You shouldn't be using regular internal tables as select options. (I'm surprised it doesn't give a syntax error.) Use range tables instead.

Rob

Read only

Former Member
0 Likes
776

You have to check for initial values before you fill the select options.


IF Stru_Cn_Selcrtr-ca_brand IS NOT INITIAL.
 wa_It_brd_selopt-sign = 'I'.
  wa_It_brd_selopt-option = 'BT'.
  wa_It_brd_selopt-LOW = Stru_Cn_Selcrtr-ca_brand.
  wa_It_brd_selopt-HIGH = Stru_Cn_Selcrtr-ca_brand.
  APPEND wa_It_brd_selopt TO It_brd_selopt.
ENDIF.
IF Stru_Cn_Selcrtr-ca_slsrl IS INITIAL.
  wa_It_slsrl_selopt-sign = 'I'.
  wa_It_slsrl_selopt-option = 'BT'.
  wa_It_slsrl_selopt-LOW = Stru_Cn_Selcrtr-ca_slsrl.
  wa_It_slsrl_selopt-HIGH  = Stru_Cn_Selcrtr-ca_slsrl.
  APPEND wa_It_slsrl_selopt TO It_slsrl_selopt.
ENDIF.
IF Stru_Cn_Selcrtr-ca_crtby IS NOT INITIAL.
  wa_It_crtby_selopt-sign = 'I'.
  wa_It_crtby_selopt-option = 'BT'.
  wa_It_crtby_selopt-LOW = Stru_Cn_Selcrtr-ca_crtby.
  wa_It_crtby_selopt-HIGH = Stru_Cn_Selcrtr-ca_crtby.
  APPEND wa_It_crtby_selopt  TO It_crtby_selopt.
ENDIF. 

Read only

0 Likes
776

Folks,

If u search data dictionary then u must have found that if field r empty althoug we get perfect ouput.I want he same..i used the 'EQ' instead of 'BT' and can anyone has code to show how to use range table in ABAP-OO.

Nirad

Read only

Former Member
0 Likes
776

Nirad,

Use ranges Here.

RANGES <rangetab> FOR <f>.

This statement is simply a shortened form of the following statements:

DATA: BEGIN OF <rangetab> OCCURS 0,

sign(1) TYPE c,

option(2) TYPE c,

low LIKE <f>,

high LIKE <f>,

END OF <rangetab>.

Don't forget to reward for all useful answers...