Query to get subtotals and totals
Hi
I have write a query which gives results in the following form:
Name Jan Feb Mar
A1 54 3 43
A2 1 23 53
A3 34 23 23
Subtotal A 98 49 119
B1 23 12 34
B2 12 2 14
Subtotal B 35 14 48
Total 133 63 167
I mean getting the subtotal and then totals.
Does anybody know how to do this?
Jeneesh, like your solution.. simple and elegant. But..... ;)
If you use NVL you can't distinguish between a "NULL value" and a record which was added because of the ROLLUP.. it might be better to use GROUPING to determine if the row was added to the result set because of the ROLLUP
Notice the difference between these two queries
SQL> with test as
2 (
3 select 'A1' name, 54 jan, 3 feb, 43 mar from dual union all
4 select 'A2' name, 1 jan, 23 feb, 53 mar from dual union all
5 select 'A3' name, 34 jan, 23 feb, 23 mar from dual union all
6 select 'B1', 23 ,12, 34 from dual union all
7 select null, null, null, null from dual union all
8 select 'B2', 12 ,2 ,14 from dual
9 )
10 select nvl(name,n1) name,jan,feb
11 from(
12 select name,substr(name,1,1) n1,sum(jan) jan,sum(feb) feb from test
13 group by rollup(substr(name,1,1),name)
14 );
NAME JAN FEB
A1 54 3
A2 1 23
A3 34 23
A 89 49
B1 23 12
B2 12 2
B 35 14
124 63
10 rows selected.
SQL> with test as
2 (
3 select 'A1' name, 54 jan, 3 feb, 43 mar from dual union all
4 select 'A2' name, 1 jan, 23 feb, 53 mar from dual union all
5 select 'A3' name, 34 jan, 23 feb, 23 mar from dual union all
6 select 'B1', 23 ,12, 34 from dual union all
7 select null, null, null, null from dual union all
8 select 'B2', 12 ,2 ,14 from dual
9 )
10 select decode (grouping (substr(name,1,1)), 1, 'Total', substr (name, 1, 1)) n1
11 , decode (grouping(name), 1, 'Name total',name)
12 , sum(jan) jan
13 , sum(feb) feb
14 from test
15 group by rollup (substr(name,1,1)
16 ,name
17 );
N1 DECODE(GRO JAN FEB
Name total
A A1 54 3
A A2 1 23
A A3 34 23
A Name total 89 49
B B1 23 12
B B2 12 2
B Name total 35 14
Total Name total 124 63
10 rows selected.
SQL>
Similar Messages
-
How to get subtotal and total per project in PS Module cl_gui_alv_grid
Hi all,
i have a requirement of getting Subtotals and totals of few column in the alv grid. as i have already used cl_gui_alv_grid class to display the grid , so what excatly i have to follow to get the values.
i have tried with :
wa_sort TYPE lvc_s_sort
wa_sort-spos = '1'.
wa_sort-fieldname = 'POST1'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO t_sort.
CLEAR: wa_sort.
And in fieldcat have passed X to do_sum field.
and
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_variant = w_variant
i_save = 'A'
is_layout = t_layout
it_toolbar_excluding = t_toolbar_excluding
CHANGING
it_outtab = it_final_1[]
it_fieldcatalog = t_fieldcat
it_sort = t_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS
But i coudnt see any subtotal column and total column in the grid.
please helpBut i coudnt see any subtotal column and total column in the grid.
please help
you did every thing correct.
but if you want the subtotals you have to do one more thing.
that is you need to mention the do_sum = 'X'. for the columns which you want to see the subtotals(quantities, currency etcc) in the fieldcatalog. -
COMPUTE function: How to get subtotals and GRAND total together?
I am wrtiting a report using SQL and SQL*Plus to get subtotals and a grand total. The COMPUTE function allows me to COMPUTE SUM on a group, but it only gives me subtotals. I'm interested in getting a report with the SUBTOTALS and a final GRAND TOTAL. Can this be done using SQL*Plus?
Here is my current code that gives me subtotals:
COMPUTE SUM LABEL subtotal OF sal ON deptno
SELECT ename, sal, deptno
FROM emp
ORDER BY deptno;
ENAME SAL DEPTNO
CLARK 2450 10
VOLLMAN 5000
MILLER 1300
8750 subtotal
SMITH 800 20
ADAMS 1100
FORD 3000
SCOTT 3000
JONES 2975
10875 subtotal
ALLEN 1600 30
BLAKE 2850
MARTIN 1250
JAMES 950
TURNER 1500
WARD 1250
9400 subtotalHere is the code to give one grand total:
Column DUMMY NOPRINT
COMPUTE SUM OF sal ON DUMMY
BREAK ON DUMMY
SELECT NULL DUMMY, ename, sal, deptno
FROM emp
ORDER BY deptno;
ENAME SAL DEPTNO
CLARK 2450 10
VOLLMAN 5000 10
MILLER 1300 10
SMITH 800 20
ADAMS 1100 20
FORD 3000 20
SCOTT 3000 20
JONES 2975 20
ALLEN 1600 30
BLAKE 2850 30
MARTIN 1250 30
JAMES 950 30
TURNER 1500 30
WARD 1250 30
29025
How can I combine both on one report?Massimo Ruocchio wrote:
Do you like this?I believe OP is looking for both department totals and grand total. Frank already showed how to do it in SQL*Plus. To do it in SQL:
SELECT CASE GROUPING_ID(real_deptno,real_ename)
WHEN 0 then real_ename
WHEN 1 then 'Department ' || real_deptno || ' total'
ELSE 'All department total'
END ename,
SUM(sal),
deptno
FROM (
SELECT deptno real_deptno,
ename real_ename,
sal,
CASE ROW_NUMBER() OVER(PARTITION BY deptno order by ename) WHEN 1 THEN deptno end deptno
FROM emp
GROUP BY GROUPING SETS((),real_deptno,(real_deptno,deptno,real_ename))
ORDER BY real_deptno nulls last,
real_ename nulls last
ENAME SUM(SAL) DEPTNO
CLARK 2450 10
KING 5000
MILLER 1300
Department 10 total 8750
ADAMS 1100 20
FORD 3000
JONES 2975
SCOTT 3000
SMITH 800
Department 20 total 10875
ALLEN 1600 30
ENAME SUM(SAL) DEPTNO
BLAKE 2850
JAMES 950
MARTIN 1250
TURNER 1500
WARD 1250
Department 30 total 9400
All department total 29025
18 rows selected.
SQL> SY. -
Hi guru's in SMART FORMS how i can get subtotals , and page totals
hi guru's in SMART FORMS how i can get subtotals , and page totals plz help me
Hi
check this
Subtotals - Check the link...
<b>Re: Subtotal with Table Node in smartforms can use the PROGRAM LINES node to calculate the page totals in Table node.
Table Node has three sections:
Header: (Triggered once in the beginning of a page)
Create a Program lines node to reset the value of TOTAL to 0.
Main Area (For each row of internal table)
Create a Program lines node to add the Value to TOTAL
Footer (Triggered once in the End of a page)
Display the TOTAL
Note: 1) You can declare the TOTAL variable in the GLOBAL Definitions under GLOBAL DATA.
2) In the PROGRAM lines always pass the TOTAL in both INPUT and OUTPUT parameters
Regards
Anji -
Do not include some lines in Subtotals and totals in ALV
Hello All,
I am printing a report with all sale order details and Quantities( delveered ,conformed etc..) iam doing subtotals based on the material and Plant.
In this if the document date is less than the SY-DATUM, we should not include the quantity into the subtotals and totals, Only the orders wiht doc date GQ to Sy-datum then display them..
As of now I am using ALV grid display and doing the sums by
l_wa_fcat-do_sum = c_x. (field catalog) for the whole colom) but i want to avoid sum row from tehe calculation based on the condition.
<b>Do we have any way to achive this, like if we want to have separate color for a purticular Cell then we add an extra field in outout table and we link this field with layout-coltab_fieldname in the same way or any other way if we have</b>.
I will be thankfull to if you can provide me your valuable suggesstions on this. it is very urgent. I am trying in all the ways from my side.Hi,
see this code,
Complete code for the ALV grid example
This example shows and ALV grid with flights. After selecting a line a change button can be pushed to display a change screen. After the changes have been saved, the ALV grid screen is displayed again, and the grid is updated with the changes.
The example shows:
How to setup the ALV grid
How to ste focus to the grid
How to set the title of the grid
How to allow a user to save and reuse a grid layout (Variant)
How to customize the ALV grid toolbar
Refresh the grid
Set and get row selection and read line contents
Make and exception field (Traffic light)
Coloring a line
Steps:
Create screen 100 with the ALV grid. Remember to include an exit button
Add a change button to the ALV grid toolbar
Create screen 200 the Change screen
The screens:
The code:
REPORT sapmz_hf_alv_grid .
Type pool for icons - used in the toolbar
TYPE-POOLS: icon.
TABLES: zsflight.
To allow the declaration of o_event_receiver before the
lcl_event_receiver class is defined, decale it as deferred in the
start of the program
CLASS lcl_event_receiver DEFINITION DEFERRED.
G L O B A L I N T E R N A L T A B L E S
*DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
To include a traffic light and/or color a line the structure of the
table must include fields for the traffic light and/or the color
TYPES: BEGIN OF st_sflight.
INCLUDE STRUCTURE zsflight.
Field for traffic light
TYPES: traffic_light TYPE c.
Field for line color
types: line_color(4) type c.
TYPES: END OF st_sflight.
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
DATA: gi_sflight TYPE tt_sflight.
G L O B A L D A T A
DATA: ok_code LIKE sy-ucomm,
Work area for internal table
g_wa_sflight TYPE st_sflight,
ALV control: Layout structure
gs_layout TYPE lvc_s_layo.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container,
o_event_receiver TYPE REF TO lcl_event_receiver.
DATA:
Work area for screen 200
g_screen200 LIKE zsflight.
Data for storing information about selected rows in the grid
DATA:
Internal table
gi_index_rows TYPE lvc_t_row,
Information about 1 row
g_selected_row LIKE lvc_s_row.
C L A S S E S
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING
e_object e_interactive,
handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS.
CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
Event handler method for event toolbar.
CONSTANTS:
Constants for button type
c_button_normal TYPE i VALUE 0,
c_menu_and_default_button TYPE i VALUE 1,
c_menu TYPE i VALUE 2,
c_separator TYPE i VALUE 3,
c_radio_button TYPE i VALUE 4,
c_checkbox TYPE i VALUE 5,
c_menu_entry TYPE i VALUE 6.
DATA:
ls_toolbar TYPE stb_button.
Append seperator to the normal toolbar
CLEAR ls_toolbar.
MOVE c_separator TO ls_toolbar-butn_type..
APPEND ls_toolbar TO e_object->mt_toolbar.
Append a new button that to the toolbar. Use E_OBJECT of
event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
This class has one attribute MT_TOOLBAR which is of table type
TTB_BUTTON. The structure is STB_BUTTON
CLEAR ls_toolbar.
MOVE 'CHANGE' TO ls_toolbar-function.
MOVE icon_change TO ls_toolbar-icon.
MOVE 'Change flight' TO ls_toolbar-quickinfo.
MOVE 'Change' TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD handle_user_command.
Handle own functions defined in the toolbar
CASE e_ucomm.
WHEN 'CHANGE'.
PERFORM change_flight.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMETHOD.
ENDCLASS.
S T A R T - O F - S E L E C T I O N.
START-OF-SELECTION.
SET SCREEN '100'.
*& Module USER_COMMAND_0100 INPUT
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Module STATUS_0100 OUTPUT
MODULE status_0100 OUTPUT.
DATA:
For parameter IS_VARIANT that is sued to set up options for storing
the grid layout as a variant in method set_table_for_first_display
l_layout TYPE disvariant,
Utillity field
l_lines TYPE i.
After returning from screen 200 the line that was selected before
going to screen 200, should be selected again. The table gi_index_rows
was the output table from the GET_SELECTED_ROWS method in form
CHANGE_FLIGHT
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines > 0.
CALL METHOD go_grid->set_selected_rows
EXPORTING
it_index_rows = gi_index_rows.
CALL METHOD cl_gui_cfw=>flush.
REFRESH gi_index_rows.
ENDIF.
Read data and create objects
IF go_custom_container IS INITIAL.
Read data from datbase table
PERFORM get_data.
Create objects for container and ALV grid
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
Create object for event_receiver class
and set handlers
CREATE OBJECT o_event_receiver.
SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
Layout (Variant) for ALV grid
l_layout-report = sy-repid. "Layout fo report
Setup the grid layout using a variable of structure lvc_s_layo
Set grid title
gs_layout-grid_title = 'Flights'.
Selection mode - Single row without buttons
(This is the default mode
gs_layout-sel_mode = 'B'.
Name of the exception field (Traffic light field) and the color
field + set the exception and color field of the table
gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
gs_layout-info_fname = 'LINE_COLOR'.
LOOP AT gi_sflight INTO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
Value of traffic light field
g_wa_sflight-traffic_light = '1'.
Value of color field:
C = Color, 6=Color 1=Intesified on, 0: Inverse display off
g_wa_sflight-line_color = 'C610'.
ELSEIF g_wa_sflight-paymentsum => 100000 AND
g_wa_sflight-paymentsum < 1000000.
g_wa_sflight-traffic_light = '2'.
ELSE.
g_wa_sflight-traffic_light = '3'.
ENDIF.
MODIFY gi_sflight FROM g_wa_sflight.
ENDLOOP.
Grid setup for first display
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
is_variant = l_layout
i_save = 'A'
is_layout = gs_layout
CHANGING it_outtab = gi_sflight.
*-- End of grid setup -
Raise event toolbar to show the modified toolbar
CALL METHOD go_grid->set_toolbar_interactive.
Set focus to the grid. This is not necessary in this
example as there is only one control on the screen
CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0200 INPUT
MODULE user_command_0200 INPUT.
CASE ok_code.
WHEN 'EXIT200'.
LEAVE TO SCREEN 100.
WHEN'SAVE'.
PERFORM save_changes.
ENDCASE.
ENDMODULE. " USER_COMMAND_0200 INPUT
*& Form get_data
FORM get_data.
Read data from table SFLIGHT
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
ENDFORM. " load_data_into_grid
*& Form change_flight
Reads the contents of the selected row in the grid, ans transfers
the data to screen 200, where it can be changed and saved.
FORM change_flight.
DATA:l_lines TYPE i.
REFRESH gi_index_rows.
CLEAR g_selected_row.
Read index of selected rows
CALL METHOD go_grid->get_selected_rows
IMPORTING
et_index_rows = gi_index_rows.
Check if any row are selected at all. If not
table gi_index_rows will be empty
DESCRIBE TABLE gi_index_rows LINES l_lines.
IF l_lines = 0.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
textline1 = 'You must choose a line'.
EXIT.
ENDIF.
Read indexes of selected rows. In this example only one
row can be selected as we are using gs_layout-sel_mode = 'B',
so it is only ncessary to read the first entry in
table gi_index_rows
LOOP AT gi_index_rows INTO g_selected_row.
IF sy-tabix = 1.
READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
ENDIF.
ENDLOOP.
Transfer data from the selected row to screenm 200 and show
screen 200
CLEAR g_screen200.
MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
LEAVE TO SCREEN '200'.
ENDFORM. " change_flight
*& Form save_changes
Changes made in screen 200 are written to the datbase table
zsflight, and to the grid table gi_sflight, and the grid is
updated with method refresh_table_display to display the changes
FORM save_changes.
DATA: l_traffic_light TYPE c.
Update traffic light field
Update database table
MODIFY zsflight FROM g_screen200.
Update grid table , traffic light field and color field.
Note that it is necessary to use structure g_wa_sflight
for the update, as the screen structure does not have a
traffic light field
MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
IF g_wa_sflight-paymentsum < 100000.
g_wa_sflight-traffic_light = '1'.
C = Color, 6=Color 1=Intesified on, 0: Inverse display off
g_wa_sflight-line_color = 'C610'.
ELSEIF g_wa_sflight-paymentsum => 100000 AND
g_wa_sflight-paymentsum < 1000000.
g_wa_sflight-traffic_light = '2'.
clear g_wa_sflight-line_color.
ELSE.
g_wa_sflight-traffic_light = '3'.
clear g_wa_sflight-line_color.
ENDIF.
MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
Refresh grid
CALL METHOD go_grid->refresh_table_display.
CALL METHOD cl_gui_cfw=>flush.
LEAVE TO SCREEN '100'.
ENDFORM. " save_changes -
ALV: how to display only subtotals and total rows in the output
ALV: how to display only subtotals and total rows in the output
i am getting output
i am getting subtotals for respective fields
but i want to display only subtotals and totals rows in the output
i have tried the
totals_only parameter in slis_layout_alv
but it is not working.hi,
For TOTAL
For the amount field / quantity field in the field catalog give DO_SUM = 'X' for WHOLE total
For SUBTOTAL
For subtotal you will have to create an internal table sort..Let's say you want to do subtotal for each customer..
DATA: lt_sort type SLIS_T_SORTINFO_ALV,
ls_sort type slis_sortinfo_alv.
CLEAR ls_sort.
ls_sort-spos = 1.
ls_sort-fieldname = 'Give the field name that you do the sum'.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO lt_sort.
fieldcatalog-do_dum = 'X'.
for subtotals
WA_SORT-FIELDNAME = 'ERSDA'.
WA_SORT-SPOS = '2'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOTAL = 'X'.
APPEND WA_SORT TO IT_SORT.
Refer
http://help.sap.com/saphelp_erp2004/helpdata/en/ee/c8e056d52611d2b468006094192fe3/content.htm
http://sap.ittoolbox.com/groups/technical-functional/sap-dev/doesnt-function-event-subtotal_text-in-alv-713787
regards,
Prabhu
reward if it is helpful -
When i make a pivot in Excel 2010 i can change the cell to give me AVG, MAX, MIN, not only SUM, but when i créate a pivot from a tabular model, these options are disabled, i have posted a image, with a "tabla dinámica" or dynamic table
in this case, i can see the functions that i want but when i use the tabular model as a source, the options average (promedio), is disabled.
How i can enable this functions, or are a way to créate a formula for totals and subtotals, and other formula for detail in dax?
Thanks in advance.Hi juliomrs,
SSAS Tabular model doesn't let us to modify the aggregate function from the Client side. In this case, you need to create a new measure and use the function what you want inside the SSAS Tabular model.
For more information regarding DAX functions, please see:
DAX Function Reference:
http://msdn.microsoft.com/en-us/library/ee634396.aspx
Regards,
Elvis Long
TechNet Community Support -
Need query to get parent and child relations
Hi,
SELECT
a.ID MASTER_ID, a.UNIQUE_NAME MASTER_UNIQUE_NAME, d.ID CHILD_ID, d.UNIQUE_NAME CHILD_UNIQUE_NAME, 1 SUB_LEVEL
FROM
srm_projects a,
prTask b,
prSubProject c,
srm_projects d
WHERE
a.id = b.prProjectID
AND b.prID = c.prTaskID
AND c.PRREFPROJECTID=d.id
The above query gives a project and its child.
Child project can inturn have child projects.
But the above query gives only the first level.
To obtain second level I am presently using the following query
SELECT
a.ID MASTER_ID, a.UNIQUE_NAME MASTER_UNIQUE_NAME, d.ID CHILD_ID, d.UNIQUE_NAME CHILD_UNIQUE_NAME, 1 SUB_LEVEL
FROM
srm_projects a,
prTask b,
prSubProject c,
srm_projects d
WHERE
a.id = b.prProjectID
AND b.prID = c.prTaskID
AND c.PRREFPROJECTID=d.id
UNION ALL
SELECT
a.ID, a.UNIQUE_NAME, g.ID, g.UNIQUE_NAME, 2 SUB_LEVEL
FROM
srm_projects a,
prTask b,
prSubProject c,
srm_projects d,
prSubProject e,
prTask f,
srm_projects g
WHERE
a.id = b.prProjectID
AND b.prID = c.prTaskID
AND c.PRREFPROJECTID=d.id
AND d.ID = f.PRPROJECTID
AND f.prID = e.prTaskID
AND e.PRREFPROJECTID=g.id
But the problem is there is no limit on levels. They can go on to 20 to 30.
So i need a query which gives me all the levels and not as above one where i am specifying till wht level.
Please guide me.Thanks.
Please find the table structures
CREATE TABLE SRM_PROJECTS
ID NUMBER NOT NULL,
NAME VARCHAR2(240 BYTE),
UNIQUE_NAME VARCHAR2(60 BYTE),
DESCRIPTION VARCHAR2(2286 BYTE),
IS_ACTIVE NUMBER DEFAULT 1 NOT NULL,
CREATED_DATE DATE NOT NULL,
CREATED_BY NUMBER NOT NULL,
LAST_UPDATED_DATE DATE NOT NULL,
LAST_UPDATED_BY NUMBER NOT NULL,
CREATE TABLE PRTASK
PRUID VARCHAR2(32 BYTE),
PRID NUMBER(10),
PRPROJECTID NUMBER(10),
PRISUNPLANNED NUMBER(10) DEFAULT 0 NOT NULL,
PRSHORTNAME VARCHAR2(48 BYTE),
PRNAME VARCHAR2(450 BYTE),
PREXTERNALID VARCHAR2(48 BYTE),
PRISMILESTONE NUMBER(10) DEFAULT 0 NOT NULL,
PRCATEGORY VARCHAR2(96 BYTE),
CREATE TABLE PRSUBPROJECT
PRUID VARCHAR2(32 BYTE),
PRID NUMBER(10),
PRTASKID NUMBER(10),
PRREFPROJECTID NUMBER(10),
PRREFTASKID NUMBER(10),
PRISREADONLY NUMBER(10) DEFAULT 0 NOT NULL,
PRISIPD NUMBER(10) DEFAULT 0 NOT NULL,
PRMODBY VARCHAR2(96 BYTE),
PRMODTIME DATE
) -
Using Rollup to get subtotals and grand total - missing right pren error
Hello,
I am trying to create sub totals by person_id and a grand total row in my APEX report but I get a "missing right pren error." I finally figure out that I need to eliminate column alias names to fix this problem, however, I now get an ambigous column reference. I am making this change in my main SQL report statement, however, I was wondering if I should be using the "group by Rollup" somewhere else while using "Break Formatting."
I would appreciate any help.
Thanks
lehCan you post the Query please?
-
Subtotals and Totals In ALV Report
Hi Experts,
I have a problem in my current scenario,
I have 3 fields,
KUNNR, WAERS, DMBTR.
000001 USD 100.00
000001 USD 200.00
000002 USD 100.00
000002 USD 400.00
000002 EUR 300.00
000002 EUR 100.00
The above mentioned is the data I have in my internal table & in my ALV report as well, Which is fine...!
Now I need Subtotals for each customer,
Means for customer 000001 The subtotal is 300 (USD)
Means for customer 000002 The subtotal is 500 (USD)
Means for customer 000002 The subtotal is 400 (EUR)
At the end I need grand totals.
USD 800
EUR 400.
Currently My field catalog is given below.
FIELDCATALOG-COL_POS = COL_POS.
FIELDCATALOG-FIELDNAME = 'DMBTR'.
FIELDCATALOG-SELTEXT_M = TEXT-106.
FIELDCATALOG-DO_SUM = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
what else I need to do for getting individual subtotals by currency and customers.
Thanks & regards,
Dileep .CHi Deelip,
FOR TOTAL:
there is a property of fieldcatalog, that is do_sum.
USE COED LIKE:
PERFORM fieldcat USING:
'1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
'2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
FORM fieldcat USING value(p_0029)
value(p_0030)
value(p_0031)
value(p_0032)
wa_fieldcat-col_pos = p_0029.
wa_fieldcat-fieldname = p_0030.
wa_fieldcat-tabname = p_0031.
wa_fieldcat-reptext = p_0032.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " FIELDCAT
in final output you will get the total of currency field.
FOR SUB TOTAL:
decleare: i_sort type standard table of slis_sortinfo_alv,
wa_sort type slis_t_sortinfo_alv.
wa_sort-spos = '1'.
wa_sort-fieldname = 'KUNNR'.
wa_sort-tablename = 'i_final'
wa_sort-up = 'x'
wa_sort-subtot = 'X'.
wa_sort-spos = '2'.
wa_sort-fieldname = 'WAERS'.
wa_sort-tablename = 'i_final'
wa_sort-up = 'x'
wa_sort-subtot = 'X'.
append wa_tab to i_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
it_sort = i_sort
Hope this can solve your pbs.
Regards,
Tutun -
Query to get summarized and detailed data
Hi experts,
The scenario is as follows:
Generic extractor -> DSO -> Infocube
Now, the cube have item level details. My concern is, the cube might grow very big and impact the performance.
Is it possible to have a query that retrieves summarized information from the cube and for details do a jump to target to the DSO and get the details?
Pls give me a hint on this.Yes you can have summerized query on Cube & item level query on DSO.
Using RRI (tcode RSBBS) you can jump from Summerized Query to Detailed Query.
You can also pass values from summerized query to detailed query through RRI if required, provided the same infoobject is used in both cube & DSO. -
Query to get salary and stock options
Hello All,
I need to genrate a report which give infomation of the following
Salary, Bonus, Emp A/c number, stock options, proposed salary and proposed bonus
For this I am using the following query , Can any one verify this and let me know.
SELECT ppp.proposed_salary_n, proposed_salary, peevf.screen_entry_value,segment1||segment2||segment3||segment4||
segment5||segment6 "Stock Options" ,segment1||segment2||segment3||segment4||segment5||segment6||segment7||segment8||segment9||segment10 "Bank Details"
FROM per_all_assignments_f paaf,
per_pay_proposals ppp,
pay_element_entry_values_f peevf,
pay_element_entries_f penf,
PER_ANALYSIS_CRITERIA PAC,
PER_PERSON_ANALYSES PPA,
per_all_people_f papf
WHERE papf.PERSON_ID=paaf.person_id
AND paaf.assignment_id = ppp.assignment_id
AND peevf.element_entry_id = penf.element_entry_id
AND paaf.assignment_id = penf.assignment_id
AND ppa.ANALYSIS_CRITERIA_ID=pac.ANALYSIS_CRITERIA_ID
AND ppa.person_id=paaf.person_id
AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
AND SYSDATE BETWEEN peevf.effective_start_date AND peevf.effective_end_date
AND SYSDATE BETWEEN penf.effective_start_date AND penf.effective_end_date
AND TRUNC (SYSDATE) BETWEEN papf.effective_start_date
AND papf.effective_end_datePerfect Octavio...Thanks for your help :)
I used the following query as per your suggestions:
SELECT aid.invoice_id,
aid.amount,
gcc.CODE_COMBINATION_ID,
gcc.segment3,
f1.description,
gcc.segment4,
f2.description
FROM ap_invoice_distributions_all aid,
gl_code_combinations gcc,
fnd_flex_values_vl f1,
fnd_flex_values_vl f2,
(SELECT flex_value_set_id
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND UPPER (segment_name) = 'COST CENTER') cc,
(SELECT flex_value_set_id
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND UPPER (segment_name) = 'ACCOUNT') acct
WHERE aid.dist_code_combination_id = gcc.code_combination_id
AND f1.flex_value_set_id = cc.flex_value_set_id
AND f2.flex_value_set_id = acct.flex_value_set_id
AND gcc.segment3 = f1.flex_value
AND gcc.segment4 = f2.flex_value
ORDER BY aid.invoice_id
-Munna
Edited by: user584101 on Aug 19, 2009 9:59 AM -
Query to get master and child organizaitons of an item
Hi Experts,
Could some body send me the query to find out the master and child organizations for an item in oracle inventory.
Kindly help
ThanksHi,
Please review links and see if it helps you:
Apps Technical: Item Master Details in R12 (with category details)
11i - R12: Master Data (Item, Supplier, Customer, Bank, Item-Stock, Formula, Routing
Thanks &
Best Regards, -
Query for get username and profile and password life time
please provide query for this output
Profile Username Password Life Time
DEFAULT APPQOSSYS UNLIMITED days
DEFAULT CZ36QW UNLIMITED days
DEFAULT DBSPI UNLIMITED days
please tell me Password Life Time in this col um shows empty.please provide query for this output
Profile Username Password Life Time
DEFAULT APPQOSSYS UNLIMITED days
DEFAULT CZ36QW UNLIMITED days
DEFAULT DBSPI UNLIMITED days
please tell me Password Life Time in this col um shows empty. -
How to get subtotals on my table
Hello,
Could any one please tell me how can i get subtotals on my table. i am new to the tool trying to get subtotals and grand totals for my analysis. please adviceHi,
Can you post how you achieved this? It can help other users in the future. And also remember to close the thread.
J.-
Maybe you are looking for
-
I ordered the ipad 2 online on 3/12 and was told i'd have by the 15th. I got it on the 15th only it was ipad (1). Took it back to the Verizon wireless store, but they can't take it back because unlike any other online/actual stores (Macy's, Nordst
-
The camera display for the front facing (camera lens on back of camera) display stopped working on my droid razr maxx...any ideas. I did a soft boot on it, but to no avail. It was working on a few minutes before it stopped. The display for the user f
-
Currency conversion reference field for WERTV15_3
Hi, I have one field cost of CURR 15 and 3 decimals, which is having domain as WERTV15_3. When I create an entry in the table I can see the value as 50,000, but when I double click the record to see the details it is showing as 500,00. It is ta
-
Equium L40-14I does not power up if its cold
When I push the power button down when the machine is cold, the green power lights come on for about 2 seconds and then go off. If I give the laptop a bit of gentle heat for a about 30 seconds the laptop starts first time and runs perfectly until the
-
Trying to update to iOS4 and it sits for about 30-40 minutes with the "backing up iphone" dialogue box open. The blue bar makes minimal progress and then says "unable to back up. Would you like to proceed w/ update?" I say yes and then nothing. Have