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

What is the difference between using Type and Like for TABLES in a function

Former Member
0 Likes
1,179

Hi

Please give our commetes on below question.

What is the difference between using Type and Like for TABLES in a function module interface?

Regards,

Hi

Please give our commetes on below question.

What is the difference between using Type and Like for TABLES in a function module interface?

Regards,

7 REPLIES 7
Read only

Former Member
0 Likes
1,131

Hi shwetambari,

1. In se37, in Tables parameter,

2. it will not allow type

eg. A LIKE T001 -


ok

B Type T001 -


error (system will give message

Flat types may only be referenced using LIKE

table parameters )

regards,

amit m.

Read only

0 Likes
1,131

Is there any senario where we can use 'TYPE ' in table parameter of se37?

If not, please explain why?

Read only

0 Likes
1,131

Hi again,

1.

ABC TYPE T001A_T (<---- this is table type)

B TYPE BUKRS (<----- this is data element)

2. In the above cases, TYPE will work in se37,

in IMPORT/EXPORT/CHANGING Parameters.

3. ABC TYPE T001A_T (<---- this is table type)

This will work in TABLES parameter also.

regards,

amit m.

Read only

0 Likes
1,131

can you please explain why only table types are accepted with type in table parameters where as in all the other parametes type can be used with the table name as well.

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,131

hi

for FM creation preferred one is TYPE only.

if you use LIKE while creating FM

system will give message

Flat types may only be referenced using LIKE

table parameter.

Regards,

kumar

Read only

Former Member
0 Likes
1,131

Example

DATA NUMBER TYPE I.

DATA WA_SPFLI TYPE SPFLI.

The field NUMBER is created with type I. You can now use it in the program. In particular, you can assign numeric values to the field and use it in calculations ( ABAP number types).

The field WA_SPFLI is created using the type of the database table SPFLI from the ABAP Dictionary. This field is structured and can be used especially for working with data from database table SPFLI.

... LIKE f1

Field f is created with the same field attribtues as the data object f1, which has already been declared. Any data object (field, parameter, structure...) is allowed as long as its type has been fully specified.

f1 can be any ABAP Dictionary reference.

Example

DATA TABLE_INDEX LIKE SY-TABIX.

The field TABLE_INDEX now has the same attributes as SY-TABIX (index field for internal tables).

Note

You should use this addition whenever you can. If the type of a field to which you are referring changes, the ABAP runtime system updates all references automatically. It also stops the system from carrying out unnecessry (and maybe undesirable) type conversions.