on 03-03-2009 4:07 PM
Hi all,
I want to pass the values entered in the select options to the function module. How should my function module interface be declared for passing the select options
I tried declaring like
t_range type data in the tables tab. But this throws error.
Please let me know how to pass select option values back to function modules.
Thanks,
Try this!
This in your program/report.
SELECT-OPTIONS: s_vbeln for VBAP-VBELN.
INITIALIZATION.
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = SPACE.
s_vbeln-high = SPACE.
append s_vbeln.
START-OF-SELECTION.
CALL FUNCTION 'ZRT_TRYING_SELECTOPTIONS'
EXPORTING
sign = s_vbeln-sign
option = s_vbeln-option
LOW = s_vbeln-low
HIGH = s_vbeln-high
tables
itab = ITAB
.
Declare this as importing parameters in your function module:
*" IMPORTING
SIGN TYPE RALDB-SIGN
OPTION TYPE RALDB-OPTION
LOW TYPE VBAP-VBELN OPTIONAL "Low and High can be declared as elementry data type or like I
HIGH TYPE VBAP-VBELN OPTIONAL "have done here.
RANGES: s_vbeln for vbap-vbeln.
s_vbeln-sign = sign.
s_vbeln-option = option.
s_vbeln-low = low.
s_vbeln-high = high.
append s_vbeln.
SELECT VBELN POSNR MATNR ERNAM ERDAT
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE VBELN in s_vbeln.
Let me know any other clarification you need!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
>
> START-OF-SELECTION.
> CALL FUNCTION 'ZRT_TRYING_SELECTOPTIONS'
> EXPORTING
> sign = s_vbeln-sign
> option = s_vbeln-option
> LOW = s_vbeln-low
> HIGH = s_vbeln-high
> tables
> itab = ITAB
> .
This would only work for a parameter, but not a true select-option.
There is a much easier way. You can declare a special type of data dictionary table type that is a range object. You can then use this DDic object in function module or method interfaces. The resulting ABAP internal table that is declared from this data dictionary object can be treated like a normal select-option (IE you can use the IN statement in SQL with it).
Here is the online help link that describes how to create a range table type:
http://help.sap.com/saphelp_nw70ehp1/helpdata/en/00/958fb7e42b11d295f700a0c929b3c3/frameset.htm
Resolved. Delcared the fm interface parameters as type ref to data..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the code that Manoj posted, If no value has been entered in the select option fields
then I am getting an error "Field symbol not assigned". How can we resolve that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Check this code.
data: node_flights type ref to if_wd_context_node.
data: rt_carrid type ref to data.
data: rt_connid type ref to data.
data: isflight type table of sflight.
data: wsflight type sflight.
field-symbols: <fs_carrid> type table,
<fs_connid> type table.
Retrieve the data from the select option
rt_carrid = wd_this->m_handler->get_range_table_of_sel_field(
i_id = 'S_CARR_ID' ).
if rs_carrid is not initial. Here you can check that if rs_carrid is no initial then assign value of field symbol
Assign it to a field symbol
assign rt_carrid->* to <fs_carrid>.
endif.
Retrieve the data from the select option
rt_connid = wd_this->m_handler->get_range_table_of_sel_field(
i_id = 'S_CONN_ID' ).
if rt_connid is not initial. Here you can check that if rt_connid is no initial then assign value of field symbol
Assign it to a field symbol
assign rt_connid->* to <fs_connid>.
endif.
if <fs_connid> is not initial and <fs_carrid> is not initial.
Retrieve that data from the database. Normally it is suggested to
encapsulate the data retrieval in a separate class.
For simplicity, the SELECT statement has been implemented here.
clear isflight. refresh isflight.
select * into corresponding fields of table isflight from sflight
where carrid in <fs_carrid>
and connid in <fs_connid>.
endif.
Bind the data to the context
node_flights = wd_context->get_child_node( name = `FLIGHTS` ).
node_flights->bind_elements( isflight ).
Hopes this will helps you.
Regard
Manoj Kumar
Edited by: Manoj Kumar on Mar 16, 2009 10:41 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can pass as Type ref to data
and inside the function module convert it to the range table of your type.
Abhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.