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 from parameters.

SG141
Active Participant
0 Likes
819

In the selection screen if the user enters any number from 01 - 20 in a particular field 'A'

Let's say the user enters n (1-20)

Based on that in the select query I have to extract A1,A2,A3,...,An and add all these into a single field a.

How can achieve it???

8 REPLIES 8
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
786

Hi,

Try this.

data c1(10).

data a1 type i.

select-options s1 for c1.

loop at s1.

concatenate 'A' s1-low into s1-low.

concatenate 'A' s1-high into s1-high.

modify s1 index sy-tabix transporting low high.

endloop.

select sum (f1) from db into A where f1 in s1.

Read only

Former Member
0 Likes
786

Please create an dataelement and domain ... that domain should have the value table ... in the value table (1-20) -> (A1-A20) ... so that if you se this dataelement as parameter in the Program then you will get it as you want .

So

dataelement : ztest

domain : ztest -> value table with key and text as (1-20) & (A1-A20) .

so in program :

parameters : s_test for table-ztest .

reward points if it is usefull .....

Girish

Read only

Former Member
0 Likes
786

karthik,

Say

DATA : A type i.

Parameters : v_num type i.

START-OF-SELECTION.

Select A1,A2,A3,...,An from source and a structure(v_struc) which is having the same structure of A1,A2,A3,...,An and

A = v_struc-A1 + v_struc-A2 + v_struc-A3 ................ v_struc-An.

Don't forget to reward if useful.....

Read only

SG141
Active Participant
0 Likes
786

n is a variable here.

Read only

0 Likes
786

Hi Karthik,

Whethere the n will be a parameter or select-option on the screen. As you written it as parameter? then at any time it will have a single value so no need to sum A<i><b>n</b></i> into another variable.

Regards,

Atish

Read only

SG141
Active Participant
0 Likes
786

let'ss say n is 5 then I have to add a1a2ab3a4a5. display this sum.

Read only

0 Likes
786

Hi Karthik,

try something like this,

lv_test type <A1>,

lv_test type <A1>.

parameters p_no TYpe char2.

concatenamet 'A' p_no into lv_test.

select * from DBtable into itab

where <a* varibale> between A1 AND lv_test.

Now

loop at itab.

lv_sum = lv_sum + itab<afield>.

endloop.

Regards,

Atish

Read only

Former Member
0 Likes
786

Hi,

parameters:n type i.

data:res type i.

data:begin of itab,

a1 type i,

a2 type i,

a3 type i,

...

...

a20 type i.

end of itab.

itab-a1 = 3.

itab-a2 = 4.

itab-a3 = 5.

FIELD-SYMBOLS: <wa> TYPE ANY,

<comp> TYPE ANY.

ASSIGN itab TO <wa>.

do n times.

ASSIGN COMPONENT sy-index OF STRUCTURE <wa> TO <comp>.

res = res + <comp>.

enddo.

write:/ res.

rgds,

bharat.