Application Development and Automation 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: 
Read only

Pass dynamic table to function

Former Member
0 Likes
915

Hello!

I must pass a dynamic table to a function. My big problem is that one field can have different types...

I have to pass a table like:

field;value

bkpf-gjahr;2006

bkpf-budat;31.12.2006

bseg-sgtxt;Hello

And so... "value" can have different types.

How can I pass this??? Can someone help me?

Thanks a lot!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
881

You just need to declare a importing paramter say IT_MESSAGES as TYPE ANY in the function module. With this you will be able to pass any internal table to this FM irrespective of the format..

However in order to access the internal table contents you'll have to make use of field-symbols...more documentation can be found at the link below

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae]

EX.

field-symbols: <row> type any, <field> type any.

loop at lt_itab assigning <row>.

assign component 'BUDAT' of structure <row> to <field>. " here you can access components either by specifying the index or using the name of the field

if <field> is assigned.

write <field>.

endif.

endloop.

~Piyush Patil

7 REPLIES 7
Read only

Former Member
0 Likes
881

Hi,

Create one internal table with 2 fields of type CHAR and named as field name(30) and field value(255). Then append the data to internal table and pass that table to FM.

Rgds,

Bujji

Read only

Former Member
0 Likes
881

Create the "value" field of type CHAR. This will solve your problem...

Read only

Former Member
0 Likes
881

with CHAR or STRING type you can store all types of data.....

Read only

Former Member
0 Likes
881

well yout table in your routine you call should be declared of type "any table".

then in your routine you can use "loop at component of structure" to acess the fields.

Read only

0 Likes
881

Hi!

How can I declare in a function module a table like "any table"?

Thanks a lot!

Read only

0 Likes
881

Hi,

Just declare a table in table parameters of function module and don't mention any structure for that table then it will consider as table of any type.

Check Function module 'REUSE_ALV_GRID_DISPLAY' for your reference.

Read only

Former Member
0 Likes
882

You just need to declare a importing paramter say IT_MESSAGES as TYPE ANY in the function module. With this you will be able to pass any internal table to this FM irrespective of the format..

However in order to access the internal table contents you'll have to make use of field-symbols...more documentation can be found at the link below

[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b332e090-0201-0010-bdbd-b735e96fe0ae]

EX.

field-symbols: <row> type any, <field> type any.

loop at lt_itab assigning <row>.

assign component 'BUDAT' of structure <row> to <field>. " here you can access components either by specifying the index or using the name of the field

if <field> is assigned.

write <field>.

endif.

endloop.

~Piyush Patil