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: 

Auto Generate Method in a class through report.

fathimawajiha
Explorer
0 Kudos
529

Hi,
I want to write a report in which the input parameter is the name of the class. Once the report is executed, a method should be auto generated in the class.

Can someone help me with the report.

Thanks and Regards,

Wajiha Fathima

4 REPLIES 4

matt
Active Contributor
432

It's certainly possible - I've done it. But it was a while ago and I don't have access to that system. I found it through searching this site.

Sandra_Rossi
Active Contributor
432

You can certainly trust the way it was done in abapGit (used by many people, code running on many ABAP versions, tool frequently updated, ...)

You didn't say if it was a class pool or a local class.

  • If it's a class pool, look at how it's done by the class zcl_abapgit_oo_class (deserialize_source method and all implied methods).
  • If it's a local class (in an executable program, function group or class pool), the code you will have to do is probably much easier. So, even if you want to have your method generated in a class pool, you may possibly think about regenerating the method in the local part of the class pool.

The difference with what you want to achieve is that the code is oriented to create/recreate the whole objects, so either you don't bother and just reuse the existing tool, or you take just what you need.

Don't forget to give credits to abapGit in your source code.

cc author lars.hvam

0 Kudos
432

Hi Sandra Rossi,

Thank you for the solution but, I want to create in a local class using any function module or any class method.

Regards,

Wajiha Fathima

0 Kudos
432

In that case, I just mentioned "probably much easier" and you can still look at abapGit how it does it, as I have mentioned.

Whatever solution you use, it will not be supported by SAP and not recommended (the only ABAP code generation supported is GENERATE SUBROUTINE POOL), so if you really want to do it, you may use the sole ABAP statement "INSERT REPORT" to replace the code of one include (in which you have your local class).

You also have lots of questions and answers about ABAP code generation.

NB: please clarify where your local class is (definition, implementation), you still didn't explain. That makes your question more difficult to answer...