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

Call method dynamic from classname

Former Member
0 Likes
4,415

Hey everybody, i need some help with a small feature. I want to check the actual installed version of a package. There are few systems and few different packages. The problem is i can't assume that all packages are on the system. So there are some systems with for example only one package. So i must search the packages dynamic. LV_PRODUCT_NAME is the classname of the class, which has the version information of the package. I can call the GET_VERSION method and i receive a string. RV_RELEASE_NOTE is my exporting parameter. The Problem now is that i fall constantly into the catch block. I tried a lot of things, but this is the best i had found:



METHOD get_release_notes .


DATA ls_methode   TYPE tmdir.

DATA lr_class     TYPE REF TO OBJECT.

DATA lv_error     TYPE REF TO CX_ROOT.

ls_methode-classname = IV_PRODUCT_NAME.

ls_methode-methodname = 'get_version'.

TRY.

   CREATE OBJECT lr_class TYPE (ls_methode-classname).

   CALL METHOD lr_class->(ls_methode-methodname)

     RECEIVING

     RT_Version = RV_RELEASE_Notes.

CATCH

     cx_sy_dyn_call_error INTO lv_error.

     RV_RELEASE_NOTES = ls_methode-classname.

ENDTRY.

ENDMETHOD.

1 ACCEPTED SOLUTION
Read only

Former Member
1,358

I think it all looks fine... Not sure if this matters or not:

ls_methode-methodname = 'get_version'.


I think you might need to have the method name in all caps.

ls_methode-methodname = 'GET_VERSION'.


2 REPLIES 2
Read only

Former Member
0 Likes
1,358

Ok, i have found my issue:

the methodname was writen in small letters

PS.: And for people who are interessted, the classname was is a String.

Read only

Former Member
1,359

I think it all looks fine... Not sure if this matters or not:

ls_methode-methodname = 'get_version'.


I think you might need to have the method name in all caps.

ls_methode-methodname = 'GET_VERSION'.