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
Similar Messages
-
Using a function module in ABAP Query
Hi All,
I want to use a function module in ABAp query in the Record Processing Section.
In the report program we click on Pattern button to inser the function module so that all the Importing and exporting parameter automatically appears.
Similarly is there any particular method of inserting a function module in ABAp Query.
Regards
Manipal ParkalaWhen you are doing the infoset for the query (SQ02) you can add coding by clicking the coding tab. You can chose in wich event you want your coding and there is Pattern Button for you to easy use.
If you don't want to put the code in the infoset just in the query then is not posible.
Nevertheless, I higly descourage the use of coding in queryies. If you need to insert some coding make an ALV its easier, clearer and much easier to mantain.
Hope it helps. -
Can we call function modules in SAP query or ADHOC query
Hi ,
Can we call afunction moudule in sap query or ADHOC query ?If yes How
An early responce is greatly appreciated
Thanks and best regards
Rajeev ChhabraHello Rajeev Chhabra,
Yes; you can call function module in SAP Query. In InfoSet definition (SQ02), you can create additional field. In this field definition, you can add code snippet where you can function module.
However, this is not possible in Quick Viewer (SQVI) Query.
Thanks,
Venu -
Elvis: Is It possible to use the Function Generator and the Oscilloscope simultaneously?
Hi,
We are using the NI Elvis to output a function or a sine wave at a certain frequency and using the oscilloscope on the same board/elvis to read a modified signal. Is this possible? Can we use both the Function Generator and the oscilloscope at the same time? Please help. The oscilloscope would be reading signal from an accelerometer. Thank you in advance. We have no VI as we do not know which to use and if they are possible.Hi,
There is no problem using the Function Generator and Oscilloscope
at the same time with NI ELVIS. Using the NI ELVIS soft front panels (Start
>> Programs >> National Instruments >> NI ELVIS 3.0 >>
NI ELVIS – see picture attached –‘NI ELVIS soft front panels.JPG’), you can choose
to open more than one instrument at a time. We do this by opening one
instrument, allowing it to begin, and then opening another. We can also program
in LabVIEW using more than one instrument at a time by placing down multiple
Express VI’s taken from the NI ELVIS pallet on the block diagram (see picture
attached – ‘ELVIS Express VI's (LabVIEW).JPG’). One note when doing this,
please see KB 41ODPHX1
for an example of how to program in parallel. If you do not wire the ‘stop’
terminal of the express VI’s, you will get the error described.
David L.
Systems Engineering
National Instruments
Attachments:
ELVIS Express VI's (LabVIEW).JPG 74 KB
NI ELVIS soft front panels.JPG 56 KB -
Is it possible to use Click Function in Dropdownbox?
Hello everybody,
I have a question on dropdownbox GUI element:
is it possible to use the attribute of DropDownBox to realize the 'Click ' function?That means when one value from DropdownBox being selected,some action will be done.
I checked the attributes of dropdownbox,and found maybe the following ones will help
onselect = ?
selection = ?
onclientselect = ?
are they correct?or which kind of attributes are
corresponding to?
Thanks in advance!
Liying
Message was edited by: Liying WangHi Liying,
Welcome to SDN!!
See, the highlighted part in the code, that will genrate a server side event for you upon selection:
<htmlb:dropdownListBox id = "DDLB1"
table = "<%= projectid_tab %>"
<b> onSelect = "DDLB1Event"</b>
selection = "<%= tab1sel %>"
nameOfValueColumn = "name"
nameOfKeyColumn = "value" />
Now we can catch the event in event handler as:
DATA: event TYPE REF TO if_htmlb_data,
ddlb_event TYPE REF TO cl_htmlb_event_selection.
DATA: data TYPE REF TO cl_htmlb_dropdownlistbox.
event = cl_htmlb_manager=>get_event( request ).
case event->event_id.
when 'DDLB1'.
ddlb_event ?= event.
IF ddlb_event->id EQ 'DDLB1' .
tab1sel = ddlb_event->selection .
ELSEIF ddlb_event->id EQ 'DDLB2' .
tab2sel = ddlb_event->selection .
ENDIF .
endcase.
Hope this helps,
Regards,
Ravikiran.
PS:Consider rewarding points for helpful replies. -
Using a function in a report query
Why can't I call a function (basically a query) in a report query like I can from from SQL?
Consider the following:
Select MyFunctionName(arg) from dual;
From SQL, it works great! No problem:
In a report query, [Application/Shared Components/Report Queries] It doesn't work. I get an XML error:
XML Parsing Error: not well formed
<MyFunctionName('arg')><?xml version="1.0"?>
----------------------^
Why?
Looks like APEX is not even executing the function...
See I have a table with a CLOB field that contains properly formatted HTML. I cannot simply query for that content, since Oracle escapes the tags in the conversion to XML. I have to (somehow) tell Oracle to keep it's grubby mitts off my CLOB content. As far as I can tell, using DBMS_XMLGEN.setConvertSpecialChars is the only way to keep Oracle from escaping the html stored in the table--in fact, the DBMS_XMLGEN documentation states that it why this functionality exists in the first place!
This is why I am trying to use a function. Simply queries don't work. The function I wrote works beautifully in SQL, but not in a report query...
Edited by: Vorlon on Aug 5, 2010 1:20 PMNote from the first post:
"In a report query, [Application/Shared Components/Report Queries]" Let me clarify: This report query is used in a BI Publisher report. Getting the information to the screen isn't the problem. I have that working. :-) It's just when I try to get the report to print that I see APEX has escaped the output before reaching BI Publisher--so BI Publisher is not the issue. I have a xsl template that will process the embedded HTML, but APEX is escaping my data before I can act on it. In other words:
It seems Apex is not creating the XML properly, since it escapes everything. Even when the function passes back data correctly.
Has anyone else seen this? Ideas for a workaround?
Thanks! -
How to use MAX function in SSAS MDX Query
I want to run this Query with MAX Condition on LAST_DATA_UPDATE Column .
Hi Ashishsingh,
According to your description, you want to know how to use MAX function in SQL Server Analysis Services MDX Query, right? In this case, please refer to the link below which describe the syntax and sample of MDX function.
http://technet.microsoft.com/en-us/library/ms145601.aspx
http://www.mdxpert.com/Functions/MDXFunction.aspx?f=64
Hope this helps.
Regards,
Charlie Liao
TechNet Community Support -
Using substr function loses index. Query tune help
Hi
when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
select
pap.full_name employe_name,
k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
a.invoice_num Invoice_Number,
b.item_description Line_Item,
b.amount Amount,
cc.trx_id Corporate_Card_Transaction_Id,
cc.transaction_date Date_Charge_Incurred,
cc.posted_date Date_Charge_Posted_To_USBank,
cc.creation_date Date_Posted_To_IExpense,
a.creation_date Expense_Report_Creation_Date,
l.report_submitted_date Expense_Report_Submitted_Date,
mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
e.check_date Payment_Date_To_USBank,
e.check_number Payment_Number,
mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
pbl_apprv_lst.activity_result_display_name AP_Process_Result
from
ap_checks_all e,
ap_invoice_payments_all d,
ap_invoices_all c,
ap_expense_report_headers_all a,
ap_credit_card_trxns_all cc,
per_all_people_f pap,
ap_expense_report_headers_all l,
ap_expense_report_lines_all b,
gl_code_combinations k,
(select ias1.user_key,
ias1.activity_result_display_name,
ias1.activity_begin_date,
ias1.activity_end_date
from wf_item_activity_statuses_v ias1,
(select c1.invoice_num
from ap_checks_all e1,
ap_invoice_payments_all d1,
ap_invoices_all c1
where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
and nvl(:To_Date, trunc(e1.check_date))
and e1.org_id = 141
and e1.void_date IS null
and d1.check_id = e1.check_id
and c1.invoice_id = d1.invoice_id) inv_lst1
where ias1.item_type = 'APEXP'
and ias1.user_key = inv_lst1.invoice_num
and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
(select ias2.user_key,
ias2.activity_result_display_name,
ias2.activity_begin_date,
ias2.activity_end_date
from wf_item_activity_statuses_v ias2,
(select c2.invoice_num
from ap_checks_all e2,
ap_invoice_payments_all d2,
ap_invoices_all c2
where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
and nvl(:To_Date, trunc(e2.check_date))
and e2.org_id = 141
and e2.void_date IS null
and d2.check_id = e2.check_id
and c2.invoice_id = d2.invoice_id) inv_lst2
where ias2.item_type = 'APEXP'
and ias2.user_key = inv_lst2.invoice_num
and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
where
trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
and nvl(:To_Date, trunc(e.check_date))
and e.org_id = 141
and e.void_date IS null
and d.check_id = e.check_id
and c.invoice_id = d.invoice_id
and a.invoice_num = c.invoice_num
and a.source = 'CREDIT CARD'
and a.employee_id = nvl(:Emp_id,a.employee_id)
and a.report_header_id = b.report_header_id
and cc.trx_id = b.credit_card_trx_id
and pap.person_id = a.employee_id
and pap.effective_start_date <= trunc(sysdate)
and pap.effective_end_date >= trunc(sysdate)
and k.code_combination_id = b.code_combination_id
and k.segment2 between nvl(:From_Cost_Center,k.segment2)
and nvl(:To_Cost_Center,k.segment2)
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_keyHi
If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
and a.invoice_num like l.invoice_num || '%'
and c.invoice_num like mgr_apprv_lst.user_key || '%'
and c.invoice_num like pbl_apprv_lst.user_key || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
and a.invoice_num between l.invoice_num * 1000000
and l.invoice_num * 1000000 + 999999I hope this makes sense...
Luis -
Use data in structure in SAP Query
I am creating a SAP query using a logical database but will like to include data from a Structure can anyone help me.
Do not worry about this topic, I have obtained the result by myself, it can be done with global variables. The error was in the initialization of some of the variables involved.
Thank you any way and forgive me for the disturbance.
Sinceresly,
Miguel. -
Date ranges - possible to use analytic functions?
The next datastructure needs to be converted to a daterange datastructure.
START_DATE END_DATE AMMOUNT
01-01-2010 28-02-2010 10
01-02-2010 31-03-2010 20
01-03-2010 31-05-2010 30
01-09-2010 31-12-2010 40Working solution:
with date_ranges
as ( select to_date('01-01-2010','dd-mm-yyyy') start_date
, to_date('28-02-2010','dd-mm-yyyy') end_date
, 10 ammount
from dual
union all
select to_date('01-02-2010','dd-mm-yyyy') start_date
, to_date('31-03-2010','dd-mm-yyyy') end_date
, 20 ammount
from dual
union all
select to_date('01-03-2010','dd-mm-yyyy') start_date
, to_date('31-05-2010','dd-mm-yyyy') end_date
, 30 ammount
from dual
union all
select to_date('01-09-2010','dd-mm-yyyy') start_date
, to_date('31-12-2010','dd-mm-yyyy') end_date
, 40 ammount
from dual
select rne.start_date
, lead (rne.start_date-1,1) over (order by rne.start_date) end_date
, ( select sum(dre2.ammount)
from date_ranges dre2
where rne.start_date >= dre2.start_date
and rne.start_date <= dre2.end_date
) range_ammount
from ( select dre.start_date
from date_ranges dre
union -- implicit distinct
select dre.end_date + 1
from date_ranges dre
) rne
order by rne.start_date
/Output:
START_DATE END_DATE RANGE_AMMOUNT
01-01-2010 31-01-2010 10
01-02-2010 28-02-2010 30
01-03-2010 31-03-2010 50
01-04-2010 31-05-2010 30
01-06-2010 31-08-2010
01-09-2010 31-12-2010 40
01-01-2011
7 rows selected.However, I would like to use an analytic function to calculate the range_ammount. Is this possible?
Edited by: user5909557 on Jul 29, 2010 6:19 AMHi,
Welcome to the forum!
Yes, you can replace the scalar sub-queriy with an analytic SUM, like this:
WITH change_data AS
SELECT start_date AS change_date
, ammount AS net_amount
FROM date_ranges
UNION
SELECT end_date + 1 AS change_date
, -ammount AS net_amount
FROM date_ranges
, got_range_amount AS
SELECT change_date AS start_date
, LEAD (change_date) OVER (ORDER BY change_date) - 1
AS end_date
, SUM (net_amount) OVER (ORDER BY change_date)
AS range_amount
FROM change_data
, got_grp AS
SELECT start_date
, end_date
, range_amount
, ROW_NUMBER () OVER ( ORDER BY start_date, end_date)
- ROW_NUMBER () OVER ( PARTITION BY range_amount
ORDER BY start_date, end_date
) AS grp
FROM got_range_amount
SELECT MIN (start_date) AS start_date
, MAX (end_date) AS end_date
, range_amount
FROM got_grp
GROUP BY grp
, range_amount
ORDER BY grp
;This should be much more efficient.
The code is longer than what you posted. That's largely because it consolidates consecutive groups with the same amount.
For example, if we add this row to the sample data:
union all
select to_date('02-01-2010','dd-mm-yyyy') start_date
, to_date('30-12-2010','dd-mm-yyyy') end_date
, 0 ammount
from dualThe query you posted produces:
START_DAT END_DATE RANGE_AMMOUNT
01-JAN-10 01-JAN-10 10
02-JAN-10 31-JAN-10 10
01-FEB-10 28-FEB-10 30
01-MAR-10 31-MAR-10 50
01-APR-10 31-MAY-10 30
01-JUN-10 31-AUG-10 0
01-SEP-10 30-DEC-10 40
31-DEC-10 31-DEC-10 40
01-JAN-11I assume you only want a new row of output when the range_amount changes., that is:
START_DAT END_DATE RANGE_AMOUNT
01-JAN-10 31-JAN-10 10
01-FEB-10 28-FEB-10 30
01-MAR-10 31-MAR-10 50
01-APR-10 31-MAY-10 30
01-JUN-10 31-AUG-10 0
01-SEP-10 31-DEC-10 40
01-JAN-11 0Of course, you could modify the original query so that it did this, but it would end up about as complex as the query above, but less efficient.
Conversely, if you prefer the longer output, then you don't need the suib-query got_grp in the query above.
Thanks for posting the CREATE TABLE and INSERT statments; that's very helpful.
There are some people who have been using this forum for years who still have to be begged to do that. -
Is It Possible to use Call Function in update task in perform on commit
Hi Friends,
I have to send an email once the commit work is done. so i am writing code like this,
Perform send_email on commit.
form send_email.
call function 'SO_NEW_DOCUMENT_SEND_API1' in update task
endform.
endform.
.... ( Some other code)
commit work.
But, I am getting error saying Update task is not possible. Please suggest me how to solve this.
Thanks in Advance,
Phani.Hi Phani,
Check whether <b>COMMIT Work</b> has be performed. I think this might be the problem.
Regards,
Prashanth -
How to use BAPI_MATERIAL_MAINTAINDATA_RT function module in SAP Reatil?
Hi,
I am facing aproblem with BAPI_MATERIAL_MAINTAINDATA_RT function module when i send Article Master data from one SAP Server where all Article Master Data is maintained to another SAP Server where all Transaction Data is maintained.
how can i use the above Function Module to create or change Articles in Remote Server ( Transactional Data Server) by specifying Destination when calling Function Module so that it can create or change in Remote Server i.e what are the neccessary parameters passed to this function modules.thanks
-
Is it possible to use Adobe Interactive Forms in SAP (ABAP) Trial Version?
Dear All,
i need some help concerning the usage of Adobe Interactive Forms in SAP (ABAP) Trial Version.
I installed SAP Netweaver 7.01 (ABAP Trial Version) and i would like to use the Adobe Interactive Form editor (transaction SFP). Is this trial version prepared for this? Is it possible to edit and test Interactive Forms in the ABAP Trial Version too?
Somebody told me that he installed Adobe Lifecycle Designer 7.1 but the layout manager part of the editor shortdumped when he wanted to go back to other parts of the editor or he wanted to save what he did...
Is it enough to install Adobe Lifecycle Designer 7.1? Is there something else to install or configure?
Thank you for your help in advance.
All the best, P. Phil.Yes, you need the lifecycle designer installed. That should be enough to work with the SFP transaction. But to actually use the form, I think you do need the ADS(Adobe Document Services) which runs on the java stack.
Regards,
Rich Heilman -
Is it possible to use external testing tools in SAP XI
Hi,
I have been working on file to file transfer of large size more than 1 GB. I have many doubts like:
1.Can I use Data compression techniques so that my files can be processsed(my scenario involves a lot of mapping)
2.Can any of the engines be stopped so that processing speed increases.
3.Can any of the third party testing tools like Load runner be used in to monitor the process.
Please help me with sloutions.
Thanks in advance.One GB is a very huge file. First of all check ur XI hardware configuration.
1. U may write ur adapter module to zip the message.
2. It wont affect the performance much if the file size is 1 GB. Also u cant stop adapter engine (File Adapter) and the Integration Engine in ur scenario
3. U can do the load testing on XI using load runner
Regards,
Prateek -
Out of pure curiosity : is it possible to use a SQL function in a DSV?
Hi all :)
out of pure curiosity, I asked myself about this : is it possible using a function in a named query for exemple?
This is why I would know that : there is a difficult function in the database. I don't want to make a view to use it and to have the table I want. I would use it directly in the dsv, with a named query (or other thing?).
I thank you a lot by advance.
(I use SQL Server 2008 :) )
See youHello,
In a named query for a Report you can use any valid SQL Statement; so yes, you can use system/user defined functions in your query.
Olaf Helper
[ Blog] [ Xing] [ MVP]
Maybe you are looking for
-
Error message in TRFC 'An SQL error occurred when accessing a table'
Hi all, Can any one tell what this below error message is about in while go into TRFC 'An SQL error occurred when accessing a table'. and please tell me how to solve this problem.
-
How can I change the event registration layout for registration information entry fields?
Hello, I want to change the arrangement of the event registration entry fields. For example I want t arrange them into 2 columns and add some comment to them. The template editor doesn't allow to select a specific field. Who can help?
-
DBA Staff KPI(s) - Measuring Performance
<font color="#333333"><font color="#000080"><strong>DBA Staff KPI(s) - Measuring Performance</strong></font> </font> <p> <font color="#333333"> Hi, I am an<strong> IT manager</strong>, <u>managing two solutions: "SCM" & "WMS (Warehouse Management Sys
-
Seriously, what good is a Support Community that won't respond to a question?
I've started two discussions one a singular question and with approximately 50 views, not a single response. Are there any people out there who actually answer questions?
-
Dynamic data inside a chart's dataProvider
Dear Members, I am adding some extra touches to my application, it's basically a tool to give online presentations so I would like to add some charts for a more visual experience. I am using the Flex Pie Chart that I create dynamically with actionscr