Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

table with type ANY in function module

Former Member
0 Kudos

Hi all

I want to use a function module in different programs. I want to pass always a table and in a string the name of the structure, so that I can access the data with ASSIGN and the passed structure name.

For a structure I can use the type ANY, but if I want to use a table in a function module, I need to define a table type.

Is there a way to define a tabletype with the type ANY? A Workaround would be fine too.

Thanks and best regards!

Christian

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Christian,

ANY TABLE is used to type a parameter, or field symbol, that can be a table of any type or structure.

ANY is used to type a parameter, or field symbol, that can be any type. You can't, however, use any table operations on a parameter/field-symbol typed as ANY. For that, you have to use ANY TABLE.

The same applies to ANY. You can pass to the method a data object, without specifying its type (i.e, in dynamic programs).

Suppose that I need to split a line into a table, but I don't know the structure of this line:

I have a method:

codeMETHOD split_line_in_table IMPORTING im_line TYPE ANY

EXPORTING ex_table TYPE ANY TABLE.

[/code]

codeMETHOD split_line_in_table.

SPLIT im_line AT separator INTO TABLE ex_table.

ENDMETHOD.[/code]

Now, i can pass this method a line of ANY structure and get a table without specifying its structure.

cheers,

Hema.

2 REPLIES 2

Former Member
0 Kudos

Hi Christian,

ANY TABLE is used to type a parameter, or field symbol, that can be a table of any type or structure.

ANY is used to type a parameter, or field symbol, that can be any type. You can't, however, use any table operations on a parameter/field-symbol typed as ANY. For that, you have to use ANY TABLE.

The same applies to ANY. You can pass to the method a data object, without specifying its type (i.e, in dynamic programs).

Suppose that I need to split a line into a table, but I don't know the structure of this line:

I have a method:

codeMETHOD split_line_in_table IMPORTING im_line TYPE ANY

EXPORTING ex_table TYPE ANY TABLE.

[/code]

codeMETHOD split_line_in_table.

SPLIT im_line AT separator INTO TABLE ex_table.

ENDMETHOD.[/code]

Now, i can pass this method a line of ANY structure and get a table without specifying its structure.

cheers,

Hema.

0 Kudos

Exactly the information, which I was searching for!

Thank you very much!!