Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
55 views

Sample - SQL Report - How To Keep Last Parameter Value in Query

SQL Report

Uploaded by

Sai Yugesh Smart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Sample - SQL Report - How To Keep Last Parameter Value in Query

SQL Report

Uploaded by

Sai Yugesh Smart
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

B1 Usability Package Sample

Date: 19/02/2017

SQL Report – Samples – How to keep last parameter values in SQL


Query Report

Summary
Module Universal functions
Level Advanced
Requirements B1UP 2015.08 or higher

Description
This sample will show you how to keep the last parameter values entered so that there is no need to
enter the value every time. You will only need to update the fields required if you need changes.

Pre-Requisite
In this example we have a query on Sales Orders information with 4 parameters, ‘From Date’, ‘To
Date’, ‘From BP’ & ‘To BP’ please see query below.

SELECT T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocNum], T0.[DocTotal]


FROM ORDR T0
WHERE T0.[DocDate] >[%0] AND T0.[DocDate] <[%1] AND T0.[CardCode] >[%2] AND
T0.[CardCode] <[%3]

This Query when run will pop up the following screen prompting user to fill in the values every time. If
user wants to run it with a different set of BPs then they have to enter the Dates again.

So in order to help user to save this hassle, we will first create a User-Defined Table with 4 fields. Each
field will correspond with each of the parameters and put in some values to start.

.
Copyright 2011 – Boyum IT A/S Page 1/3
B1 Usability Package Sample

In my example above I called it QRY_PARA which means in SAP it is called @QRY_PARA


Note: you are welcome to call it something else but please remember to change the table name in the
query below.

Add and Edit Menu

We will now create a Menu Item for the SQL Report. (Note: you can assign this function to a button or
any other Validation event, it is optional to create a menu item)

Under the Function Column, we will create our new Universal Functions.

Universal Functions

We will create a Universal Function of the type SQL Report. We will create 4 variables making them
equal to the fields from the User-Defined Table that we just created. The Query is as below:

Declare @fromdate datetime = (select U_FromDate from SBODemoUS.dbo.[@QRY_PARA])


Declare @todate datetime = (select U_ToDate from SBODemoUS.dbo.[@QRY_PARA])
Declare @fromBP nvarchar(20) = (select U_FromBP from SBODemoUS.dbo.[@QRY_PARA])
Declare @toBP nvarchar(20) = (select U_ToBP from SBODemoUS.dbo.[@QRY_PARA])

SELECT T0.[CardCode], T0.[DocDate], T0.[CardName], T0.[DocNum], T0.[DocTotal]


FROM ORDR T0
WHERE T0.[DocDate] >= @fromdate AND T0.[DocDate] <= @todate
AND T0.[CardCode] >= @fromBP AND T0.[CardCode] <= @toBP

We also need to make sure select the Refresh Data Button option.

Copyright 2011 – Boyum IT A/S Page 2/3


B1 Usability Package Sample

Next we will run this SQL report. When the Report is displayed, we will right click and select ‘B1
Usability Pack’ > Add or Edit Function Button.

Copyright 2011 – Boyum IT A/S Page 3/3


B1 Usability Package Sample

Then in the Button Configuration, we give the button a name and assign a new Universal Button which
Open the User-Defined Table. This will allow user to Update the values of the parameter.

We go to View > System Information and enable it.

Copyright 2011 – Boyum IT A/S Page 4/3


B1 Usability Package Sample

Then we go to Tools > User-Defined Windows, locate our User Defined Table and hover our arrow on top
of the table. We can then look at the lower left hand corner to find out about the Menu UID of this table.
In my example, the Menu UID is 51285

We will now create our second Universal Function and Assign it to the Set Parameter button that we just
created. The Syntax is just Activate(51285); using the Menu UID that we just found out. Then we Add this
function and another Add when back in the Button Configuration window.

Copyright 2011 – Boyum IT A/S Page 5/3


B1 Usability Package Sample

Result
When menu item of the Sales Order SQL Report is click, the SQL report will be displayed using the initial
values we put in the User-Defined Table. If customer wants to change the parameter, say now they want
to see Sales Order for the year 2006 as well, then all they have to do is to click the ‘Set Parmeter’ to open
the User Defined Table to update the parameter value

In our example we are changing the FromDate to 01/01/2006 and click Update.

Copyright 2011 – Boyum IT A/S Page 6/3


B1 Usability Package Sample

Back in the SQL Report, user will need only to click the ‘Refresh’ button to see fresh data. This will save
them the need to re-type the other parameters.

Copyright 2011 – Boyum IT A/S Page 7/3

You might also like