2009 Feb 10 11:19 AM
Hi All,
I am creating one class and I want to pass the select-options parameters directly to it like s_plant,s_mtart etc .
So while specifying these as paramters what type I should give them?
Rgds,
Madhuri
2009 Feb 10 12:04 PM
Is your class locally defined?
if yes, declare select-option parameters before definition of class.
so, that parameters will be visible within the methods of your class
without passing them.
2009 Feb 10 2:12 PM
Hello,
one possible solution:
given select-option in a report :
SELECT-OPTIONS:
s_mblnr FOR gv_mblnr,
s_mjahr FOR gv_mjahr NO INTERVALS NO-EXTENSION.
before calling the select-method:
DATA: lt_sel_mblnr TYPE rseloption.
DATA: lt_sel_mjahr TYPE rseloption.
DATA: ls_sel TYPE rsdsselopt.
LOOP AT s_mblnr.
CLEAR ls_sel.
MOVE-CORRESPONDING s_mblnr TO ls_sel.
APPEND ls_sel TO lt_sel_mblnr.
ENDLOOP.
LOOP AT s_mjahr.
CLEAR ls_sel.
MOVE-CORRESPONDING s_mjahr TO ls_sel.
APPEND ls_sel TO lt_sel_mjahr.
ENDLOOP.
Call the select-method
CALL METHOD gcl_....->get_main_entries
EXPORTING
ir_mblnr = lt_sel_mblnr
ir_mjahr = lt_sel_mjahr
IMPORTING...
The parameters ir_mblnr and ir_mjahr in method get_main_entries are defined to type rseloption.
Then you can use
SELECT * FROM ...... INTO TABLE et_log_1
WHERE mblnr IN ir_mblnr
AND mjahr IN ir_mjahr.
Regards Wolfgang
Edited by: Wolfgang Valtin on Feb 10, 2009 3:13 PM
2009 Feb 11 9:50 PM
Wolfgang is correct - he is using the Data Dictionary type RSELOPTION. Look at it using SE11. You can see it is a table type where the row looks like a select-options row type (sign, option, low, high).
However, the LOW and HIGH in this case are CHAR 45, which may not be good for your program. So create your own structure (sign, option, low, high) in SE11 and make low and high into the correct data types. Next create a table type based on the structure (for example ZSELTAB).
Now, you can give this type in the method signature... be careful though! The original table has a header line, and in a method you are NOT ALLOWED to use tables with header lines... to be safe I would code it like this:
select-options: s1 for <...>.
data: my_zseltab type zseltab.
start-of-selection.
my_zseltab = s1[].
call method ..... exporting in_table = my_zseltab.
In the method code, remember ZDSELTAB has no header line, but you can still use it like a selection table, for example
if field1 IN in_table.
2009 Feb 12 7:02 AM
Hi,
thanks for reply.
So if I have to pass 3-4 fields like, bukrs, vkorg, mtart, prdha, I need to create those many structure and table types?
Can I use the conversion exit to convert that one to input type?
Rgds,
Madhuri
Edited by: madhuri sonawane on Feb 12, 2009 12:32 PM
2009 Feb 12 3:47 PM
Whatever you finally decide upon, you must have a Data Dictionary definition. So either create one for each type (bukrs, vkorg, etc.) or use a general one like RSELOPTION. However with the general one you have to put extra code in the class to convert back from a CHAR 45 field to your special field.
Anyway, using the Data Dictionary is fun! So go create as many new tables as you need. In the long term, the work you do in the Data Dictionary is never wasted and it may save you time in the future when you need that structure / table again for a different program.
Creating these structures and tables is easy if you use shortcuts. For example in local definitions in your program you can code...
data range1 type range of bukrs.
or
data wa_bukrs type bukrs.
ranges range1 for wa_bukrs.
either of these gives you the structure... no need to manually type sign, option, low, high...
What about Global (data dictionary) definitions? yes, there are also shortcuts...
start transaction SE11, enter range table name in the 'Data' field (e.g. ZMYRANGETAB), Hit Create, choose to create a Table Type... now you are on the blank new Maintain Table Type screen. enter a short text for your new table, then choose
Edit->Define as ranges table type
next enter your data element (e.g. BUKRS) under 'data element', hit Save and activate. You just created your range table without manually entering sign, option, low, high...
But wait there's more... on the same screen you can now (after saving the range table) also enter a structure name such as ZMYRANGE in the field 'structured row type'. Hit Create and you are taken to the Maintain Structure screen where the sign, option, low and high are already populated... add a short description and save and activate... you just created a workarea for your range table.
You just created a table type ZMYRANGETAB and a structure ZMYRANGE with minimal effort.
2009 Feb 14 7:59 PM