‎2011 Jul 05 8:30 AM
Hi,
how do i specify a table defined in a select option as a range table as input parameter for a method? I can use any table, but thats something i dont want to do in this case.,
‎2011 Jul 05 8:41 AM
Hi.,
In your Method parameters declare only parameter of that type instead of range parameters ., and in method source code you append it to range.
ex:
date type ISH_ANFDT.
and in source code:
data:
RT_RANGES_FDT TYPE RANGE OF ISH_ANFDT,
RS_RANGES_FDT LIKE LINE OF RT_RANGES_FDT.
if date is not initial.
RS_RANGES_FDT-OPTION = 'EQ'.
RS_RANGES_FDT-LOW = date.
RS_RANGES_FDT-SIGN = 'I'.
APPEND RS_RANGES_FDT TO RT_RANGES_FDT.
ENDIF.
hope this helps u.,
Thanks & Regards,
Kiran
‎2011 Jul 05 8:33 AM
Hi,
I am little confused with the question
Does the select option content hold the table name ? Possibilities of multiple entries in select option ?
Please make it clear:)
‎2011 Jul 05 8:39 AM
select-options selcrit for....this creates an internal table selcrit with header line as a global range table . I would lioke to handle that table selcrit in a method, but i dont know how to specify it as an input parameter. Which type do i have to enter?
‎2011 Jul 05 9:02 AM
Hello Rainer,
First-of-all i'm lil' bit surprised that y.o.u are asking this qn
Anyway back to your qn:
select-options s_bukrs for t001-bukrsSo in your class define a pvt. type:
TYPES grt_burks TYPE RANGE OF bukrsand use define your i/p param as
IP_BUKRS TYPE grt_bukrsIn your method call you can pass the select-option as
IP_BUKRS = S_BUKRS[] "Remeber the square bracketsHope this helps.
BR,
Suhas
‎2011 Jul 05 9:06 AM
I implemented following solution when I used Local class within an ABAP program.
Call the function module RS_REFRESH_FROM_SELECTOPTIONS in the constructor method of the class. Whenever the instance of class is created the above function module will return the selection screen components (including the values in select-options).
See the wiki post [ABAP Objects - Accessing selection screen components in Local Class|http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=235963596] for reference.
Regards, Vinod
‎2011 Jul 05 9:30 AM
Hi Vinod,
Good idea
Suhas I thought that OP wanted to pass multiple select options ( dynamically ) with one parameter in the method. You solution will work for only one. Vinod's idea sounds good . Not sure !! Is it not possible by passing the reference and dereferencing it ?
Didn't look at the editor for last 2 months ...
‎2011 Jul 05 9:45 AM
Hello Keshav,
Suhas I thought that OP wanted to pass multiple select-option ( dynamically ) with one parameter in the method
In that case create a data reference parameter & pass the select-option reference to the param:
ip_selcrit TYPE REF TO dataIn the calling program get the reference of select-option:
DATA: gd_selcrit TYPE REF TO data.
GET REFERENCE OF selcrit INTO gd_selcrit& in the method call pass the data ref. gd_selcrit.
BR,
Suhas
‎2011 Jul 05 9:47 AM
‎2011 Jul 05 11:05 AM
Thks guys.
I tried now with type standard table and got a type mismatch error. I forgot that select-options tables do have a header line and selcrit only passes the header line which is of course incompatible with tables.
After a while i recognized that i had to use selcrit[]. Grmpf. I hate tables with header lines.
In the method i'm now checking if it is a table, has 4 columns, every column has the correct values and if the test passes with ok, i have a correct range table.
Did i mention already that i really hate header lines?
After that i'm creating a dynamic field structure, assigning that to a field_symbol (did i mention that i hate header lines) and looping thru the table.
Well, thanks everybody for giving me hints on how to solve that. It wasnt just that easy as in my first thoughts (comparing to a simple perform its a lot more coding). I hate performs as well as header lines. Guess i mentioned that already.
Was a nice practise dealing with dynamic data structures.
‎2011 Jul 05 8:41 AM
Hi.,
In your Method parameters declare only parameter of that type instead of range parameters ., and in method source code you append it to range.
ex:
date type ISH_ANFDT.
and in source code:
data:
RT_RANGES_FDT TYPE RANGE OF ISH_ANFDT,
RS_RANGES_FDT LIKE LINE OF RT_RANGES_FDT.
if date is not initial.
RS_RANGES_FDT-OPTION = 'EQ'.
RS_RANGES_FDT-LOW = date.
RS_RANGES_FDT-SIGN = 'I'.
APPEND RS_RANGES_FDT TO RT_RANGES_FDT.
ENDIF.
hope this helps u.,
Thanks & Regards,
Kiran
‎2011 Jul 05 9:01 AM
‎2011 Jul 05 9:06 AM
Hi Rainer,
Below is an example of what you are trying to achieve, update the post if you have any specific question after going through the below.
*----------------------------------------------------------------------*
* CLASS lcl_some_class DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_some_class DEFINITION.
PUBLIC SECTION.
METHODS some_method IMPORTING lt_tab TYPE STANDARD TABLE.
ENDCLASS. "lcl_some_class DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_some_class IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_some_class IMPLEMENTATION.
METHOD some_method.
IF sy-subrc EQ 0.
ENDIF.
ENDMETHOD. "some_method
ENDCLASS. "lcl_some_class IMPLEMENTATION
data: l_data TYPE TABNAME30,
lt_tab1 TYPE STANDARD TABLE OF selopttab.
SELECT-OPTIONS l_tab FOR l_data.
START-OF-SELECTION.
DATA: lcl_class TYPE REF TO lcl_some_class.
CREATE OBJECT lcl_class.
LOOP AT l_tab.
APPEND l_tab to lt_tab1.
ENDLOOP.
CALL METHOD lcl_class->some_method EXPORTING lt_tab = lt_tab1.
Regards,
Chen