2009 Apr 16 8:14 AM
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.)
2009 Apr 16 8:37 AM
You can use table type/structure for MATNR as range table for apssing to FM.
e.g WSELMATNR ==> Range Table for Material Number
2009 Apr 16 8:39 AM
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.
2009 Apr 16 8:51 AM
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
2009 Apr 16 9:05 AM
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
2012 May 28 1:33 PM
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 ..........
2009 Apr 16 9:12 AM
2012 May 28 1:38 PM
Hi,
To achieve this you may use the standard table type 'EFG_TAB_RANGES'. Hope it helps. Thank you.
Regards,
kartik
2012 May 28 2:06 PM
Hi Kartik,
i am not getting can you please explain little more
Thanks..........
2012 May 28 2:41 PM
Hi,
You can create an importing parameter for your function module of type 'EFG_TAB_RANGES' and send select options to it.
Regards,
kartik