2007 Jul 10 5:11 AM
2007 Jul 10 5:16 AM
Hi Vijay ,
Use table types , go to SE11 and for the structure you are passing to the method create a table type and then use this table type as a parameter in the method.
In case you have any further queries feel free to revert back.
Regards
Arun
2007 Jul 10 5:16 AM
Hi Vijay ,
Use table types , go to SE11 and for the structure you are passing to the method create a table type and then use this table type as a parameter in the method.
In case you have any further queries feel free to revert back.
Regards
Arun
2007 Jul 10 6:09 AM
2007 Jul 10 7:37 AM
Hi,
this means it while passing the internal table only table is going to method not the header line.so u have to use the field-symbols to read the data from ur internal table inside ur method.see my example in the previous reply to this question.
FIELD-SYMBOLS:<fs> type mara.
loop at itab assigning <fs>.
write:/ <fs>-matnr,<fs>-mbrsh.
endloop.
<b>reaward helpful answers.</b>
rgds,
bharat.
2007 Jul 10 5:17 AM
Can you edit the method ?
If you can then you can use the export / import option... although you should be able to pass an internal table directly
DATA: wa_indx TYPE indx.
EXPORT tab = itab TO DATABASE indx(xy) FROM wa_indx CLIENT
sy-mandt
ID 'NAME'.
* and in the method
* imports from database the list sent by the calling program
IMPORT tab = itab FROM DATABASE indx(xy) TO wa_indx CLIENT sy-mandt
ID 'NAME'.
* deletes the data to save wastage of memory
DELETE FROM DATABASE indx(xy)
CLIENT sy-mandt
ID 'NAME'.
2007 Jul 10 5:22 AM
Hi,
see this link
http://www.jt77.com/development1/programming-27385.html
also see this example.
REPORT ZCLS.
CLASS cls DEFINITION.
PUBLIC SECTION.
METHODS:meth1 importing itab type standard table.
ENDCLASS.
CLASS cls IMPLEMENTATION.
METHOD meth1.
FIELD-SYMBOLS:<fs> type mara.
loop at itab assigning <fs>.
write:/ <fs>-matnr,<fs>-mbrsh.
endloop.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA:obj TYPE REF TO cls.
CREATE OBJECT obj.
data:itab1 type mara OCCURS 0.
SELECT * FROM mara into TABLE itab1 up to 10 rows.
CALL METHOD obj->meth1 exporting itab = itab1.
<b>reward points if helpful</b>
rgds,
bharat.
2007 Jul 10 5:35 AM
Hi,
Class methods should take table types as importing parameters..
Are you talking about function modules? Which SAP version you are working on? Does this table type contains nested structures?
Regards,
Abhijit
2007 Jul 10 5:36 AM
I have created the dynamic internal table and passed the values for it.but i was not able to pass this internal table for the function module <b>'REUSE_ALV_GRID_DISPLAY'.</b> Please help me.It is very urgent!!!!!!!!!!!!!!!!!!
I have given the following code for creating the dynamic internal table.
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: TYPE ANY TABLE,
TYPE ANY,
TYPE ANY.
is_fieldcat-fieldname = 'FIELD1'.
is_fieldcat-ref_field = 'MATNR'.
is_fieldcat-ref_table = 'MARA'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD2'.
is_fieldcat-ref_field = 'SPRPS
gkakbar: ok
naliniraja: is_fieldcat-ref_table = 'PA0001'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD3'.
is_fieldcat-ref_field = 'BEGDA'.
is_fieldcat-ref_table = 'PA0002'.
APPEND is_fieldcat TO it_fieldcat.
* Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
* Create a new Line with the same structure of the table.
ASSIGN new_table->* TO .
CREATE DATA new_line LIKE LINE OF .
ASSIGN new_line->* TO .
* Test it...
DO 30 TIMES.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE TO .
= '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE TO .
= 'X'.
ASSIGN
naliniraja: ASSIGN COMPONENT 'FIELD3' OF STRUCTURE TO .
= '20030101'.
INSERT INTO TABLE .
ENDDO.
i am not able to pass the to the grid.Please tell me which way i have to proceed to pass the dynamic internal table for ALV display.
reward points if it is usefull ...
Girish
2007 Jul 10 5:40 AM
hi,
<b>The default way of passing a parameter in a method is by reference. To pass a parameter by value, you must do so explicitly using the VALUE addition.</b>
while working with methods, it doesn't allow internal table with header line while creating internal table you must create without header line and pass to to the import or changing parameters of the methods that depends on your needs.
<b>while working with methods better to declare internal tables in SE11 by using the objects like LINE TYPE and ROW TYPE.
here LINE TYPE behaves like work area of the internal table.
ROW TYPE behaves like internal table body.</b>
<b>Declaring Methods</b>
You can declare methods in the declaration part of a class or in an interface. To declare instance methods, use the following statement:
METHODS <meth> IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL]..
EXPORTING.. [VALUE(]<ei>[)] TYPE type [OPTIONAL]..
CHANGING.. [VALUE(]<ci>[)] TYPE type [OPTIONAL]..
RETURNING VALUE(<r>)
EXCEPTIONS.. <ei>..
<b>Calling Methods</b>
To call a method, use the following statement:
CALL METHOD <meth> EXPORTING... <ii> =.<f i>...
IMPORTING... <ei> =.<g i>...
CHANGING ... <ci> =.<f i>...
RECEIVING r = h
EXCEPTIONS... <ei> = rc i...
regards,
Ashok Reddy