2009 Jul 10 11:44 AM
Dear All
I hv some experience with ALV. Now I m trying to learn ALV with OOPs.
I just want to know how to call a method.
I mean if i want to call a method in non alv report, i simply click on pattern and give the method name and the respective method with
respective variable got inserted into code.
but when i give method name in pattern in code if i m OOPs, then its give an error.
And if i type the whole thing myself, it works fine.
Do i need to type every method with respective variables or is there any other way to call a method when using OOPs with ALV.
Also if anyone can provide a tutorial link on this.
Thanks in advance.
Rerages
2009 Jul 10 1:22 PM
Hi Maverick,
If you want to call a method uing pattern .First you have to click the radio button ABAP Object patterns and ok button on the pattern on the next pop up youll have to select CALL METHOD radio button
In instance parameter give your OBJECT name created for your CLASS.And in the Class give your
class name and on the method you have to give the method name which is present in that particular class check that in SE24 TCODE. Pattern will only work for class defined by SAP and for the user defined class in SE24 .It wont work for locally created classes.
With Regards,
M.Sreeram.
Dear All
I hv some experience with ALV. Now I m trying to learn ALV with OOPs.
I just want to know how to call a method.
I mean if i want to call a method in non alv report, i simply click on pattern and give the method name and the respective method with
respective variable got inserted into code.
but when i give method name in pattern in code if i m OOPs, then its give an error.
And if i type the whole thing myself, it works fine.
Do i need to type every method with respective variables or is there any other way to call a method when using OOPs with ALV.
Also if anyone can provide a tutorial link on this.
Thanks in advance.
Rerages
2009 Jul 10 12:12 PM
Hi,
You need to provide reference variable for each method which is an instance method (during call it is shown as)
call method ref_variable->method. "here call is instance method
.
For that in Patter you need to provide:
- Instance - which is variable name
- Class - which is class name
- Method - which is instance method name
When, on the other hand, you want to calll static method (during call it is shown as)
call method class_name=>method. "here call static method
For that in Patter you need to provide:
- Class - which is class name
- Method - which is static method name
In frist case you simply must have reference variable defined like
data: ref_variable type ref to cl_gui_alv_grid.
"then you need to create an object (instance) of that class
create object ref_variable .... "this you can insert with Patter as well (option 'Create Object')
"now you can call your INSTANCE method
call method ref_variable-> ....
In second you don't need to create any object nor reference variable , you simply call static method of a class (which is valid for class (so for all objects too) ) like this
call method cl_gui_alv_grid=>.... "static method name here
The above is relevant for all methods/classes not only CL_GUI_ALV_GRID
For more info please refer [Declaring and Calling Methods|http://help.sap.com/saphelp_nw04/helpdata/en/08/d27c03b81011d194f60000e8353423/frameset.htm]
Regards
Marcin
2009 Jul 10 1:22 PM
Hi Maverick,
If you want to call a method uing pattern .First you have to click the radio button ABAP Object patterns and ok button on the pattern on the next pop up youll have to select CALL METHOD radio button
In instance parameter give your OBJECT name created for your CLASS.And in the Class give your
class name and on the method you have to give the method name which is present in that particular class check that in SE24 TCODE. Pattern will only work for class defined by SAP and for the user defined class in SE24 .It wont work for locally created classes.
With Regards,
M.Sreeram.
2009 Jul 10 1:29 PM
Thanks M.Sreeram. ur reply is very concise and usefull.
Thanks again.
Regards