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

How to create a method with generic parameter?

0 Likes
3,045

Hi, I would like to know if it is possible to create a method that accepts an importing parameter with a generic data type, the scenario is I need my method to accept a parameter with any "NUMERIC" data type be it integers, floats , quantities but no character types so that the developer doesnt have to create intermediate variables when calling my method he could just pass the variable from his program and the casting happens inside my method, is this possible? and if it is then how ?.

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,469

the scenario is I need my method to accept a parameter with any "NUMERIC" data type be it integers, floats , quantities

ABAP has the generic type NUMERIC, you could have just typed NUMERIC.

Keep these points in mind while doing generic programming - http://help.sap.com/abapdocu_740/en/abentype_formal_param_guidl.htm.


iv_param TYPE REF TO data

So you think data reference will not accept character-like actual parameters.

BR,

Suhas

3 REPLIES 3
Read only

Former Member
0 Likes
1,469

iv_param TYPE REF TO data

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,470

the scenario is I need my method to accept a parameter with any "NUMERIC" data type be it integers, floats , quantities

ABAP has the generic type NUMERIC, you could have just typed NUMERIC.

Keep these points in mind while doing generic programming - http://help.sap.com/abapdocu_740/en/abentype_formal_param_guidl.htm.


iv_param TYPE REF TO data

So you think data reference will not accept character-like actual parameters.

BR,

Suhas

Read only

Abhijit74
Active Contributor
0 Likes
1,469

Hello,

I think this is a good example for your requirement.

ABAP OO - Generic class for inserting, updating and deleting records.

Thanks & Regards,

Abhijit