Thursday 12 January 2017

zSQL: A tool to execute SQL statements directly in sap

Sometimes i need to write sql statements and get results immediately in abap. To handle this requirement, i create a test program, write my sql in it and debug to investigate results.  It’s difficult and time consuming work so I have developed an SQL tool for ABAP Programmers to allow them to run select statements directly in SAP, confirm or discover relationships and see data side by side.
Installation:

1- Create an executable program  and named it “ZSQL” in se38

2- Download attached zSQL.txt.zip file and Upload into zsql(or copy&paste)
(Source Code: https://blogs.sap.com/2013/10/20/zsql-a-tool-to-execute-sql-statements-directly-in-sap-source-code/ )

3- Create screen ‘0100’

4- Go into screen ‘0100’, choose “Flow Logic” tab and add flow logic code as below

5- Go to layout of screen and add a “Custom Control” and name it “CC_SQL”

6- In layout add two buttons

     -Run: FctCode: “RUN”

     -Exit: FctCode: “EXIT”

7- Activate screen

8- Activate program

Flow Logic Code:

PROCESS BEFORE OUTPUT.

   MODULE status_0100.

PROCESS AFTER INPUT.

   MODULE user_command_0100.

Notice:

     – Each FROM/JOIN clause must be in new line

     – Table names&Aliases and From/Join clauses must be in the same line

     – Don’t use SELECT SINGLE

     – Don’t use INTO statement

     – Doesn’t support aggregate functions(e.g. SUM, MAX, AVG)

     – DELETE/UPDATE statements are not supported in default, but you can allowed in test systems by uncommenting lines in subroutine “check_operation”

Examples:

zSQL: A tool to execute SQL statements directly in sap

zSQL: A tool to execute SQL statements directly in sap

*

zSQL: A tool to execute SQL statements directly in sap

zSQL: A tool to execute SQL statements directly in sap

*
zSQL: A tool to execute SQL statements directly in sap

*

zSQL: A tool to execute SQL statements directly in sap

I didn’t change my original code because of the easy installation cares, And also putting screen shot to give you an idea how it can be modified for better user experience

zSQL: A tool to execute SQL statements directly in sap

No comments:

Post a Comment