07-25-2016 1:06 PM
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
07-25-2016 1:37 PM
07-27-2016 8:09 AM
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
07-27-2016 8:31 AM
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.
07-27-2016 2:14 PM
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
07-27-2016 8:21 AM
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