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 option

Former Member
0 Likes
1,122

Hi,

I have created a select option for project number filed. Now in internal table i have all the projects. I want to display only those project, which user has entered in select option. What is the optimized way to do that, in which i can get all include, exclude, lt, eq,bw, gt, operators. Or if lt, gt, operator are not possible, how can i display only those project which comes into the range. e.g if use has entered 40005 to 40009. How can i loop on this select option to delete irrelavant data.

Thanks,

Message was edited by:

Sal Khan

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
1,068

May be this way.

First select all project related to select option value.


select * from proj into table i_proj where pspnr in s_pspnr.

then


if sy-subrc eq 0.
  loop at i_proj.
     v_tabix = sy-tabix.
     read table i_your_proj_num_int_table with key pspnr = i_proj-pspnr.
     if sy-subrc ne 0.
        delete i_proj index v_tabix. 
     endif.
  endloop.
endif.
" After this i_proj contains the valid project numbers

9 REPLIES 9
Read only

Former Member
0 Likes
1,068

Hi,

You can not loop on Select Option, first you need to pass those Project values to an internal table and can do Loop on that internal table.

Regards,

Satish

Read only

0 Likes
1,068

How can i pass those projects to internal table...

Read only

0 Likes
1,068

You have to delete unwanted projects from the internal table.

Like:

DETELE ITAB WHERE NOT PROJ_NO IN S_PROJNO.

After this statement you will have only those projects in table ITAB which user had entered on the selection screen.

Regards,

Naimesh Patel

Read only

0 Likes
1,068

Types: Begin of ty_proj,

pspnr type proj-pspnr.

end of ty_proj.

Data: IT_PROJ TYPE TABLE OF TY_PROJ,

WA_PROJ TYPE TY_PROJ.

In the selection screen you will provide low and high values, so in your program fetch only those projects from PROJ Table.

Select-options: s_pspnr for proj-pspnr.

Select PSPNR from PROJ into TABLE IT_PROJ where PSPNR in S_PSPNR.

Now you have data in IT_PROJ.

Reward Points if this helps,

Satish

Read only

0 Likes
1,068

Patel,

In operator is not working in delete query. My query is


delete itab where not projn1 in s_proj.

This is not working, infact it's deleting all the records from internal table.

Pls suggest....

Message was edited by:

Sal Khan

Read only

0 Likes
1,068

Hi,

Try this

Data: r_projno type range of <dbfield>.

r_projno-sign = 'E'.
r_projno-option = 'BT'.
r_projno-low = s_proj-low.
r_projno-high = s_proj-high.

Delete itab where projn1 in r_projno.

Regards,

Satish

Read only

former_member194669
Active Contributor
0 Likes
1,069

May be this way.

First select all project related to select option value.


select * from proj into table i_proj where pspnr in s_pspnr.

then


if sy-subrc eq 0.
  loop at i_proj.
     v_tabix = sy-tabix.
     read table i_your_proj_num_int_table with key pspnr = i_proj-pspnr.
     if sy-subrc ne 0.
        delete i_proj index v_tabix. 
     endif.
  endloop.
endif.
" After this i_proj contains the valid project numbers

Read only

Former Member
0 Likes
1,068

Hi try this,

let s_1 has user entered project ids and let itab has all the project IDS.

select-options:s_1 for tab-field no-extension.

loop at s_1-low

loop at itab where itab-field = s_1-low.

itab1-field = itab-field..

append itab1.

endloop.

endloop.

Read only

Former Member
0 Likes
1,068

Hi,

One way to display only selected projects is u can write code as select-options: so_filed for lf_field no-intervals.or no-extensions a parameter type of option will appear in the output screen then giv f4 functionality to it and thn give only tht values u want llike proj1, proj4 only into tht opiotns thn only those enterd projects only will be displayed.

try this for exact syntax check n saplibrary it will surely work.