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: 

wild card and given value

Former Member
0 Kudos
144

hi all,

I am trying to fetch data from table PKHD which is based on certain criteria,

lets say matnr,

so wat i want is i want to write a select query that is kind of dynamic,

so when user provides matnr then query shud look for that matnr, when nt then query shud look for all matnr,

i believe i shud use range, problme is there wud many criteria nt only matnr hence i cannot write two queries checking if matnr is provided or nt,

will wait for ur expert opinion

thnaks,

RS

1 ACCEPTED SOLUTION

Former Member
0 Kudos
105

Hi,

If you are passing matnr from selection screen P_MATNR if there is some bvalue it will fetch that particular value it there is no value it will fetch all the records.

Select * from mara into table itab where matnr = P_matnr.

If P_MATNR - is initial it will fetch all values

If p_MATNR = 001 it will fetch 001 only.

Reward if helpful.

9 REPLIES 9

Former Member
0 Kudos
106

Hi,

If you are passing matnr from selection screen P_MATNR if there is some bvalue it will fetch that particular value it there is no value it will fetch all the records.

Select * from mara into table itab where matnr = P_matnr.

If P_MATNR - is initial it will fetch all values

If p_MATNR = 001 it will fetch 001 only.

Reward if helpful.

0 Kudos
105

no uma shankar, i m trying to use it in function module,

thanks

Former Member
0 Kudos
105

Hi reena,

1. for this purpose, one option is

2. suppose in that table,

there are 5 different fields, on which basis the user can search.

3. so in the selection screen give 5 SELECT Options.

4. While writing query,

just give

where field1 in selopt1

and field2 in selopt2

and field3 in selopt3

... and so on till 5.

5. It will automatically check,

if selopt1 is BLANK, - it means all record.

and so on..

6. So if user enter Nothing, ALL Records will come,

if user enters field 3 ONLY, then only those records will come

7. If user enter field 1 and field 3,

then records matching field1 & field 3 will come.

like this... and son.

regards,

amit m.

0 Kudos
105

forgot to mention amit, m trying this in function module,

ne suggestions???

thanks

0 Kudos
105

Hi again,

1. No problem, if u are using FM.

2. Use the TABLES parameter

to pass the select options.

3. eg.

there is one select option on screen for BUKRS.

then the corresponding FM, should have in TABLES Parameter,

BUKRS LIKE RSOBUKRS.

(RSOBUKRS is a strucutre having 4 fields just like select option/ranges)

This is the kind of logic, which one should follow

while passing select options to FM.

4. Similarly for other fields, u may find in se11,

some other similar structure or Range Structure for that field.

regards,

amit m.

Former Member
0 Kudos
105

Hi,

I didnt undrsatan what you are expecting can you please be more elobarate ablout your requirement.

0 Kudos
105

ok i m trying to generate a function module that fetches data from table PHKD,

now the problem I m facing is my clients said that he can specify either of 5 fields as selection criteria when he calls the FM,

so i cant use the select options!!

is it okay or shud i explain more??

thanks

0 Kudos
105

Hi,

In the function module import parameters select the flag optional for the fields that are optional to be given.

Hope this will solve yoyur problem.

Reward if helpful.

0 Kudos
105

i do understand that providing input is optional using that option tick in SE37, but my point is something different