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 execute an ABAP dynamically?

Former Member
0 Likes
1,913

Hi,

How to execute an ABAP code directly within the ABAP code[transport]?

I have to inject the ABAP code in the run-time to transport and has to execute it.

I am not looking for SUBMIT, CALL, PERFORM as this is not solving my use case.

Sample :

   ABAPFunction (write:/ 'Hello World')

Thanks

Ashish

5 REPLIES 5
Read only

Juwin
Active Contributor
0 Likes
1,396

You need to explain your requirement further. What do you mean by: inject the ABAP code in the run-time to transport?

And, check if this document helps your requirement:

Thanks,

Juwin

Read only

Former Member
0 Likes
1,396

Hi Juwin,

Thanks for the response.

My application uses JCO library to interact with SAP. Currently we install a program on SAP box and we call it at the runtime using JAVA interface. We take input of ABAP code from our customer and pass on to SAP using the JAVA interface (SAP JCO). Then we embed the already installed function module.


Now, we cannot install the program on the SAP side and embed the user ABAP code. So we want to dynamically pass the ABAP code at the SAP side and execute it.

Please let me know if you have any queries.

Thanks and Regards,

Ashish

Read only

ziolkowskib
Active Contributor
0 Likes
1,396

I believe that should help:

https://help.sap.com/abapdocu_70/en/ABAPINSERT_REPORT.htm


REPORT ZTMP_R_DYN_GEN.

DATA lt_source TYPE stringtab.

APPEND 'REPORT ZTMP_R_REPORT.' TO lt_source[].

APPEND 'WRITE ''TEST REPORT''.' TO lt_source[].

INSERT REPORT 'ZTMP_R_REPORT' FROM lt_source[].

SUBMIT ztmp_r_report.

Read only

Juwin
Active Contributor
0 Likes
1,396

Let me tell you, whoever designed this solution is trying to push you into hell. If you were in my company, you will never pass audit. What you are designing puts untested code into production system, which can potentially even damage system configuration and steal critical data. (Read: Code injection).

That said, in a controlled fashion, this is possible in SAP (Read: GENERATE SUBROUTINE POOL).

Thanks,

Juwin

Read only

Former Member
0 Likes
1,396

Hi,

you can create a report using ABAP keyword INSERT REPORT.

Then you can call fm RFC_GENERATE_REPORT.

After that you can SUBMIT this report.

But you can also create the main report with an include. insert only the include report, generate the main report and submit it.

Regards,

Klaus