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: 

Dynamic Sql Output

Former Member
0 Kudos

Dear All,

The user will write/enter a

sql query in the screen. The

program should give output of

that sql in the form of records/itab.

How can this be achieved ?

Thanks in advance.

Amit Mittal.

1 REPLY 1

Former Member
0 Kudos

Hi,

I wonder how you will carry out the syntax checks in this case. Any way, there are a couple of options available:

1. Use statement GENERATE SUBROUTNE POOL to dynamically generate a transient program and obtain its output in your own program.

2. The other way is that you can obtain column names, table name and where clause from the user in separate fields on screen and use them to construct an OpenSQL statement like <b>SELECT (fieldlist) FROM (tablename) INTO (targetarea) WHERE (whereclause)</b>.

For both options, you can take a look at the document <b>https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/advanced and generic programming in abap.pdf</b> or TechEd session <b>https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/eclasses/teched04/ABAP351.htm</b> on generic programming.

Hope this helps.

Regards