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

Scan ABAP Coding for SQL-Statements

Fabian_Kegel
Product and Topic Expert
Product and Topic Expert
0 Likes
2,056

Hi,

I am trying to write a coding scan tool that is able to find out all SQL Statements.

Therefore I am using the sytax

SCAN ABAP-SOURCE lt_code

TOKENS INTO tokens

STATEMENTS INTO statements

LEVELS INTO levels

STRUCTURES INTO structures

PROGRAM FROM ls_trdir-name

MESSAGE INTO message

INCLUDE INTO include

LINE INTO line

WORD INTO word

WITH ANALYSIS

WITH INCLUDES

WITH COMMENTS.

After that, I have to scan all the tokesn for commands like INSERT, MODIFY, SELECT,...

One of my problems is, that it is very hard to distinguish between an INSERT to a local table and a database table. Is there any easy way to find out if it is an SQL statement or not (maybe a type)?

Best regards,

Fabian

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,592

Hi Fabian,

have you take a look to the Code-Inspector (transaction SCI )? This tool works also with the "SCAN ABAP-SOURCE" command and provide also some checks for SQL-Statements.

If there is not a check routine that you are looking for, you can extend this tool with own routines:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f5d9a790-0201-0010-dd8c-baff999f8197">How to Build a New Check</a>

Regards,

Stefan

9 REPLIES 9
Read only

Former Member
0 Likes
1,592

Hi,

There are some standard programs that can SCAN the source code and return the suggestions, you can refer RPR_ABAP_SOURCE_SCAN program, this might give some clue about how to go about doing this,

Hope this helps,

Rgds,

Read only

0 Likes
1,592

hi,

you can validate the found table from the token

with db-table DD02L (tabclass <> INTTAB).

A.

Read only

Fabian_Kegel
Product and Topic Expert
Product and Topic Expert
0 Likes
1,592

Hi,

unfortunately, the function module RPR_ABAP_SOURCE_SCAN does not exist in my system (Basis 6.40). Could you please tell me, where you found this module?

Best regards,

Fabian

Read only

0 Likes
1,592

Hi,

It is not the function module, you can check in SE38 transaction, it is a report program,

Rgds,

Read only

Fabian_Kegel
Product and Topic Expert
Product and Topic Expert
0 Likes
1,592

Hi,

what about dynamic INSERTs like

INSERT (<variable>) FROM ls_sflight.

Read only

Fabian_Kegel
Product and Topic Expert
Product and Topic Expert
0 Likes
1,592

Thank you.. that was my fault.

Unfortunately this report just does the same like I am able to do. It only scans the coding for a certain string but it does not differentiate between internal tables and database tables.

Best regards,

Fabian

Read only

Former Member
0 Likes
1,593

Hi Fabian,

have you take a look to the Code-Inspector (transaction SCI )? This tool works also with the "SCAN ABAP-SOURCE" command and provide also some checks for SQL-Statements.

If there is not a check routine that you are looking for, you can extend this tool with own routines:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/f5d9a790-0201-0010-dd8c-baff999f8197">How to Build a New Check</a>

Regards,

Stefan

Read only

0 Likes
1,592

Fabian,

haven't you read my 1st post

-> here's another possibility:

look fm RS_CROSSREFERENCE and esp. prog. <b>LSEUWU02</b>

-line 300ff.

Andreas

Read only

Former Member
0 Likes
1,592

hi.

If you know standard transaction or program for purchase order or for any function . you can know the affected tables by that transaction or program USING TRANSACTION

'SE49'.

I am working on 4.6c it does exist in this version.

if does not exist on ur version

then other way to find affected tables by a transaction or program is--

first find the development class for that transaction (like Va01) then goto se80 and enter that development class .it will show all the tables affected .

steps to find Development class for example (Va01).

press F1 to any field then click on tech. info

(ii) double click on program name(SAPMV45B).

(iii) click on object directory entry in GOTO menu.

(iv) from here u will get Development class (VA).

now in se80 u will get all the databasec tables under the node object entry.

hope this will help.

Regards .

vikas