‎2008 Aug 05 12:54 PM
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!
‎2008 Aug 05 1:15 PM
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
‎2008 Aug 05 12:58 PM
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
‎2008 Aug 05 1:01 PM
Create the "value" field of type CHAR. This will solve your problem...
‎2008 Aug 05 1:01 PM
‎2008 Aug 05 1:02 PM
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.
‎2008 Aug 05 1:03 PM
Hi!
How can I declare in a function module a table like "any table"?
Thanks a lot!
‎2008 Aug 05 1:49 PM
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.
‎2008 Aug 05 1:15 PM
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