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: 

pass 2 values in a variable.

Former Member
0 Kudos

Hi ABAPers,

This is my requirement.

(three radio buttons defined )

PARAMETERS: rb_c1 radiobutton group rb1. **zero

PARAMETERS: rb_c2 radiobutton group rb1. **one

PARAMETERS: rb_c3 RADIOBUTTON GROUP rb1. **both

if rb_c1 = 'X'.

funct = '0'.

perform goods_1.

(the form goods_1 fetches data from a table corresponding to the value of u201Cfunctu201D)

elseif rb_c2 = 'X'.

funct = '1'.

perform goods_1.

else .

funct = ***********************

((here I want to pass both 0 and 1 to funct,so that it fetches all the records with respect to both u20190u2019 and u20181u2019 from the table ))

perform goods_1.

ENDIF.

Is it Possible ?

1 ACCEPTED SOLUTION

h_senden2
Active Contributor
0 Kudos

You can only put 1 value in a variable.

You have to define an internal table for storing the 2 values.

regards,

hans

9 REPLIES 9

Former Member
0 Kudos

Hi Adhi,

How can you store two values in a single variable at a time. Better you go another logic.

....

elseif rb_c2 = 'X'.

funct = '1'.

perform goods_1.

else .

Use select statement here based on condition where funct ='0' or funct = '1'.

Thanks

Nitesh

h_senden2
Active Contributor
0 Kudos

You can only put 1 value in a variable.

You have to define an internal table for storing the 2 values.

regards,

hans

matt
Active Contributor
0 Kudos

>

> You can only put 1 value in a variable.

>

> You have to define an internal table for storing the 2 values.

>

> regards,

> hans

Or you could use a structure with 2 fields.

BEGIN OF my_struc,
  field1 TYPE c,
  field2 TYPE c,
END OF my_struc.

If you really want two values, you'll have to wait for the development of quantum computing and use quantum superposition.

matt

Former Member
0 Kudos

hi deepan,

instead, you use range table when you are passing two values to functional module.

for as it is solution is call that function module twice by giving two values as constants to function module.

Thanks & Regards,

Pavan

Former Member
0 Kudos

hi

You can do in this way..

types:

BEGIN OF x_f,

sign(1) TYPE c, "inclusive/exclusive

option(2) TYPE c, "less/greater/between/eq

low TYPE ebeln, "starting value.

high TYPE ebeln, "ending value

END OF x_f.

data: i_f TYPE STANDARD TABLE OF x_f,

wa_f type x_f.

..............

...................

else.

wa_f-low = '0'.

append wa_f to i_f.

wa_f-low = '1'.

append wa_f to i_f.

Now in the selection logic in the where condition use ....... field in i_F instead of field = func.

Former Member
0 Kudos

tables : VBAK.

ranges : func for VBAK-VBTYP.

PARAMETERS: rb_c1 radiobutton group rb1. **zero

PARAMETERS: rb_c2 radiobutton group rb1. **one

PARAMETERS: rb_c3 RADIOBUTTON GROUP rb1. **both

if rb_c1 = 'X'.

funct-low = '0'.

funct-sign = 'I'.

funct-option = 'EQ'.

append funct.

clear funct.

perform goods_1.

(the form goods_1 fetches data from a table corresponding to the value of u201Cfunctu201D)

elseif rb_c2 = 'X'.

funct-low = '1'.

funct-sign = 'I'.

funct-option = 'EQ'.

append funct.

clear funct.

perform goods_1.

else .

funct-low = '0'.

funct-sign = 'I'.

funct-option = 'EQ'.

append funct.

clear funct.

funct-low = '1'.

funct-sign = 'I'.

funct-option = 'EQ'.

append funct.

clear funct.

perform goods_1.

ENDIF.

Former Member
0 Kudos
*--global data declaration---------------*
types : begin of st_fun,
          func type c,
        end of st_fun.
data : t_fun type standard table of st_fun,
          s_fun type st_fun.   
*------------------------------------------------*
PARAMETERS: rb_c1 radiobutton group rb1, 
            rb_c2 radiobutton group rb1,
            rb_c3 RADIOBUTTON GROUP rb1. 

if rb_c1 = 'X'.
       s_fun-funct = '0'.
       append s_fun to t_fun.
       perform goods_1.

elseif rb_c2 = 'X'.
       s_fun-funct = '1'.
       append s_fun to t_fun.
       perform goods_1.

else .
       s_fun-funct = '0'.
       append s_fun to t_fun.

       s_fun-funct = '1'.
       append s_fun to t_fun.
       perform goods_1.
endif.

form goods_1. " +you can use tables tt like t_fun but not needed as declared globally.+
*----------------
*--------------------
*-------------------
         select aa bb cc from xyz 
                                into table t_table
                                for all entries in t_fun
                                where func = t_fun-func.
         if sy-subrc <> '0'
             "--------
*--------------------
         endif.
endform.

hope this will help... there are so many methods.. you can also use that select option method as already mentioned in this thread...

Former Member
0 Kudos

Hi,

No,you cannot assign two values to a variable but can simply do like this:

data: i_funct type standard table of funct,

wa_funct like line of i_funct.

if rb_c1 = 'X'.

funct = '0'.

append funct to i_funct.

perform goods_1 using i_funct.

elseif rb_c2 = 'X'.

funct = '1'.

append funct to i_funct.

perform goods_1 using i_funct.

else .

wa_funct-funct = '0'.

append wa_funct to i_funct.

wa_funct-funct = '1'.

append wa_funct to i_funct.

perform goods_1 using i_funct.

endif.

form good_i using .....

select ..........

from ........

into table .......

where funct in i_funct. "even in case it has only one value(0/1) it will give the desired output

endform.

Former Member
0 Kudos

THANKS FOR THE REPLIES.....