Skip to Content
author's profile photo
Former Member

Dynamic Sql Output

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • author's profile photo
    Former Member
    Posted on Jan 19, 2005 at 07:36 AM

    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 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 or TechEd session https://www.sdn.sap.com/sdn/elearning.sdn?class=/public/eclasses/teched04/ABAP351.htm> on generic programming.

    Hope this helps.

    Regards

    Add comment
    10|10000 characters needed characters exceeded