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: 

Possible to do dynamic SQL statement?

Former Member
0 Kudos

Hi,

I have a dialog screen with an inputfield. The developer will key in SQL statement into this inputfield and the SQL statement will store in the database. When the developer click on execute button. The program will retrieve the SQL statement from the database and perform the SQL statement and retrieve the data.

Is it possible to do that? What are the things that i need to look into?

Regards,

Rayden

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Rayden,

I don't think it is possible. You may need to look at some other alternative.

Regards,

Atish

5 REPLIES 5

Former Member
0 Kudos

Hi Rayden,

I don't think it is possible. You may need to look at some other alternative.

Regards,

Atish

Former Member
0 Kudos

Hi,

Yes it is posible.

I made one program like you want. But it need very long code.

Here I explain the idea:


1. Create Screen with input TEXT EDIT CONTROL.
    This is for input SQL Statement.
2. Get SQL Statement from Text Edit Control using method <b>get_text_as_r3table</b>.
3. Now we need to separate SQL Statement into different table. 
    We Separate SELECT, FROM, WHERE, GROUP, HAVING, ORDER, etc.
4. We need dynamic internal table to store the data.
5. Select the data according SQL statement.
      SELECT (IT_SELECT)
        into corresponding fields of table  <dyn_table>
      FROM (IT_FROM)
      WHERE (IT_WHERE)
      GROUP BY (IT_GROUP)
      HAVING (IT_HAVING)
      ORDER BY (IT_ORDER).
6. Display our data using ALV GRID

Hopefully it will help you.

Regards,

0 Kudos

Hi Jatra,

That was great. Do you have any sample code to share?

Regards,

Rayden

Former Member
0 Kudos

Hi,

I am preparing my code. When it ready i will upload it.

Regards,

0 Kudos

Hi Jatra,

Great. Looking forward for the sample.

Thanks

Regards,

Rayden