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: 

Method parameter as TYPE Any

amreshkumar_panda2
Discoverer
2,230

Hi Gurus,

SAP enhancement has method parameter as TYPE ANY in Changing, by passing program it passed as a internal table but in that method as its TYPE ANY I am not able to use that as internal table, please suggest how we can do that??

3 REPLIES 3

DoanManhQuynh
Active Contributor
0 Kudos
614

I think you can do it this way:

DATA i_ref_tab TYPE REF TO DATA.
FIELD-SYMBOLS <itab> TYPE STANDARD TABLE.
CREATE DATA i_ref_tab LIKE input_tab[].
ASSIGN i_ref_tab->* to <itab>.

pokrakam
Active Contributor
0 Kudos
614

Assign it to a Field Symbol of your required data type and use that as usual.

BjörnJüliger
Product and Topic Expert
Product and Topic Expert
0 Kudos
614

1. If the type TY_ITAB of your table is known to you statically at compile time, just convert the parameter PARAM with a standard conversion:

  DATA(itab) = CONV ty_itab( param ).

Note that if the table is large, this can have performance issues as you are potentially copying PARAM. To avoid this, you can also use a field symbol of the type instead:

FIELD-SYMBOLS <itab> TYPE ty_itab.
ASSIGN param TO <itab>.

2. If the type of the table is not known at compile time, use a generically typed field symbol

FIELD-SYMBOLS <itab> TYPE TABLE.
ASSIGN param TO <itab>.

Now, ITAB resp. <ITAB> are variables of table type accepted by LOOP AT and other table manipulation statements.