03-09-2005 12:21 PM
Hello everybody.
I think many of you hhave passed through the same problem. I have a requirement to pass internal table to class as for example class constructor parameter. It is desirable that class should get the table of variable structure.
How coult that be realized?
Thank you in advance for your kind help.
--
Best regards,
Andrey
03-09-2005 12:31 PM
Hi,
The parameter can be typed TYPE TABLE. Let us know if it helps.
Regards
03-09-2005 12:31 PM
Hi,
The parameter can be typed TYPE TABLE. Let us know if it helps.
Regards
03-09-2005 1:13 PM
Here is a quick sample........
report zrich_0003 .
*---------------------------------------------------------------------*
* CLASS lcl_app DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app definition.
public section.
methods: constructor importing table type table.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_app IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_app implementation.
method constructor.
check sy-subrc = 0.
endmethod.
endclass.
data: app type ref to lcl_app.
data: imara type table of mara.
start-of-selection.
create object app
exporting
table = imara.
check sy-subrc = 0.
Regards,
Rich Heilman
03-09-2005 3:39 PM
As mentioned earlier, you can TYPE the parameter as a generic table type, for example TYPE STANDARD TABLE, TYPE INDEX TABLE, etc.
Your next problem is how to use the table. You can create a work area with a DATA statement:
DATA:
wa_table LIKE LINE OF parameter_table.
You can:
LOOP AT parameter_table INTO wa_table.
Since your code does not know the field names, you must
access the fields by assigning to a field symbol using:
ASSIGN COMPONENT index OF ... TO ...
Is this what you need?
03-09-2005 4:10 PM
Thank you all dear colleagues.
I've found a way to move due to your kind help.
--
With kind regards,
Andrey.