2014 Nov 20 6:34 PM
Hi all.
In this simple code example. I would like to know why this line of code generates an error. CL_SALV_TABLE->DISPLAY( ).
************************************************
DATA : IT_MARA TYPE TABLE OF MARA.
DATA : LR_ALV TYPE REF TO CL_SALV_TABLE.
SELECT * FROM MARA INTO TABLE IT_MARA UP TO 50 ROWS.
CALL METHOD CL_SALV_TABLE=>FACTORY
IMPORTING
R_SALV_TABLE = LR_ALV
CHANGING
T_TABLE = IT_MARA.
**** LR_ALV->DISPLAY( ). "correct
CL_SALV_TABLE->DISPLAY( ). "error
********************************
Q : Isn't the last statement similar to this one : CALL METHOD CL_SALV_TABLE->DISPLAY( )
which is similar to CALL METHOD CL_SALV_TABLE=>FACTORY ?
FACTORY & DISPALY are both methods of the class CL_SALV_TABLE, except that DISPLAY has no import or export parameters. why calling it, is causing an issue ?
Thank you.
2014 Nov 20 8:34 PM
hi sami
the difference is:
CL_SALV_TABLE=>FACTORY is a STATIC Method, where
CL_SALV_TABLE->DISPLAY is a INSTANCE Method, so you cannot Access it over the Classname but you can use a REF TO variable (LR_ALV)
2014 Nov 20 8:39 PM
Hi,
You are missing basic OO knowledge.
See here http://help.sap.com/abapdocu_740/en/abenabap_objects_oview.htm
Regards.
2014 Nov 21 4:15 AM
Hi,
FACTORY is static method.
DISPLAY is instance method.
check the syntax for method call
http://help.sap.com/saphelp_nw70/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm