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: 

Find SELECT quires in a given program

Former Member
0 Kudos

Hi Experts,

Good day,

Can anybody help me out in finding out or to tell how many SELECT quires are there in a given program

or

How to trace out all the SELECT for a given program.

any logic would be really appreciated.

Regards

SAMUEL

12 REPLIES 12

former_member946717
Contributor
0 Kudos

Hi Sam,

Do you want to write a program to do this search or externally also its fine? If its fine externaly then you can do a global search for SELECT and then you can count. The number of SELECT queries differ from program to program so please specify your requirement clearly.

0 Kudos

Hi,

Thank you for the reply,

I just want to write a SE38 report program which accepts the PROGRAM NAME as input,

and gives output as all the SELECT quires present in that given program.

If i do with STRING operations, there may be a string with

1. 'SELECTION-SCREEN'

2. write / 'please select the radio button below'.

3. etc

so please suggest me how can write my logic...

Regards

SAM

0 Kudos

Hi Sam ,

Check this below Code .

DATA BEGIN OF SOURCE OCCURS 1000,

         LINE(256),

END OF SOURCE.

DATA: P_STATEMENTS LIKE SSTMNT OCCURS 100 WITH HEADER LINE.

DATA: P_TOKENS LIKE STOKEN OCCURS 100 WITH HEADER LINE,

       WA TYPE STOKEN .

PARAMETERS: PROGRAM LIKE SY-REPID DEFAULT SY-REPID,            " Pass Program Name

             SSTRING LIKE TUCHK3-OBJECT .                        " Search String example :  SELECT

READ REPORT PROGRAM INTO SOURCE .

SCAN ABAP-SOURCE SOURCE STATEMENTS INTO P_STATEMENTS  "Comment in chain

                         TOKENS       INTO P_TOKENS.

WRITE : / 'String' , 'Row Number' ,'Column Number' , 'Length'.

LOOP AT P_TOKENS INTO WA .

   IF WA-STR = SSTRING.

     WRITE 😕 WA-STR ,WA-ROW, WA-COL , WA-LEN .

   ENDIF.

ENDLOOP.

Regard's

Smruti

Former Member
0 Kudos

Hi,

I think this will help you.

http://saptechnical.com/Tutorials/ABAP/SQLTrace/page1.htm

Please do let us know if you are still facing the issue.

Regards

Purnand

Former Member
0 Kudos

Hi Sam,

There is an standard option to see all the SELECT queries in a given program.

GOTO SE38 ->UTILITIES -> INTERNAL PROGRAM ENVIRONMENT -> choose SELECT.

It will show you all the SELECT staments used in the program.

Regards,

Santanu Mohapatra.

Former Member
0 Kudos

Hi Sam,

Check this SAP Standard Program "RPR_ABAP_SOURCE_SCAN" .

Input Parameter :

Program Name :  your ABAP Program Name

Find string       :   what you want to search for the particular program 

Regard's

Smruti

0 Kudos

Hi Smruthi,

Thank you for immediate response...

I am using the same program but i am facing the issue, what i was discussing earlier.

if i give input search as SELECT it give me the output as lines like

SELECTION-SCREEN SKIP.

SELECTION-SCREEN COMMENT /1(20) TEXT-049.

if i give input search as SELECT * FROM .....i miss the queries with other format..

any specific logic to trace out all SELECT quires would be really appreciated....

Regards

SAM

matt
Active Contributor
0 Kudos

Use the program RS_ABAP_SOURCE_SCAN or RPR_ABAP_SOURCE_SCAN (there's no difference; the latter calls the former), but specify that the search is via "string is a standard expression". Then you enter a regular expression (regex) that exactly matches your requirements - which really is SELECT as an individual word.

You can read http://www.regular-expressions.info for details on how to use regex. In your case /bSELECT/b is probably what you need. 

Former Member
0 Kudos

Hi,

Writing a new program to find the select queries in a given program is not required and SAP has laready provided the SQL Trace tool for this.

BR

Nitin

former_member946717
Contributor
0 Kudos

Hi Sam,

Please elaborate on your requirement

Former Member
0 Kudos

Hi,

I think that the best way to work for this issue is submit standard report RPR_ABAP_SOURCE_SCAN.

Details:

into String searched for insert SELECT

into Program Name insert name of your report

flag 'X' into Ignore Comment Lines

Regard

Ivan

former_member189849
Contributor
0 Kudos

Hi Sam,

Using SQl trace (ST05) we can find right or ctrl+g or f (simply find ).

Regards

Mahesh