06-07-2006 2:10 PM
Hi All,
I am using Object Oriented Programming in my program.
I want to pass a Internal Table from a method calling statement written in a start-of-selection.
Can any one give me the syntax for
1. Declaring a method with importing parameter as internal table.
2. Syntax for Method Implementation
3. Syntax for calling the method from start-of-selection.
helpful answers are rewarded.
Regards,
Azaz Ali.
06-07-2006 2:16 PM
Here is a simple example.
report zrich_0001.
*---------------------------------------------------------------------*
* CLASS lcl_app DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app definition.
public section.
types: t_t001 type table of t001.
class-data: it001 type table of t001,
xt001 type t001.
class-methods: put_data importing im_t001 type t_t001,
write_data.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_app IMPLEMENATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app implementation.
method put_data.
it001[] = im_t001[].
endmethod.
method write_data.
loop at it001 into xt001.
write:/ xt001.
endloop.
endmethod.
endclass.
data: itab type table of t001.
start-of-selection.
select * into table itab from t001.
call method lcl_app=>put_data( itab ).
call method lcl_app=>write_data.
Regards,
Rich Heilman
06-07-2006 2:14 PM
Hi,
Check this program
DEMO_ABAP_OBJECTS_METHODS
Give ur Id will send docs on OO ABAP
Regards
Message was edited by: Manoj Gupta
06-07-2006 2:23 PM
Hi Manoj,
In program which you have mentioned no where call method statement is using exporting statement with internal Table.
Regards,
Azaz Ali.
06-07-2006 2:16 PM
Here is a simple example.
report zrich_0001.
*---------------------------------------------------------------------*
* CLASS lcl_app DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app definition.
public section.
types: t_t001 type table of t001.
class-data: it001 type table of t001,
xt001 type t001.
class-methods: put_data importing im_t001 type t_t001,
write_data.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_app IMPLEMENATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app implementation.
method put_data.
it001[] = im_t001[].
endmethod.
method write_data.
loop at it001 into xt001.
write:/ xt001.
endloop.
endmethod.
endclass.
data: itab type table of t001.
start-of-selection.
select * into table itab from t001.
call method lcl_app=>put_data( itab ).
call method lcl_app=>write_data.
Regards,
Rich Heilman
06-07-2006 2:23 PM
Hi Azaz,
1. Declare the parameter as follows in the parameter list of the method :
Parameter : t_table
Type : Exporting or Changing
Typing Method : Type
Associated Type : Table Type
2. Double Click the method name in SE24 and write the code.
3. CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST
EXPORTING
FILE = SOURCE
RECEIVING
RESULT = RC
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
others = 4.
<b>Reward points if it helps.</b>
06-07-2006 2:40 PM
Hi,
Calling Method is similar to calling function Module.
CALL METHOD cl_gui_frontend_services=>gui_download
exporting
filename =
IMPORTING
FILELENGTH =
changing
data_tab = <b>( this is ur internal table name )</b>* EXCEPTIONS
FILE_WRITE_ERROR = 1.
<b>In OO ABAP u avoid creating table with header line</b>
Best way to call method is to use <b>PATTERN</b> Button
1) Click Pattern Button
2) Select Abap Object Pattern
3) Enter
4) Select Call Method
5) Enter instance name ( i. e used for create object ) ( No need for static method like gui_download )
6) Enter Class / Interface name
7) Enter Method Name
done.
<b>passing value to method is similar to FM.
Creating internal table for Method
any TYPE ........SAY TY_Intern
Then Syntax Should Be
DATA : OO_INTERNAL_TABLe type table of TY_Intern.
pass this to the Method.
Hope This will solve ur problem.
Please Mark Helpful Answers</b>
Message was edited by: Manoj Gupta