SAP Query Manager Parameter selection problem
Experts,
Declare @Fromdate datetime
Declare @ToDate datetime
set @Fromdate =(select MIN(T0.docdate) from OPCH T0 where T0.DocDate >='[%0]')
set @Todate =(select Max(T0.docdate) from OPCH T0 where T0.DocDate <='[%1]')
select
ROW_NUMBER() OVER (ORDER BY T0.DocNum) '#',
T0.DocNum 'AP Invoice Document Number',
T0.DocDate 'AP Invoice Posting Date',
T0.NumAtCard 'Vendor Ref No',
T0.CardName 'Vendor Name',
T1.ItemCode 'Item Code',
T1.Dscription 'Item Description',
T1.Quantity 'Quantity',
T1.LineTotal 'Gross Total',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '4') ), 0) 'VAT 4',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '5') ), 0) 'VAT 5',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '12.5') ), 0) 'VAT 12.5',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '14') ), 0) 'VAT 14',
T0.DocTotal 'Grand Total'
from OPCH T0 inner join PCH1 T1 on T0.DocEntry = T1.DocEntry
where T0.DocDate >= @Fromdate
and T0.DocDate <= @ToDate
This gives error again
Hi,
Try this one:
Declare @Fromdate datetime
Declare @ToDate datetime
set @Fromdate =(select MIN(T0.docdate) from OPCH T0 where T0.DocDate >='[%0]')
set @Todate =(select Max(T0.docdate) from OPCH T0 where T0.DocDate <='[%1]')
Select * FROM ( select ROW_NUMBER() OVER (ORDER BY T0.DocNum) '#',
T0.DocNum 'AP Invoice Document Number',
T0.DocDate 'AP Invoice Posting Date',
T0.NumAtCard 'Vendor Ref No',
T0.CardName 'Vendor Name',
T1.ItemCode 'Item Code',
T1.Dscription 'Item Description',
T1.Quantity 'Quantity',
T1.LineTotal 'Gross Total',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '4') ), 0) 'VAT 4',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '5') ), 0) 'VAT 5',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '12.5') ), 0) 'VAT 12.5',
ISNULL ((Select MAX(T2.TaxSum) from PCH4 T2 where (T2.DocEntry = T1.DocEntry and T2.LineNum = T1.LineNum and T2.staType = '1' and T2.TaxRate = '14') ), 0) 'VAT 14',
T0.DocTotal 'Grand Total'
from OPCH T0 inner join PCH1 T1 on T0.DocEntry = T1.DocEntry
where T0.DocDate BETWEEN @FromDate AND @ToDate ) as result
Thanks.
CLint
Similar Messages
-
Query Manager Input Date Problem
Dear expert,
When i paste the following code in query manager,
error is encountered.
What is the problem.
Regards,
Kit
Code:
declare @type int
declare @opening DateTime
declare @closing DateTime
declate @tmp DateTime
select @type = T0.ItmsGrpCod from [dbo].[oitb] T0 where T0.ItmsGrpNam = '[%0]'
select distinct @opening = T1.DocDate from [dbo].[oinm] T1 where T1.DocDate ='[%1]'
select distinct @closing = T2.DocDate from [dbo].[oinm] T2 where T2.DocDate = '[%2]'
/* swap date */
if @opening > @clsoing
begin
set @tmp = @opening
set @opeing = @closing
set @closing = @tmp
end
select ItemCode , BatchNum,
sum(Opening) as 'Opening',
sum(InQty) as 'InQty',
sum(OutQty) as 'OutQty',
sum(Closing) as 'Closing',
UnitCost ,
sum(TotalClosingStock) as 'TotalClosingStock',
sum(TotalOut) as 'TotalOut'
from (
select * from GetMovementReport(@type,@opening,@closing)
union
select * from GetSTMovementReport(@type,@opening,@closing)
) result
group by ItemCode , BatchNum, UnitCostHi Chun,
I can see couple of spelling errors:
1. declate @tmp DateTime must be: decla<b>r</b>e @tmp DateTime
2. if @opening > @clsoing should be if @opening > @cl<b>os</b>ing
3. set @opeing = @closing should be set @ope<b>n</b>ing = @closing
Hope it helps,
Adele -
SAP Query : Excel sheet download problem
Hi,
While executing a Z SAP query in SQ01 and data is displaying fine in the ALV format. But when we export the data to excel sheet, every column is appearing twice (repeating only the header, with empty items)
something like this......
Excel sheet...
Header MATNR MATNR MATKX MATKX LIFNR LIFNR KUNNR KUNNR
Item 10 Test ABC ABC
20 Test2 XYZ XYZ
30 Test3 MNO MNO
What can be possible cause of this ? What can be the corrective step to the issue?
Thanks,
JaiHi ,
Please follow the below step .
In SQ01 --> In the List Display screen --> click on Export --> Local file --> Spread Sheet --> Give the File name and click on generate .
It s working file . and i can be able to download all the records to excel without any repeatation .
Thanks
Pavendhan -
RSDMWB - Create Model - BW Query Model Field Selection - Problem
I am trying to create a Data Mining model.
In RSDMWB I select "Create Model" in the right click context menu after selecting a Data Mining model.
In the "Create Model" window I try to select a BW Query I have previously created as source for Model Field Selection.
To find the query I press F4 and get a list of available objects sorted by InfoAreas. However, the InfoArea containing my InfoProviders and the BW Queries is not visible.
If I try selecting a BW Query that is visible this BW query does not appear in the BW Query field in the Create Model window.
However as I press 'enter' I get a field selection list!
Last but not least, I cannot type manually a BW Query name in the abovementioned BW Query field.
I am not sure it is related, but I found a note about some UI problem at model creation
"Data Mining: UI adjustment SAP Note Number: 851886". It says that BW35 SP14 should be needed. I am currently on SP12.
Does anyone have the same problem. What is the solution to it?
Claudio Ciardelli
SAP BI Consultant at Unisys.Hi,
- do you see the variables from the BW query in Crystal Reports ?
- where in the BW query are the variables defined ?
Ingo -
Hi,
I am doing SAP query, If I select Company Code, i need to get the resule of
GL a/c, Buss Area, Cost Center, Profit Center
For this in table joints i taken KNA1, KNB1, SKB1, CSKS
then also i could not run the report.
Rgds
sunficoHello
When you have chosen a query and a user group on the initial screen, you can execute the query online or in the background.
Executing Queries Online
Executing Queries in the Background
Improving Response Times
Interactive Functions for ABAP Lists
Direct Interaction
Check this link for further notes executing queries
http://help.sap.com/saphelp_erp2005vp/helpdata/en/b7/26ddebb1f311d295f40000e82de14a/frameset.htm
regards -
Is it possible to use aggregation function in SQ Sap query?
I need to create a sap query like using SELECT MAX(begda) statement.
Please teach me how...
Thank u in advance..Hi Ella,
You can very well use the aggregate functions in sql which is usually a performance tuning technique.
A calculation that is made on several records or cells of data. SUM, AVG, MAX, MIN and COUNT are examples of aggregate functions that are used in spreadsheets and database programs.
SELECT ( ( ] ...
MAX: returns the maximum value of the column
MIN: returns the minimum value of the column
AVG: returns the average value of the column
SUM: returns the sum value of the column
COUNT: counts values or lines as follows:
· COUNT( DISTINCT ) returns the number of different values in the column.
· COUNT( * ) returns the total number of lines in the selection.
Ex: DATA: fldate LIKE sbook-fldate,
count TYPE i,
avg TYPE p DECIMALS 2,
max TYPE p DECIMALS 2.
SELECT fldate COUNT( * ) AVG( luggweight ) MAX( luggweight )
FROM sbook
INTO (fldate, count, avg, max)
WHERE carrid = 'LH' AND
connid = '0400'
GROUP BY fldate.
WRITE: / fldate, count, avg, max.
ENDSELECT.
For further info:
http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3990358411d1829f0000e829fbfe/content.htm
http://help.sap.com/abapdocu/en/ABAPSELECT_AGGREGATE.htm
Thanks and Regards
Srikant.P
Edited by: SRIKANTH P on May 27, 2009 9:41 AM -
Which Table Store the Query in the Query Manager?
Hello, I have looking for the table which store all the query inside the Query Manager.
From this i can retrieve the query without open the program.
Please help. Thanks.Hi William,
Try this Queries in MSSQL Server Management Studio and dont use Query Generater.
1. Run this Query, Result: Query Manager Details
SELECT * from OQCN
2. Run this Query, Result: Query Details on Query Manager
SELECT * from OUQR
Regards,
Madhan. -
HI All,
1..While creating an SAP Query, I have selected the field groups, then fields, selected basic list, entered the sequence, etc and then also enetered alternate text for control level. When i execute the report, the error message displayed is 'no data selected'. How can i rectify this issue?
2. I would also like to add the field 'Deductions' under field group 'Payroll Results'.
Thanks and Regards,
AM_BLRUsing the messaging service in the b1 i achieve this
SAPbobsCOM.CompanyService oCmpSrv;
MessagesService oMessageService;
Message oMessage;
MessageDataColumns pMessageDataColumns;
MessageDataColumn pMessageDataColumn;
MessageDataLines oLines;
MessageDataLine oLine;
RecipientCollection oRecipientCollection;
oCmpSrv = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
oMessageService = (MessagesService)oCmpSrv.GetBusinessService(ServiceTypes.MessagesService);
oMessage = (Message)oMessageService.GetDataInterface(MessagesServiceDataInterfaces.msdiMessage);
oMessage.Subject = "My Subject";
oMessage.Text = "My Text";
oRecipientCollection = oMessage.RecipientCollection;
oRecipientCollection.Add();
oRecipientCollection.Item(0).SendInternal = BoYesNoEnum.tYES;
oRecipientCollection.Item(0).UserCode = "test";
pMessageDataColumns = oMessage.MessageDataColumns;
pMessageDataColumn = pMessageDataColumns.Add();
pMessageDataColumn.ColumnName = "My Column Name";
oLines = pMessageDataColumn.MessageDataLines;
oLine = oLines.Add();
oLine.Value = "My Value";
oMessageService.SendMessage(oMessage); -
Reading Archived Data Through SAP Query Report
Dear SAP Gurus,
My client archived their SAP data in a particular year range and all the Z reports have to modified to read these archive data. Normal ABAP reports can be modified to read the archive data without no problem.
But there are two Z SAP query reports which should be modified the same way so it will be able to read archive data.
What is the best method for this? Does SAP Query tool provide facility to read archive data? or do I have to append the code?
Thank you in advance for your help
Regards,
Isuru Fernando>
Isuru U Fernando wrote:
> hi Manthan,
>
> Yes I used these FMs and read the data without any problem for normal ABAP reports.
>
> But SAP query report is the problem. Is it advisobale to modify the SAP query generated report source code? since it is a system generated report.
>
> Regards,
> Isuru
No, do not adapt the SAP generated report source. The reason is: every time someone re-generates the query from tx. SQ01 your changes will be lost.
You could add the functionality Manathan gave you to add to the infoset of said query - but to be honest: in my opinion that is shooting nuclear rockets at flies. Also you run the risk that every change of the infoset (add a join/delete a join) requires adjustment of said coding you applied ... and where will you be then? Fancy repairing the same query over and over again? Try talk sense to your client - go for a Z-report here ... -
Query Manager SQL DateDiff and Parameter Problem
Im having trouble with a date calculation in the Query Manager. Im wondering if anyone has run into something similar.
I am trying to write a query that returns records that are X days old, where X is a parameter input by the user.
Heres an example you can paste this into your system and duplicate the issue:
<b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= [%0]</b>
Returns a date error code if you try to input an integer (e.g. the "Define Survey Variables" dialog is looking only for date values)
However
<b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= 30</b>
Works just fine.
Any ideas?> I tried your query and it's working perfection for
> me. I'm using SBO B1 2005 A.
>
> The [%0] in your case is looking for the type of the
> critary and because it sees T0.DocDueDate it thinks
> you should give the query with a date and not a
> numeric. Maybe you cshould try to add a casting
> function to return a numeric ?
Merci Daniel,
I too am using SBO B1 2005 A (PL 22)
I should have expanded on my original problem. I have tried using CAST and CONVERT in the following ways:
<b>SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where datediff(dd, T0.DocDueDate, getdate()) <= CAST([%0] as Integer)
SELECT T0.DocNum, T0.DocDueDate FROM ORDR T0 where cast(datediff(dd, T0.DocDueDate, getdate())as Integer) <= [%0]
</b>
also
<b>SELECT T0.DocNum, T0.DocDueDate, cast(datediff(dd, T0.DocDueDate, getdate())as Integer) as Date FROM ORDR T0 where Date <= [%1]</b>
Nothing seems to work (although I could be getting the syntax wrong) -
How to add drop down list for query manager report in sap business one
Hi Every one,
I need drop down list for parameter selection in sap business one Query Manager.I have two Parameters 'Sales Order','Invoice'.
Please suggest.
Thanks and Regards
DEVHi,
you need to use this :
/*select from [dbo].[OINV] T2*/
DECLARE @Invoice varchar(100)
/*where*/
set @Invoice =/* T2.DocNum */N'[%2]'
you can change the tables and the parameter number but you have to write it exactly that way.
when you run the query within the SBO you will get list of objects ( in this case list of invoices)
hope it was helpful
Shachar -
Pass parameter to sql statement in query manager
Hai to all,
I want to pass the percentage as the parameter into the sql statemnet.i what to execute it in the query manager.
If i execute that statement then cann't found the tablename error is coming.
Other than the data in the table (general data) pass to the parameter in the sql at runtime.
for example:
select [%0] *100
how to pass 10 to that sql statement.
Please help me...
Regards,
Raji.Hi Ramya,
You can create a SP with parameters to accept and then execut this SP from SAP Business One Query Manager by passing the parameter (in your case 10). The result will be as desired.
Ex:
Create this Procedure in SQL Management Studio
create proc Test(@a as int)
as
begin
select (@a*100)
end
To Execute the Query use this Query and pass the desired values with parameters
execute Test 10
Regards,
Reno -
At line-selection in SAP Query ( Infoset ) code
Hi all ,
Here is one for you : can I put somehow the following code in a Sap Query ( at infoset level of course ) :
at line-selection.
set parameter id 'BUK' field XXX-bukrs.
set parameter id 'BLN' field XXX-belnr.
set parameter id 'GJR' field XXX-gjahr.
call transaction 'FB03' and skip first screen.
(In other words I would like to see the documents behind a line in the list)
Some explains : my query's output would be ABAP list , the bukrs, belnr, gjahr fields are on the lines of my resulting list, and my problem is with those XXX 's - I don't know where are stored the lines of my ABAP list.
I'm pretty new at ABAP so any idea and explains about the generated SAP Query code
is appreciated . I looked at the final code but seemed very complex for my level.
Please guide me in this area ( I know the basic things like writing pretty simple reports )
Thanks !
Best of all
ZoliHi,
You need to add extra piece of code as below:
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
* FORM USER_COMMAND *
* --> R_UCOMM *
* --> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
* Check function code
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
* Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
* Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
* Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
"For further information please refer the link below :
http://www.sapdev.co.uk/reporting/alv/alvgrid_ucomm.htm
Thanks,
Sriram Ponna. -
Query Manager Condition Problem
Dear expert,
In B1 query manager, i found a report called 'Production Order Report' and there is a searching condition which i don't understand.
Code:
T3.CardName= '[%9]' or '[%9]' = ''
If user dose not input this parameter, how the query manager handle the query??Hi Kit,
The query code you mentioned basically says that if the [%9] variable is blank, don't filter on it, else filter on it. You can test it with this query
declare @Code varchar(15)
set @Code= ''
--set @Code = 'C1000'
select * from ocrd where (Cardcode= @Code or @Code = '')
If you run it as is, all records in OCRD will be returned, if you run it with the commented line uncommented it will return only C1000.
Hope it helps,
Adele
<i>PS: I have seen that every post you make you set as answered/solved problem already. Please make sure which problems are solved and which not. People tend to not look at solved posts that often. Every question you asked have been marked as solved before anyone replied. Were they solved?</i> -
SAP Inventory Manager 4.0 installation problems
I am having problems when trying to install the new version of Inv Manager 4.0 on windows server 2008. The installation is performed by first installing and patching to latest release an SMP 3.0 server, followed by an installation of the SAP Inventory Manager 4.0.0 Deployment exe file. That installation runs without any errors but no app is visible on the SMP, no folders or shortcuts or other indications are visible that it was successful. Also very strange is that according to the installation guide there are some steps (1-6) which I cannot see, my install runs jumps directly from step 3 step nr. 7 (serial numbers, install type, keys are all missing or not requested by the installation for some reason). I have installed this on 4 different servers/PC´s where at least 2 of those were totally fresh systems that didn´t have any previous installation of either Agentry or SMP. The prerequisites are met (java, jco etc) but what puzzles me the most is that I don´t see any logs or error messages.
Help is much appreciatedBjorn,
At very high level...
1) Install SMP Server with Latest support pack. you don't need to enter any server serial numbers details.
2) Logon to SMP Management cockpit.
3) create Agentry application for Inventory Manager and save it.
4) Once Agentry application is created under server->configuration folder you can see a folder created.
Server\configuration\com.sap.mobile.platform.server.agentry.application.
5) Execute SAPInventoryMgr400Deployment.exe by entering SAP back end connection details.
6) Once you complete step 5), you have IM 4.0 deployment application is created. at this point you can copy all the deployment folder contents to application folder created in step 4) or do publish from editor or follow step 5.
5) Select Agentry application ->go to App Specific settings tab ->Under publish option "upload your Inventory Manager deployment zip file" and save the changes.
6) Re-start the Server.
7) Test if your application is deployed correctly by entering URL in the browser https ://<hostname>:8081/<appname> . you should get response as 'I'm here".
8) if step 7) is not successful then troubleshoot Agentry app deployment ( turn on agentry logging and check for startup errors ).
check this thread for SMP 3.0 Server Installation troubleshooting.
Query on SMP 3.0 - Working with Agentry Client
Thanks,
Manju.
Maybe you are looking for
-
What is difference between abstraction and encapsulation ?
Hi, I am trying to figure out the difference between abstraction and encapsulation but confused. Both are used for data hiding then what is the exact difference ? Thanks.
-
Billing plan reference joined to a material number
Hello to all We have to join material number with a billing plan reference before the creation of the sales order. The issue is that you can join a billing plan reference(with the distribution of the amount between the different dates in a percent) w
-
How can i downgrade to my iOS 6? I dont like iOS7.
Hello people, I have a iPhone 4S, I've recently upgrade to iOS7...OMG what i've i done !! I dont like it at all... the calendar and notes are pretty useless now, everything turned white, even the date cursor on "starts" option (date/hour) its hard to
-
After updating to ios 7.0.3 my wifi has been DISABLED and BLUETOOTH. Need help
I need some help. How can I fix my iPhone4s? Yesterday I updated my ios to the newest version using my handset. And then early morning while using it the wifi suddenly turned off. I restarted my handset but still the same. The wifi still disabled. I'
-
Hi All, I need to retireve the Header text of Sales orders. I am able to fetch the Text using READ_TEXT Function module with proper import parameters. My requirement is to display such header texts against each sales order. If a particular sales ord