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

Problem with creating ABAP Objects instances dynamically

Former Member
0 Likes
1,501

Dear experts,

recently I've written an application that includes the SAP formula editor (classes CL_FOBU_FORMULA, CL_FOEV_FORMULA, etc.) in a subscreen. Now I'm supposed to rework my program for our customers who still have 4.6C systems, in which those classes don't yet exist. The application doesn't necessarily need to work under 4.6C. The minimum requirement is that at least it doesn't cause loads of errors during the import in the customers system. My approach was to check my options to create all the necessary object instances dynamically and only after successfully checking their existence in system, by using the dynamic TYPE assignment that can be used with the CREATE OBJECT statement, as shown in the following code snippet:

DATA object_reference TYPE REF TO object.

DATA name_of_the_object TYPE classname value 'CL_FOBU_FORMULA'.

CREATE OBECT <obj_reference> TYPE (name_of_the_object)

The creation of objects seems to work fine, at least the creation of object instances doesn't cause short dumps, but it looks as if the instances created this way are not fully compatible with objects that have been created in the normal non-dynamic way. When dynamically calling either of the CL_FOBU_FORMULA methods LOAD or CREATE I get a parameter mismatch short dump

DYN_CALL_METH_PARAM_TYPE  

CX_SY_DYN_CALL_ILLEGAL_TYPE

which refers to an object instance that I'm handing over to the parameter IM_ENVIRONMENT. This object instance was created the "dynamic way", as shown above. I don't get the short dump when the instances are created non-dynamic. Does anybody in the ABAP developer community have had those kinds of problems, too? Any experience that I could benefit from?

Thanks in advance

Andreas

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,147

Hello Andreas,

I am assuming that you are using an object type 'OBJECT' to pass into the parameter 'IM_ENVIRONMENT'.

The parameter mismatch could be due to the fact that you are passing an object reference of type 'OBJECT' to a parameter which would accept references of type IF_FOBU_CONNECTOR, thereby narrowing the cast. I am not sure if this issue would arise only in 4.6c . If my assumption is right, then the above error should come in all systems, simply due to the fact that class type 'Object' does not implement the interface IF_FOBU_CONNECTOR.

Do correct me If I am missing anything here.

Thanks,

Venkat

2 REPLIES 2
Read only

Former Member
0 Likes
1,148

Hello Andreas,

I am assuming that you are using an object type 'OBJECT' to pass into the parameter 'IM_ENVIRONMENT'.

The parameter mismatch could be due to the fact that you are passing an object reference of type 'OBJECT' to a parameter which would accept references of type IF_FOBU_CONNECTOR, thereby narrowing the cast. I am not sure if this issue would arise only in 4.6c . If my assumption is right, then the above error should come in all systems, simply due to the fact that class type 'Object' does not implement the interface IF_FOBU_CONNECTOR.

Do correct me If I am missing anything here.

Thanks,

Venkat

Read only

0 Likes
1,147

Dear Venkat,

you're assuming right that I declared the reference variable that I wanted to pass as of type OBJECT,

assuming that I dynamically could create an instance of an object that includes the IF_FOBU_CONNECTOR interface.

I guess I will close this thread because meanwhile I've realized that there doesn't seem to exist a way of surviving a syntax-check in 4.6C.

Nonetheless - thanks a lot for your answer that I've marked as helpful!

Andreas