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: 

Export RANGES to function module

Former Member
0 Kudos
8,354

Can anyone tell, how to pass RANGES to function module.

i have report program in ,

DATA : BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

END OF ITAB.

SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.

I want all the values in S_MATNR in ITAB.

Note that S_MATNR has any value( Include, Exclude,Between, Equal etc.)

9 REPLIES 9

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,275

You can use table type/structure for MATNR as range table for apssing to FM.

e.g WSELMATNR ==> Range Table for Material Number

Former Member
0 Kudos
1,275

Hello


TABLES: MARA.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
END OF ITAB.
DATA: IMARA LIKE MARA OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS : S_MATNR FOR MARA-MATNR.
SELECT * FROM MARA INTO TABLE IMARA WHERE MATNR IN S_MATNR.

LOOP AT IMARA.
  ITAB-MATNR = IMARA-MATNR. APPEND ITAB.
ENDLOOP.

Former Member
0 Kudos
1,275

1) Dictionary Structure SELOPT : Transfer Structure for Select Options.

2) Use it in the Import Parameters in Function Module.

3) Pass S_MATNR to the Function Module in your program.

Regards,

Gurpreet

Former Member
0 Kudos
1,275

Hi,

Define a type in the global data declaration of the function module as follows :


TYPES : BEGIN OF t_range_matnr,
        sign(1) TYPE c,
        option(2) TYPE c,
        low TYPE mara-matnr,
        high TYPE mara-matnr,
END OF t_range_werk.

" Define a table type
types matnr_tab type t_range_matnr occurs 0.

Once done, define the importing parameter of t_matnr in the function modules signature, lets call it matnr

In your program where you would call the function, lets say you have the select option as follows


SELECT-OPTIONS matnr FOR ekpo-matnr.

" In the call function simply pass matnr[]

call function 'select_mara'
 exporting 
   matnr = matnr[].

Done.

P.S. Do not forget the square brackets.

regards,

Advait

Edited by: Advait Gode on Apr 16, 2009 10:05 AM

0 Kudos
1,275

Hi Guys,

This is working to pass the rage to function module

DATA t_matnr TYPE WSELMATNR OCCURS 0 WITH HEADER LINE.

   DATA :  p_labst TYPE mard-labst.

  

   t_matnr-SIGN = 'I'.

   t_matnr-OPTION = 'EQ'.

   t_matnr-LOW = matnr-LOW.

   t_matnr-HIGH = matnr-HIGH.

   APPEND t_matnr.

  

     select sum( labst ) from mard into p_labst

   where matnr in t_matnr and werks = plant.

but i have problem in when i am pass nothing in material ( t_matnr ) and plant = '1010' at that time query returns zero . I want summation of all stock in 'MARD'  against the plant as the query  if we run in the report.

Thanks ..........

Former Member
0 Kudos
1,275

thank you all

Kartik2
Contributor
0 Kudos
1,275

Hi,

To achieve this you may use the standard table type 'EFG_TAB_RANGES'. Hope it helps. Thank you.

Regards,

kartik

0 Kudos
1,275

Hi Kartik,

  i am not getting can you please explain little more

Thanks..........

0 Kudos
1,275

Hi,

You can create an importing parameter for your function module of type 'EFG_TAB_RANGES' and send select options to it.

Regards,

kartik