Application Development and Automation 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: 
Read only

How to write your own SQL statement and execute it?

Former Member
0 Likes
6,017

Hi,

Is there a Transaction Code that could be used to write your own SQL query and execute. The QuickViewer is a graphical query designer and is not flexible for advance query design. You could also write your query in a ABAP program and execute it but this take time.

Pls give me various methods that are available.

Thanks

Kishan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,797

Hi Kishan,

Would you execute

- a SELECT-Statement, then see the answer from andrea (SQ01 and SQ02)

or

- a any Statement.

Then see

- EXEC SQL

or

- use the class CL CL_SQL_STATEMENT. An example is the abap ADBC_DEMO.

Sven

7 REPLIES 7
Read only

Former Member
0 Likes
1,797

Hi Kishan,

As far as I know, there's no transaction that would let you do it directly.

You have these two options which may be somewhat helpful -

1. ST05 - There's an option to <i>Explain one SQL Request</i>. Through this option you can find out the number of records that will be retrieved and other details. You will not get the resut, however. This transaction will help you write better SQL queries in terma of performance.

2. If you are looking for data from only a single table, you can use the SE16 transaction. You specify the table name and give the conditions.

Regards,

Anand Mandalika.

Read only

andreas_mann3
Active Contributor
0 Likes
1,797

Hi Kishan,

try sq01 resp. sq02 and have a look here:

http://help.sap.com/saphelp_47x200/helpdata/en/d2/cb4138455611d189710000e8322d00/frameset.htm

regards Andreas

Read only

Former Member
0 Likes
1,798

Hi Kishan,

Would you execute

- a SELECT-Statement, then see the answer from andrea (SQ01 and SQ02)

or

- a any Statement.

Then see

- EXEC SQL

or

- use the class CL CL_SQL_STATEMENT. An example is the abap ADBC_DEMO.

Sven

Read only

Former Member
0 Likes
1,797

n order to create an ABAP query , one has to do the following.

1. Create an User group.

2. Create a Functional Area

3. Assign the User group to the Functional Area

4. Create the query based on the functional area created.

You can create or execute these, using the transactions below.

SQ01 for Query

SQ02 for Functional Area.

SQ03 for User Group.

First Step is to create a dictionary structure . Include all the fields in this structure that you want to output.

Then create a report program having the following structure .

Report XXX .

TABLES tab . Declare the already created dictionary structure also here.

Parameters x . Define parameters here

Select-Options:…….

DATA :…..

DATA : BEGIN OF itab OCCURS xxx

END OF itab. Structure tab to hold the records to be evaluated.

*<Query_head> This comment must always appear after your data declarations

  • Code to define the table itab

Loop to retrieve each record and place it in itab.

SELECT,DO, LOOP ,….

If necessary , code to format data

*<Query_body> This comment must always be the last statement in the loop.

End of loop

ENDSELECT , ENDDO, ENDLOOP ,…

Get back to me if u need the document for doing so.

Thanks & Regards,

Judith.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,797
Read only

soren_hansen
Associate
Associate
1,797

Use DBACOCKPIT choose Diagnostics and SQL Commands

Read only

0 Likes
1,797

You waited five years after registration in order to post your first reply to a four year old thread?

I'm puzzled

Thomas