‎2008 Dec 11 11:06 AM
HI all,
I would like to know if there is a FM to which I can pass a query string which it can execute and show the results.
The requirement is that I need to execute queries on a set of tables such as KNA1, ARDC, etc (depending on the user's choice and hence is decided at runtime) and extract values based on the join conditions. So is there a module to which I can pass the query string? if not, has anyone written a similar ABAP program which does the same? Can you please share the code if possible?
Also, which T code can i use to perform joins on tables and view data(to verify the result of the code)?
‎2008 Dec 11 12:07 PM
Function module: RFC_READ_TABLE
Transaction SQVi (query viewer to create joins).
‎2008 Dec 11 12:07 PM
Function module: RFC_READ_TABLE
Transaction SQVi (query viewer to create joins).
‎2008 Dec 11 1:12 PM
Micky,
Thanks for the pointer wrt SQVi. However, i also need an RFC that can accept entire query as an input. Since RFC_READ_TABLE works on only one table, this will not help me. I need to perform joins on many tables, depending on the users input. Is there an RFC which can do this?
‎2008 Dec 12 4:05 AM
Hi Monica,
Check the follwing FM:-
TH_SERVER_LIST u2013 List of RFC servers
CAT_CHECK_RFC_DESTINATION u2013 Checks the RFC destinations and connections
CAT_PING u2013 Checks RFC system and configuration
Regards,
Kanika
‎2008 Dec 16 5:28 AM
Kanika,
Perhaps i used the wrong term . what i wnat is an ABAP progam or a BAPI that accepts a SQL query (that works on table )as an input and returns the result. Is this available?
‎2009 Jan 01 5:05 PM
Just copy this program check the working through debuging and you will be able to resolve your problem.
DATA:v_fieldname
TYPE fieldname,
l_PROG TYPE string,
v_mess TYPE string,
l_sid TYPE string,
wa_ddfields TYPE dntab.
DATA i_tab TYPE STANDARD TABLE OF string.
DATA:l_str TYPE string,
l_str1 TYPE string.
PARAMETERS matnr type marc-matnr.
end-of-SELECTION.
*build the subroutine pool
APPEND 'PROGRAM subpool.' TO i_tab.
APPEND `LOAD-OF-PROGRAM.` TO i_tab.
APPEND `DATA i_tab1 TYPE TABLE OF vbak.` TO i_tab.
APPEND `DATA l_rows TYPE i.` TO i_tab.
APPEND `select * into table i_tab1 from vbak.` To i_tab.
append 'DESCRIBE TABLE i_tab1 LINES l_rows.' to i_tab.
append 'Write : l_rows .' to i_tab.
GENERATE SUBROUTINE POOL i_tab NAME l_PROG
MESSAGE v_mess
SHORTDUMP-ID l_sid.
IF sy-subrc = 0.
PERFORM ('LOOP_AT_TAB') IN PROGRAM (l_PROG) IF FOUND.
ELSEIF sy-subrc = 4.
MESSAGE v_mess TYPE 'I'.
ELSEIF sy-subrc = 8.
MESSAGE l_sid TYPE 'I'.
ENDIF.
I guess this will resolve your question.if you want more help i will be there