SUM VALUES
Hi
I need to sum values for different CD_INDICATOR, same CD_CUSTOMER , same NM_CYCLE , same CD_STRUT, same PROFILE
CD_STRUT NUMBER(6)
NM_CYCLE NUMBER(6)
CD_CUSTOMER NUMBER(10)
CD_PROFILE NUMBER(2)
CD_INDICATOR NUMBER(6)
VL_INDICATOR NUMBER(15,2)
LAST_DATE DATE
SELECT CD_STRUT , NM_CYCLE ,
CD_CUSTOMER , CD_PROFILE , CD_INDICATOR ,
VL_INDICADOR VL_INDICATOR , DT_ULTIMA_ATUALIZACAO LAST_DATE
FROM MYTABLE PPC
WHERE PPC.CD_TYPE_STRUCT = 5 ---IS CONSTANT = 5
AND PPC.CD_STRUT = 4
AND PPC.NM_CYCLE = 200810
AND PPC.CD_CUSTOMER = 574970
AND PPC.CD_PROFILE = 1
AND PPC.CD_INDICATOR IN (4,2); CD_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR LAST_DATE
4 200810 574970 1 2 14.00 6/30/2008 8
4 200810 574970 1 4 1.00 6/30/2008 8 I must to sum VL_INDICATOR , with rule
When CD_INDICATOR = 4 AND VL_INDICATOR =1.00 I must return sum
of VL_INDICATOR 2 ( In case above =14) with 1, but if when
CD_INDICATOR = 4 AND VL_INDICATOR != 1 I must return only value of of VL_INDICATOR 2 ( In case above = 14)
I must return new CD_INDICATOR (5) as with below
CD_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR LAST_DATE
4 200810 574970 1 5 15.00 6/30/2008 8 if the values of CD_INDICATOR (2,4)
CD_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR LAST_DATE
4 200810 574970 1 2 12.00 6/30/2008 8
4 200810 574970 1 4 4.00 6/30/2008 8RETURN ME
CD_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR LAST_DATE
4 200810 574970 1 5 12.00 6/30/2008 8
Hi
I must to sum values OF CD_INDICATOR 309 and 4 ,
When value of CD_INDICATOR 4 is equal 1 (One) then I sum 1 else I sum zero
But if record of CD_INDICATOR 4 not exists I must to sum 0
In example below the sum equal 10 because value of CD_INDICATOR 4 is equal 2
CD_STRUT CD_TYPE_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR
2 5 200810 3320080 1 309 10.00
2 5 200810 3320080 1 4 2.00 In example below the sum equal 15
CD_STRUT CD_TYPE_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR
2 5 200810 3320080 1 309 14.00
2 5 200810 3320080 1 4 1.00 In example below the sum is 10, because no exist cd_indicator 4
CD_STRUT CD_TYPE_STRUT NM_CYCLE CD_CUSTOMER CD_PROFILE CD_INDICATOR VL_INDICATOR
2 5 200810 3320080 1 309 10.00
SELECT c.CD_STRUT,
cCD_TYPE_STRUT,
cNM_CYCLE ,
cCD_CUSTOMER,
cCD_PROFILE ,
C.CD_INDICATOR,
c.VL_INDICATOR
from T_CUSOTMER a
INNER JOIN MYTABLE c ON ( a.cd_type_strut = c.cd_type_strut
AND a.cd_estru = c.cd_estrut
AND a.CUSTOMER = c.cd_CUSOTMER
AND c.nm_cyicle = 200810
AND c.cd_profile = 1
AND c.cd_indicator = 309
and c.cd_customer = 3320080)I Want to a OUTER LEFT JOIN with MYTABLE for to get CD_INDICATOR =4 , but I did know how can I do it
Message was edited by:
muttleychess
Similar Messages
-
Error in printing sum value of DME file in Automatic Payment Run
Hi All,
We are in the process of upgrading from R/3-4.0B to ECC6.0.
In Automatic Payment run in transaction F110, when the spool is generated, the sum values is displaying in correctly. It is displaying and printing as actual value/100 for example if total of all the line items is 1000000, the sum value displaying as 10000 and in words also prints as ten thousands.
Kindly let us know how to fix the issue, if any one has come across with similar issue.
Thanx & Regards
AshokHi VVR,
I got the following errors:
Err Message text
003 Item is blocked for payemnt
007 Error in creating the payment doc, read job log.....
But if we have a look at the job log it is showing for all the 50,000 items... how to find where the problem is???
thanks. -
Hi, sorry to trouble, i havent got any data within a database or anything, just thinking about some work that i might have to do, so trying to get a head start. Was wondering how i would sum values in a column but with 2 where clauses. For example if i wanted to sum all values until 6pm in 1 column and all values after 6pm for 1 day how i would write this out.
I know how to write them separately, i.e.
select name, sum(values) as after6
from table
where time > '18:00'
group by name;
select name, sum(values) as upto6
from table
where time < '18:00'
group by name;
how can i combine these to have a columns after6 and upto6 next to each other.
if somebody could please advise.
thanks in advanceUsing case you can split the column then sum the column .Try the below
select name,
SUM(CASE WHEN time > '18:00' THEN values ELSE 0 END) as after6,
SUM(CASE WHEN time < '18:00' THEN values ELSE 0 END) as upto6
from table
groupbyname; -
Sum values in last row for date format "hh24:mi"
Hi,
I have a big problem creating a sum row with date data.
I created a sql view where the result looks like that:
SELECT category_name,
user_name,
b_mmyyyy,
b_1, ..., b_31
FROM view_category_user_booking
category_name, user_name, b_1, ..., b_31
category1, user1, 122008, 01:00, ..., 03:30
category2, user1, 122008, 02:00, ..., 01:00
category3, user1, 122008, 00:00, ..., 00:15My goal is to integrate a sum row at the end for the columns b_1 ... b_31
category_name, user_name, b_1, ..., b_31
category1, user1, 122008, 01:00, ..., 03:30
category2, user1, 122008, 02:00, ..., 01:00
category3, user1, 122008, 00:00, ..., 00:15
Sum, user1, 122008, 03:00, ..., 04:45I tried it like that:
select decode(grouping(category_name),1,'Summe',category_name),
sum(to_number(replace(b_1,':',','))) as b_1,
sum(to_number(replace(b_31,':',','))) as b_31
from category_user_booking
where user_name = 'user1'
and b_mmyyyy = '122008'
group by rollup(category_name)But the result isn't really successful
category_name, b_1, b_31
category1, 1, 3,3
category2, 2, 1
category3, 0, 0,15
Sum, 3, 4,45Is there somebody with an idea?
Thanks ahead,
TobiasHi Avinash,
the problem is not the grouping it is the date format.
Instead of a value like 5,4 > I want 05:40 or 1,75 > I want 02:15 in the sum value.
In my table all time values are saved in the format hh24:mi.
I don't know how to get that via a sql statement.
Output I want:
category_name, user_name, b_1, ..., b_31
category1, user1, 122008, 01:00, ..., 03:30
category2, user1, 122008, 02:00, ..., 01:00
category3, user1, 122008, 00:00, ..., 00:15
Sum, user1, 122008, 03:00, ..., 04:45Regards,
Tobias -
SUM value by multiple conditions in SSAS
Hi All,
I have a condition like as below, but the SUM value not working in CASE STATEMENT. Anyone can help me...!
SUM(CASE [Calendar].[Calendar Date]
WHEN [Calendar].[Calendar Date].[Year] = '2005' AND [Calendar].[Calendar Date].[Month] = 1
THEN [Calendar].[Calendar Date].CURRENTMEMBER.CHILDREN
END
, [Measures].[Work Day Flag])
Thanks in Advance...!
BaskaranThat is quite right Simon, although, technically, it's not a sum, you are simply getting the internet sales for january 2011, and you are overriding whatever selection is on the calendar date hierarchy. However, if that is what you want the calc to return,
perfect.
I would like to point out that WHEN [Calendar].[Calendar Date].[Year] = '2005' AND [Calendar].[Calendar Date].[Month] = 1
probably isn't what you want. If you want to know the Year of the current date, you might like to try something like the following
WHEN ancestor([Calendar].[Calendar Date],[Calendar].[Calendar Date].[Year]).member_caption
= '2005' AND ancestor([Calendar].[Calendar Date],[Calendar].[Calendar
Date].[Month]).member_caption = 'January'
Hope that helps,
Richard -
I want to read field-catlog "do-sum" value i.e final grandtotal which diaplay in ALV output . How to read "do-sum" value ?
Hi,
You have to use "get_subtotals" method to get the Totals and subtotals in your ALV THis set of code you will be writing in your "TOP-OF-PAGE" event, Please refer the sample code to do that.
DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
* get the global reference
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lo_grid.
* get the subtotal
DATA: it_00 TYPE REF TO data,
it_01 TYPE REF TO data,
it_02 TYPE REF TO data,it_03 TYPE REF TO data,it_04 TYPE REF TO data.
CALL METHOD lo_grid->get_subtotals
IMPORTING
ep_collect00 = it_00
ep_collect01 = it_01
ep_collect02 = it_02
ep_collect03 = it_03
ep_collect04 = it_04.
FIELD-SYMBOLS: <ft_tab> TYPE ANY TABLE,<ft_tab1> TYPE ANY, <ft_tab2> TYPE ANY TABLE,<ft_tab3> TYPE ANY,
<ft_tab4> TYPE ANY TABLE.
ASSIGN it_00->* TO <ft_tab>.
ASSIGN it_01->* TO <ft_tab1>.
ASSIGN it_02->* TO <ft_tab2>.
ASSIGN it_03->* TO <ft_tab3>.
ASSIGN it_04->* TO <ft_tab4>.
Now Your Final Total is in Fieldcatalog <FT_TAB>, and your respective subtotals are in other fieldcatalog.
Thanks
Saurabh
Edited by: Saurabh Siwach on Feb 8, 2010 8:35 AM
Edited by: Saurabh Siwach on Feb 8, 2010 8:39 AM -
Break formatting and number format of SUM value
Where can I put number formatting functio, which will format breaking sum values...like:
to_char(#SUM_VALUE#,'fmt 999G999G999G990')....maybe this thread is somewhere posted, but I cannot find it.
Next, how to exclude showing reports total at the end of report?
Is there any working demo to see some hints...
THX!
Message was edited by:
FunkyHello Damir,
"Maybe a hint for feature releases to have an option to disable total report sum on column …"There is a relative simple workaround, which will allow you exclude or highlight (style) this total report sum line, as you can see in here - http://htmldb.oracle.com/pls/otn/f?p=22710:10
In the Report Attribute page, I'm using the Break Formatting section first field "Display this text when printing report sums" - http://i10.tinypic.com/4ie8ck5.png .
If you want to exclude this line, you should use the same color as your cell background. For the example page, the code is looking like this:
<div id="FinalSum"><script type="text/javascript">var lastRow=html_CascadeUpTill('FinalSum','TR'); lastRow.style.color='#f7f7e7';</script></div>If, on the other hand, you want to highlight the line, or use any other CSS attribute style available, the code would look something like this:
<div id="FinalSum1"><script type="text/javascript">var lastRow=html_CascadeUpTill('FinalSum1','TR'); lastRow.style.backgroundColor='#CCCC99';</script>Total Report Sum</div> Regards,
Arie. -
Calculate the max and sum value by weird way !!!
this code calculate the sum value without sum clause :-
DECLARE
x NUMBER;
y NUMBER := 0;
CURSOR cur_sal
IS
SELECT sal
FROM emp;
BEGIN
OPEN cur_sal;
LOOP
FETCH cur_sal
INTO x;
EXIT WHEN cur_sal%NOTFOUND;
y := y + x;
END LOOP;
CLOSE cur_sal;
DBMS_OUTPUT.put_line ('sum sal without using sum function = ' || y);
END;
and this code calculate the max value without max clause :-
DECLARE
x NUMBER;
y NUMBER := 0;
CURSOR cur_sal
IS
SELECT sal
FROM emp;
BEGIN
OPEN cur_sal;
LOOP
FETCH cur_sal
INTO x;
EXIT WHEN cur_sal%NOTFOUND;
IF (x > y)
THEN
y := x;
END IF;
END LOOP;
CLOSE cur_sal;
DBMS_OUTPUT.put_line ('max sal without using max function = ' || y);
END;
the Question is : how suppose that's happen ?
what's the secret in those codes ?
it's just new idea for me , but I don't understand !
is there any name for this way in ( Oracle® Database PL/SQL User's Guide and Reference ) ?
if not , so please anyone give me any help to understand those codes !Secret? What secret? It slowly and inefficiently fetch each row one at a time and consecutively add them together you get a sum. What the first, horribly inefficient, cursor loop is doing is roughly the equivalent of determining how many rivets are in a bucket by dumping them on the floor and picking them up one at a time rather than weighing one, weighing all, and then doing a simple division. The second loop does the same, horribly inefficient thing, by picking up each rivet and seeing if it is bigger than the previous one.
Cursor loops are obsolete and this code is about as inefficient as you can get without using an Excel macro. -
How can I sum values over a date range?
I want to sum values (revenue) for a range of dates (i.e. for each month). I'm trying to use the MONTH function nested in SUMIF and keep getting an error message. I want it to be SUMIF( MONTH (column of dates), cell with month, column with revenue) and it tells me "all ranges must be the same size". It works if I create a separate column where I extract the month from each date and then compare that to a column with the number of the month, but that is really annoying.
You can use the sumif() function to compute the sum of revenues after the "End Date", the sum of revenues before some date and you can use the sum function to summ all revenue. Then you can combine these into a single formula to get the answer by:
sum between two dates is:
sum("of all revenue") - sumif("before date") - sumif("after date"
Cell B4 of the smaller table =SUM(Revenue)-SUMIF(Date, "<"&B1,Revenue)-SUMIF(Date, ">"&B2,Revenue)
I highlighed cells to show before and after dates to highlight the sumif("after") and sumif("before") -
How to sum value from a day to next day
First, I provided the CREATE and INSERT sql statements for testing:
CREATE TABLE TBL_CALC
"YEAR" VARCHAR2(4),
"MONTH" VARCHAR2(2),
"DAY" VARCHAR2(2),
"HOUR" VARCHAR2(2),
"VALUE" VARCHAR2(20)
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','1','20','32')
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','1','21','33');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','1','22','53');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','1','23','28');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','0','37');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','1','35');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','2','39');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','3','57');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','13','42');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','2','14','12');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','31','21','32');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','31','22','52');
insert into tbl_calc (year,month,day,hour,value) values ('2000','1','31','23','29');
insert into tbl_calc (year,month,day,hour,value) values ('2000','2','1','0','27');
insert into tbl_calc (year,month,day,hour,value) values ('2000','2','1','1','45');
insert into tbl_calc (year,month,day,hour,value) values ('2000','2','1','2','69');
insert into tbl_calc (year,month,day,hour,value) values ('2000','2','1','3','68');I have this sql to get the period of time of a day:
select year,month,day,hr,val,
sum(case when hr between 20 and 23 or hr between 0 and 3 then val else 0 end) over (partition by year,month,day) as new_value
from(
select year,month,day,to_number(hour) hr,to_number(value) val from tbl_calc
order by year,month,day,hrHere's the output:
YEAR MONTH DAY HR VAL NEW_VALUE
2000 1 1 20 32 146
2000 1 1 21 33 146
2000 1 1 22 53 146
2000 1 1 23 28 146
2000 1 2 0 37 168
2000 1 2 1 35 168
2000 1 2 2 39 168
2000 1 2 3 57 168
2000 1 2 13 42 168
2000 1 2 14 12 168
2000 1 31 21 32 113
2000 1 31 22 52 113
2000 1 31 23 29 113
2000 2 1 0 27 209
2000 2 1 1 45 209
2000 2 1 2 69 209
2000 2 1 3 68 209
17 rows selected The above sql get the sum of time period which in 20-23 and 0-3 in every day.
The values are recorded by each hour. (sometimes there are missed hours)
My problem is how to get the sum of time period over each day?
For example, I need to get the sum of value of a day night time from 20-23 and the next day morning 0-3, to become a sum value in this period.
Let say, the sum from 1st Jan night time to 2nd Jan morning should be combined into 1 value (146+168)=314.
In addition, there is a tricky point is that from every month last day (31th Jan night time to 1st Feb morning time) are also need to be combined into 1 value.
And it appears the new problem is that how about if the last day is in a non-regular day (not 30,31,28,29), just say maybe March consist only 15 period records only and the last day is 19th March.
The expected output:
YEAR MONTH DAY HR VAL NEW_VALUE
2000 1 1 20 32 314
2000 1 1 21 33 314
2000 1 1 22 53 314
2000 1 1 23 28 314
2000 1 2 0 37 314
2000 1 2 1 35 314
2000 1 2 2 39 314
2000 1 2 3 57 314
2000 1 2 13 42 314
2000 1 2 14 12 314
2000 1 31 21 32 322
2000 1 31 22 52 322
2000 1 31 23 29 322
2000 2 1 0 27 322
2000 2 1 1 45 322
2000 2 1 2 69 322
2000 2 1 3 68 322
17 rows selected I think its quite complicated case, please ask me for more if you need to clarify for something.
Thanks so much!! :)
Edited by: 920575 on 2012/7/31 上午 1:09Are you looking for something like this (partially tested)...
SQL> ed
Wrote file afiedt.buf
1 select year
2 ,month
3 ,day
4 ,hr
5 ,val
6 ,sum(case when hr between 20 and 23 or hr between 0 and 3 then val else 0 end) over (partition by year,month,day) as new_value
7 ,sum(case when hr between 20 and 23 or hr between 0 and 3 then val else 0 end) over (partition by trunc(dt-(4/24),'DD')) as day_value
8 from(
9 select year,month,day,to_number(hour) hr,to_number(value) val
10 ,to_date(year||lpad(month,2,'0')||lpad(day,2,'0')||lpad(hour,2,'0')||'0000','YYYYMMDDHH24MISS') as dt
11 from tbl_calc
12 )
13* order by year,month,day,hr
SQL> /
YEAR MO DA HR VAL NEW_VALUE DAY_VALUE
2000 1 1 20 32 146 314
2000 1 1 21 33 146 314
2000 1 1 22 53 146 314
2000 1 1 23 28 146 314
2000 1 2 0 37 168 314
2000 1 2 1 35 168 314
2000 1 2 2 39 168 314
2000 1 2 3 57 168 314
2000 1 2 13 42 168 0
2000 1 2 14 12 168 0
2000 1 31 21 32 113 322
2000 1 31 22 52 113 322
2000 1 31 23 29 113 322
2000 2 1 0 27 209 322
2000 2 1 1 45 209 322
2000 2 1 2 69 209 322
2000 2 1 3 68 209 322
17 rows selected.This turns the values into a proper DATE datatype and then offsets that back by 4 hours to bring the 0-3 hours into the previous day, and then partitions the sum based on that day. -
How to calculate the total sum value of a particular field that repeats
Hi All,
I have the following Req...File----Idoc Scenario
In the Inbound xml file i will get the Sales Order details with suppose 10 line items( 10 Orders)
Each line item represents one one SO. So totally i wil have 10 Sales Orders in this file.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Sales_Order xmlns:ns0="http://sap/Sales_Order">
<Header>
<COMP_CODE></COMP_CODE>
<DOC_TYPE></DOC_TYPE>
<SUPPL_VEND></SUPPL_VEND>
</Header>
<Item>
<ITEM></ITEM>
<MATERIAL></MATERIAL>
<PLANT></PLANT>
<QUANTITY></QUANTITY>
<Amount></Amount>
</Item>
In the above structure Item Segment will repeats as many no. of Sales Orders comes in a file.
In a file if there are 10 Orders means the Item segment wil repeats 10 times.
I have the Amount field in the Item Segment, each and every time that needs to be added to next Amount value that presents in the next Line Item.
Finally i will have the Another separate field caled Grand Total, and i have to get the total summation of the 10 values of the Amount field at last.
Can we achieve this using UDF or is there any way to do this
REgardsHi,
Do like this, actually in your case sum is taking place before the condition check for discount type
do a little change in mapping
DiscntType--removeContext--
EqulsS-------IfWithoutElse----Amount---removecontext--then---SUM-
Connstatnt(Value)
--->GrandAmount
Krishna, Check the same question asked by Rajesh in thread Calculate totals of segments that occur multiple times
Thanks! -
To sum values in a internal table
hi
iam using below loop
Loop at it_table.
At end of amount.
sum.
endat.
At end of field2.
sum.
endat.
endloop.
my purpose is to sum all values of the table field1 and field2 and use it to display please let me know how to do it
regards
aroraHi Arora,
SUM in control break command will hold sum of the variable you will mention with control command. If you want to add sum of two variables then add totals of each SUM varaible.
Check the below code.
V_FIELD1_SUM
V_FIELD2_SUM
V_TOTAL_SUM
Loop at it_table.
At LAST amount.
sum.
WRITE IT_TABLE-amount TO V_FIELD1_SUM.
endat.
At LAST field2.
sum.
WRITE IT_TABLE-field2 TO V_FIELD2_SUM.
endat.
endloop.
V_TOTAL_SUM = V_FIELD1_SUM + V_FIELD2_SUM.
WRITE:/ V_FIELD1_SUM,V_FIELD2_SUM,V_TOTAL_SUM
Thanks,
Vinay -
ALV - need to sum values of internal table and display in ALV
I have data in internal table as:
Material date sum1 sum2
Mat_A 19990101 4 4
Mat_A 20080501 3 0
Mat_A 20080601 2 0
Mat_B 19990101 2 0
Mat_B 20080601 5 5
Required output is :
Material qty1 qty2 19990101 20080501 20080601
Mat_A 432 4 4 3 2
Mat_B 2+5 5 2 5
Thinking of using ALV to pass the internal table and display as classical report (and also to save as excel spreadsheet).
Counting your help on the following questions:
1) How to accomplish the sum in ALV report? Can ALV FM do that or one has to use ABAP to compute the sum from the given internal table?
2) Mat_A can have more date values. Here it got 3 distinct date values 19990101, 20080601, 20080501. If it has say 5 date values, how to create the ALV date columns (from 3 to 5 date columns) dynamically?
Thanks for the help.for the sum inalv we use generally..
it_fieldcat-do_sum = 1.
check this examples...
http://www.****************/Tutorials/ALV/Subtotals/text.htm
*& Report ZTEST_ALV_PERC_13317
REPORT ztest_alv_perc_13317.
TYPE-POOLS: slis.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
it_events TYPE slis_t_event,
wa_events TYPE slis_alv_event,
it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv,
l_layout TYPE slis_layout_alv.
TYPES: BEGIN OF ty_itab,
field1(10),
qty1 TYPE i,
qty2 TYPE i,
qty3 TYPE i,
dummy TYPE c,
END OF ty_itab.
DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,
itab1 TYPE ty_itab.
START-OF-SELECTION.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
itab-field1 = 'FIRST'.
itab-qty1 = 2.
itab-qty2 = 1.
itab-qty3 = 5.
itab-dummy = 10.
APPEND itab.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'FIELD1'.
wa_fieldcat-tabname = 'ITAB'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'QTY1'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'QTY2'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'QTY3'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'DUMMY'.
wa_fieldcat-tabname = 'ITAB'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-no_out = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_events
EXCEPTIONS
list_type_wrong = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = it_fieldcat
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
ENDIF. -
Require sum value of one table to be inserted into another table column
Hi
I have a table which contains a list of parts and their prices required for an assembly.
I am trying to calculate the total from this part lists and put into the total price column for the assembly (another table column).
My method was to calculate the total in a page process ( eg, once all parts in the assembly have been entered the page process calculates the total price (the sum of the part prices at that time) and puts the result (total) in the assembly total column)
In the process I capture the total using either
SELECT SUM(TOTAL_COST) Total INTO B from CC_REQ_BOM WHERE RID = :P5_RID;
or
SELECT SUM(TOTAL_COST) INTO B from CC_REQ_BOM WHERE RID = :P5_RID;
Both the above sql statements are allowed ( one with alias and one without alais) by the page process but they dont seem to be working as no total is returned to the table when the page process is run.
to insert the calculation(variable B) into the required table I have used
INSERT INTO CC_REQ(TOTAL_COST)
VALUES(B);
I have used this method a few times with no problems for standard sql statements but this is the first time I have used it with the sum SQL function. For some reason it doesn't seem to like the SUM function even though the code below works in SQL Command window.
SELECT SUM(TOTAL_COST) from CC_REQ_BOM WHERE RID = :P5_RID;
Any help welcome.
PGJHi
In that case, I would do something like this then...
CREATE TABLE crt_crates
(ccr_id INTEGER CONSTRAINT ccr_pk PRIMARY KEY,
ccr_name VARCHAR2(4000) CONSTRAINT ccr_nam_nn NOT NULL);
CREATE TABLE crt_requests
(cre_id INTEGER CONSTRAINT cre_pk PRIMARY KEY,
cre_reference VARCHAR2(4000) CONSTRAINT cre_ref_nn NOT NULL,
--I've skipped the requester as this would probably refernce a different table
--I've skipped request details as it's not necessary for this example
cre_ccr_id INTEGER CONSTRAINT cre_ccr_fk REFERENCES crt_crates);
CREATE TABLE crt_materials
(cma_id INTEGER CONSTRAINT cma_pk PRIMARY KEY,
cma_name VARCHAR2(4000) CONSTRAINT cma_nam_nn NOT NULL,
cma_cost NUMBER(12,2) CONSTRAINT cma_cos_nn NOT NULL);
CREATE TABLE crt_crate_bom
(ccb_id INTEGER CONSTRAINT ccb_pk PRIMARY KEY,
ccb_ccr_id INTEGER CONSTRAINT ccb_ccr_fk REFERENCES crt_crates,
ccb_cma_id INTEGER CONSTRAINT ccb_cma_fk REFERENCES crt_materials,
ccb_quantity INTEGER DEFAULT 1 CONSTRAINT ccb_qua_nn NOT NULL);
INSERT INTO crt_crates
VALUES(1, 'Crate 1');
INSERT INTO crt_requests
VALUES(1,'Request 1',1);
INSERT INTO crt_materials
VALUES(1,'Material 1', 1000);
INSERT INTO crt_materials
VALUES(2,'Material 2', 500);
INSERT INTO crt_crate_bom
VALUES(1,1,1,5);
INSERT INTO crt_crate_bom
VALUES(2,1,2,3);
COMMIT;
--So crate cost totals would be...
SELECT cre_reference request,
ccr_name crate,
SUM(cma_cost*ccb_quantity) crate_cost
FROM crt_requests,
crt_crates,
crt_materials,
crt_crate_bom
WHERE cre_ccr_id = ccr_id
AND ccb_ccr_id = ccr_id
AND ccb_cma_id = cma_id
GROUP BY cre_reference,
ccr_name;
--And request cost totals would be...
SELECT cre_reference request,
SUM(cma_cost*ccb_quantity) crate_cost
FROM crt_requests,
crt_crates,
crt_materials,
crt_crate_bom
WHERE cre_ccr_id = ccr_id
AND ccb_ccr_id = ccr_id
AND ccb_cma_id = cma_id
GROUP BY cre_reference; Do you see what I mean - you don't store the derived values as they could get out of sync with the component parts that make then up. You derive them from the underlying data instead.
Hope this makes sense.
Cheers
Ben -
Hello,
I 'm working with invoice and I have this source structure as XI input:
Invoice
-- |....
-- |....
-- |Item1
|taxcode=01
|Amount=12
--|Item2
|taxcode=08
|Amount=10
--|Item3
|taxcode=01
|Amount=24
Now my scope is to map these fields to the IDOC segment E1EDP04 grouping by taxcode (MWSKZ taxcode)and putting the sum of the group amount (MWSBT amount).
IDOC:
--|...
--|...
--|E1EDP01
|...
|...
|EIEDP04
|MWSKZ=01
|MWSBT=36
|...
--|E1EDP01
|...
|...
|EIEDP04
|MWSKZ=08
|MWSBT=10
|...
How can I group by a field in XI?
Thank you
CorradoHi Corrado,
If You want to do it in graphical mapping then I will do it this way:
1. sort by taxcode
(taxcode) --> split by value (valuechanged) --> formatByExample (Amount, and splitted value) --> sum(amount) --> MWSBT
I can send u a screenshot of something similar if u need.
best regards
Dawid
Maybe you are looking for
-
How can I update my iCloud account?
A couple months ago I updated my apple ID from [email protected] to [email protected] and now I am having issues with something else and need to restore to a backup to fix my second issue. My primary issue it that I can neither restore or reset my ph
-
Syncing apps from iPhone to new computer
I have a new computer and want to sync my phone and all it's apps to my new computer. How do I do this without loosing all of my apps?
-
Maximum file size for iDisk's public folder?
I was wondering whether there is a max size for files in the idisk's public folder. When syncing my 68 MB zip file, the file on the iDisk shows 0MB. When uploading files externally via Safari, any file above 1 MB shows as 0MB. What are the restrictio
-
Spry Accordian in Dreamweaver CS3
I am using Spry Widgets in Dreamweaver CS3. However, everytime I insert the spry accordion - it doesn't work right if too much text is in one of the tabs. For Example: I have 3 tabs in the Accordion. Everything works well as it should if there is jus
-
I want to run "SAP" on my PC - where to start?
Hello, I'm seeking a career at a company that has "knowledge of SAP" as one of their requirements - this is for a position in Finance. I've watched some tutorials on SAP, specifically the "FI/CO" features - and thought that I would give it a try by i