One important (and cool) feature of SQL Cockpit is an ability to auto-generate ABAP reports directly from the SQL query entered in the cockpit.
We illustrate below, one example of how this may be utilised
As you can see from the code snippet and screenshot below, suppose we want to generate a report output that executes a relatively complex select query :
FROM but000 INNER JOIN but020 ON but000~partner = but020~partner
LEFT OUTER JOIN adrc ON but020~addrnumber = adrc~addrnumber
but000~partner IN &PARTNER&
AND but000~type = '1'
AND but000~bpkind = ''
and but020~addr_valid_to = '99991231235959'
AND but020~nation = ''
AND adrc~title = ''
AND adrc~name1 = ''
AND adrc~city1 = 'Wien'
If you want to generate SAP report that executes this query, it would be a tedious and repetitive work to create a report manually in ABAP. Report generation feature of SQL Cockpit makes this work much simpler and quicker as illustrated below (We have implemented customer requirements with many more fields and complex select query that pulls data from upto 10 database tables!).
After executing the SQL query, just click on the highlighted „Template“ icon and „Select Template“ textbox appears
Choose an ‚advanced‘ option in the screenshot above.
We are taken to the Report Template Wizard
Enter the report name, description, and other optional information. Note that „Tabular Selection Blocks“ checkbox to generate multiple tabs on the selection screen is selected. Continue to the next window
As shown below, we get a list of selection screen field options, (also auto-generated from the WHERE condition of the SQL query 🙂 )
As shown above, we have three options…
- create a selection screen field with an auto-populated value from the SQL where condition
- create a selection screen field without an auto-populated value from the SQL where condition
- Select query of a generated report will contain hard-coded value from the SQL where condition
Click on Continue button again after making your selections from one of these options
Finally, a generate report option is presented along with a list of specified report parameters in the previous step as seen below
Click on the Generate Report button
Select package as applicable and we are done.
A generated report can be viewed / executed in SE38 like any other custom report.
Note the selection screen as seen below (with different selection screen tabs for fields from different tables)
Here is a screenshot from the select query (that was also auto-generated, of course 🙂 )
As highlighted in the screenshot, one of the where condition was created with a hard-coded values from the select query („Wien“) as per the selection in the report generation template!
Conclusion: we can auto-generate complex SAP reports using SQL Cockpit in less than 15 minutes! We can even customize special features based on individual client requirements.
This saves a lot of a lot of repetitive work for programmers and power users 😉