‎2010 Oct 21 2:07 AM
Hi
I am trying to create a program to use for the ABAP developers at my work. We want to be able to enter small snippets of code and for the program to run the code and send back the database results. Kind of like a test program for data in the DB. We also want to be able to do direct table updates with it (Z tables only).
I am creating a text editor on my screen to enter the code to compile. The user will then enter their select statement which will return the results of the database on screen.
However I am unsure how to compile code that the user has entered? I know how to retrieve the text from the editor but how do I use the code that I retrieve? Is there a way to do this? I want to try run whatever code the user enters.
‎2010 Oct 21 2:42 AM
You can use another option of using giving the user parameters Iike table names where clause fiels etc and in back end you can use dynamic queries. I m loking into your problem will get back to you soon. It is way arounf which i provided.
Nabheet
‎2010 Oct 21 2:42 AM
You can use another option of using giving the user parameters Iike table names where clause fiels etc and in back end you can use dynamic queries. I m loking into your problem will get back to you soon. It is way arounf which i provided.
Nabheet
‎2010 Oct 21 2:58 AM
I just write my own code and check how Sap does it. Check following classes.
1 cl_wb_pgeditor method check_source
2 cl_wb_editor.
For more detail write a statement and before activating enable debugging.
Nabheet
‎2010 Oct 21 6:00 AM
These look hopeful indeed, thanks if I can get working example with what you have provided I'll let you know and give you 10.
Cheers
‎2010 Nov 08 4:26 AM
I got it to work.. here is the code I used.
TRY.
GENERATE SUBROUTINE POOL source_tmp NAME prog
MESSAGE msg
LINE lin
WORD wrd
OFFSET off.
* editor-call for report prog display-mode.
IF sy-subrc <> 0.
v_textname = 'Syntax Error!'.
REFRESH i_tline.
lin = lin - 2. " 2 lines added at generation
CONCATENATE 'Error during generation in line' lin
INTO i_tline-tdline.
APPEND i_tline.
i_tline-tdline = msg.
APPEND i_tline.
* CONCATENATE 'Word:' wrd 'at offset' off
* INTO I_TLINE-TDLINE.
* APPEND I_TLINE.
CALL FUNCTION 'POPUP_WITH_TABLE'
EXPORTING
endpos_col = 120
endpos_row = 25
startpos_col = 35
startpos_row = 5
titletext = v_textname
TABLES
valuetab = i_tline
EXCEPTIONS
break_off = 1.
ELSE.
GET TIME STAMP FIELD v_timestamp1.
PERFORM dyn1 IN PROGRAM (prog) TABLES <l_table>.
GET TIME STAMP FIELD v_timestamp2.
v_timeresult = v_timestamp2 - v_timestamp1.
ENDIF.
CATCH cx_sy_generate_subpool_full.
gen_error = 'X'.
MESSAGE s012(s7).
EXIT.
ENDTRY.