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

Function Module

Former Member
0 Likes
613

hi friends,

iam declaring company code as import parameter in function module. later on iam calling that fuction module in report. but i declared company code as select-options. it is giving error. if iam declaring company code as a parameter then it is working.

pls, let me know how to declare it as select-options.

chandu

6 REPLIES 6
Read only

Former Member
0 Likes
565

Use below code

Select bukrs from t001 into i_t001 where bukrs in s_bukrs (ur select option.

check sy-dbcnt gt 0.

Loop at i_t001.

call function 'UR FUNCTION'

exporting

bukrs = i_t001-bukrs

Endloop.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
565

Defining as a select-option, you are giving the user the opportunity to enter mulitple company codes and ranges or even excluding. Do you want to fire this function module for all company codes which are valid for the select-option? If so, then you need to get all of the company codes in the SO, and loop thru that table.

data: it001 type table of t001 with header line.
select-options: s_bukrs for it001-bukrs.

select * into table it001 from t001
         where bukrs in s_bukrs.

loop at it001.
* Call your function module with 
* the company code in this table.
*  IT001-bukrs.
endloop.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
565

do like this:

data: begin of it_t001 occurs 0,

bukrs type bukrs,

end of it_t001.

select bukrs

from t001

into it_t001

where bukrs in s_bukrs.

loop at it_t001.

call function '<func mod name>'

exporting <comp code> = it_t001-bukrs.

endloop.

Regards,

Ravi

Read only

Former Member
0 Likes
565

Hi chandra,

1. in the FM,

pass the parameter in

TABLES (not IMPORT)

2. and make it like this.

<b>BUKRS LIKE RNG_BUKRS</b>

(In TABLES Tab of se37)

<b>NOTE:

RNG_BUKRS is nothing but a RANGE for BUKRS,

which is nothing but copy of

select-option for bukrs field.</b>

3. then while calling the FM,

pass the select-option (eg. MYBUKRS)

using TABLES (and not EXPORTING)

4. In this way, in your FM,

u shall be able to fire query

IN BUKRS

(similar to select-option)

regards,

amit m.

Read only

Manohar2u
Active Contributor
0 Likes
565

1. Select company code entries into ITAB.

2. change FM's signature as

import to tables for company code.

3. Pass the table to FM

4. Change the logic in FM to handle for multiple company codes.

Regds

Manohar

Read only

Former Member
0 Likes
565

Hi chandra,

Instead of using IMPORT use TABLES in the FM created by you.

IMPORT is used when only one value has to be passed.

Since you are using select-option, there will be n number of entries

You will need to use a LOOP in your FM and change the code accordingly.

Regards,

Sameena