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 logic.

Former Member
0 Likes
1,200

hi masters,

i am bit confused with my logic and need bit your assistence.

i have a selection screen with 8 parameters.

they all are characteristics.

if user inputs on any of the above parameters ex : parameters : origin -07122.

i have written select statement like this

IF NOT origin1 IS INITIAL.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam = origin.

endif.

which is fine...but if the user enters values on all 8 parameters how could be the select statement?

thank you,

pasala.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,165

Hi ,

it should be

IF NOT origin1 IS INITIAL.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam = origin and/or

atnam = origin2 and/or

atnam = origin3 and/or

...

...

atnam = origin7 and/or

atnam = origin8.

endif.

Its very basic question , but just to assist you , have replied.

Hope this is helpful,

Regards,

Uma Dave

9 REPLIES 9
Read only

Former Member
0 Likes
1,165

can i know the variable is origin or orgin1?

Read only

Former Member
0 Likes
1,165

Hi,

Just want to know all the fields are from the CABN table? . If so you can pass all the parameters to the same selection query.

Just replace that corresponding fields into table with proper internal table . That will give you performance issue.

parameters : a type (anything),

b type (anything),

c type (anything),

-


i type (anything).

select (fields) from table into (internal table) where (this ) = a and

(this ) = b and

-


(this ) = i.

With Regards,

Sumodh.P

Read only

Former Member
0 Likes
1,166

Hi ,

it should be

IF NOT origin1 IS INITIAL.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam = origin and/or

atnam = origin2 and/or

atnam = origin3 and/or

...

...

atnam = origin7 and/or

atnam = origin8.

endif.

Its very basic question , but just to assist you , have replied.

Hope this is helpful,

Regards,

Uma Dave

Read only

0 Likes
1,165

hi Uma,

i have 12 parameters, like

1 desti 2 origin 3 ccode 4 citem 5 tcatg 6 using 7status 8custm 9reqdat 10expid 11 impld .12 sapnu

they all are characteristics.

if the user enters values on any of the above parameters it should go to CABN and fetch and store in LT_CABN.

At the initial stage all of them will have values as they are characteristics.

what i have done was i have created 12 variables where their will be no value unless user enters.

so that ...is the reason i have given the select statement like this.

IF NOT origin1 IS INITIAL.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam = origin.

elseIF NOT ccode1 IS INITIAL.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam = ccode.

endif.

but if any of the above parameter is successfull it does not look at the below as i have given ELSEIF.

How can i write the logic to look at all the parameters.. i hope i make sense here.

thank you.

Read only

0 Likes
1,165

All of them refer to the same field? That is the atnam field , then instead of using parameters u can use select-options. U can enter multiple values like 8 values there itself and use the query for atnam in Select-options. it will solve ur problem

Read only

0 Likes
1,165

Hi Bhaskar,

parameters : a type atnam, 
           .b type atnam . " etc

data : r_atnam type range of atnam with header line.

refresh r_atnam.
clear r_atnam.

r_atnam-sign = 'I'.
r_atnam-option = 'EQ'.
r_atnam-low = a.
append r_atnam.
clear r_atnam-low. " Clear only LOW
r_atnam-low = B.
append r_atnam.
clear r_atnam-low. "
r_atnam-low = C. "Etc
append r_atnam.
clear r_atnam-low. " Clear only LOW
                    
"or
you can directly take single select-option
tables cabn.
select-options s_atnam for cabn-atnam.
now 

select atinn atnam
from cabn into corresponding fields of table lt_cabn
where atnam in r_atnam. " If you take SELECT-OPTINS replace r_atnam with s_atnam

Then when you want the values
read table lt_cabn into wa_cabn with key atnam = A " The value entered in Parameter
read table lt_cabn into wa_cabn with key atnam = B " Etc

Cheerz

Ram

Read only

0 Likes
1,165

Hello

Try this logic:


ranges: r_atnam for cabn-atnam.
r_atnam-sign = 'I'.
r_atnam-option = 'EQ'.
if not desti is initial.
  r_atnam-low = desti. append r_atnam.
endif.
if not origin is initial.
  r_atnam-low = origin. append r_atnam.
endif.
*" and so on for other parameters
SELECT atnam
atinn
FROM cabn
INTO CORRESPONDING FIELDS OF TABLE lt_cabn
WHERE atnam in r_atnam. " in ranges. You write only one SELECT

Read only

0 Likes
1,165

Hi Pasalabasker,

Please try to explain ur requirement , Its not clear to me now.

Please elaborate broadly so that I can help you.

If all the 12 parameters are declared as select option then you can compare them one by one in 1 select query as shopwn in my previous post.

If they are not present on your selection screen , then

create a range and populate these 12 values in that range and then use that range in select query.

Regards,

Uma Dave.

Edited by: UmaDave on Jun 21, 2010 10:04 AM

Read only

arul_murugan
Active Participant
0 Likes
1,165

Hi,

You can use select-options instead of parameter and use no-extension, no intervals.

select-options: origin for (dataelemet) no-extension no intervals.

SELECT atnam

atinn

FROM cabn

INTO CORRESPONDING FIELDS OF TABLE lt_cabn

WHERE atnam in origin

and (other selection screen input)

I think it will help u

Thanks

Arul