ALV help on summing
Hi,
I have a report which will display the costing data. Now I have to sum on the Basis of Cost Centre and Profit Centre. I do not want the total. I want the line items to be summed on this 2 fields. How would I handle this in ALV Fieldcatalogue.
Regards,
Mira
For the fields that are to be summed, in the field catalog, make sure that they have "do_sum" turned on.
ls_fcat-do_sum = 'X'.
Doing this allows you to do sub-totaling. At runtime, while ALV is being displayed. Hightlight one of the columns like "Profit Center", click the subtotal icon.
You can either program this kind of functionality directly in the program but useing the parmeter "I_SORT" or the class CL_GUI_ALV_GRID, or something simuluar using the FM for alv grid.
You could also save this layout as a default variant.
Regards,
Rich Heilman
Similar Messages
-
Post Author: genesis
CA Forum: Formula
Hello I need help on sum
this is my example
W/O Status Datew1681 008 05/01/2007 7:00 amw1681 009 05/01/2007 8:10 amw1681 010 05/01/2007 9:00 am
I need to sum how long to to move from step 008, 009 and 010
W/O Status Datew1681 008 05/01/2007 7:00 amw1681 009 05/01/2007 8:10 am 1:10 Hourw1681 010 05/01/2007 9:00 am 0:50 minutes
The table & field that hold date value is WO_TASK_STATUS.ENTRY_DATEPost Author: bryanflora
CA Forum: Formula
Insure you already order the data in W/O then Status.Write a formula like this:{WO_TASK_STATUS.ENTRY_DATE} - Previous({WO_TASK_STATUS.ENTRY_DATE})Because it get the field value from the previous row, so in right order is important. -
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. -
Actuate to BIP Conversion Need Help with Sum and Distinct
Hi,
I am in the process of converting an Actuate report to BI Publisher .rtf format. Within the actuate report I have encountered the following code in one of the fields:
Sum([ssCalc])Distinct([ssProfessional_Id])
From what I understand this Actuate code is grouping by distinct ssProfessional_Id then taking the sum of the ssCalc field.
In my .rtf template I have the following:
<?for-each-group:ssSRA;./ssCIN?>
<?ssCalc?>
<?end for-each-group?>
I need to convert the Actuate code into the place where I currently have <?ssCalc?> in my template but I have no idea how I can translate translate this. Does anyone have any suggestions?????
Thanks,
FredFred
Can you post the XML, easier to help then
Tim -
hello experts,
i want to display the following format in the end of the list of the ALV. the report actually has a grid structure and a list header , and now i want to add the following to the end of the list.
bed pecess she cess
opening balance
credit from manufacturer
credit from dealer
credit from import
total credit available
debit
closing balance
The major problem here is the alignment.
pls kindly help me if there are key words that can used for the aligning in the end-of-the-list.
so far i have used the ***-typ and ***-info to display but i am not able to achieve what was required.
And i want to know how to add the variables for eg: in the table above i have three variables to fill each row , but how do i achieve it. plz kindly help me if possible with some sample codes.
Thanks in Advance.
Edited by: Arun Pandian on Nov 26, 2008 7:33 AMRefer this link:
http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Regards,
Ravi -
Hi,
There is one program need to calculat the SUB-TOTAL AMOUNT FOR SAME DOCUMENT NUMBER.
Means: Need to sumup betrg for the same belnr.
QUESTION:
How can I write the sorce cord In AT END OF...ENDAT.
TO SUMUP THE AMOUNT FOR SAME DOCUMENT NUMBER.
Please help!!
Thanks.
Here is the sourc code.
DATA: BEGIN OF t OCCURS 0,
bukrs LIKE knb1-bukrs,
*<<<<< CR01
zuonr Like bsid-zuonr, "sort key "CR01
*>>>>> CR01
belnr LIKE bsid-belnr,
kunnr LIKE kna1-kunnr,
bldat LIKE bsid-bldat,
budat LIKE bsid-budat,
netdt LIKE bsega-netdt,
waers LIKE bsid-waers,
wrbtr LIKE bsid-wrbtr,
shkzg LIKE bsid-shkzg,
xblnr LIKE bsid-xblnr, "WD041005a
sgtxt LIKE bsid-sgtxt,
dmbtr LIKE bsid-dmbtr,
END OF t.
Description of Interface-record RECON
DATA: BEGIN OF s,
belnr(10), " document number
*<<<< CR01 STRAT ADD ZUONR
zuonr(10), "sort key " CR01
*>>>> CR01 END ADD ZUONR
filler1(1),
KUNNR(5), " customer no."WD290705a
kunnr LIKE kna1-kunnr, " customer no."WD290705a
filler2(1),
bldat(10), " date
filler3(1),
budat(10),
filler4(1),
netdt(10), " due date for payment
filler5(1),
betrg(14), " amount
filler6(1),
waers(3), " currency
filler7(1), " document field - blank
compcode(4), " company-code "fw070905
filler8(1), " comment - blank
sgtxt(50), " Text "INS MG020207
filler9(1),
kmmnt(30),
filler10(1),
vbeln(12) ,
filler11(1),
xblnr(16), "WD041005a hier Referenznr rein
filler12(1),
lifn2(11),
filler13(1), " remark - blank
dmbtr(14),
filler14(1),
twaer(3),
END OF s.
DATA: BEGIN OF outtab OCCURS 1000,
s LIKE s,
END OF outtab.
*<<<<< INS MG020207
TYPES: BEGIN OF ty_outalv,
belnr(10), " document number
*<<<< CR01 START ADD ZUONR
zuonr, " sort key " CR01
*>>>>CR01 END ADD AUONR
kunnr LIKE kna1-kunnr, " customer no."WD290705a
bldat(10), " date
budat(10), " posting date
netdt(10), " due date for payment
betrg(14), " amount
waers(3), " currency
compcode(4), " company-code "fw070905
sgtxt(30), " comment
kmmnt(30), " comment
vbeln(12), " delivery number
xblnr(16), "WD041005a hier Referenznr rein
lifn2(11), " customer number
dmbtr(14),
twaer(3), " currency company code
END OF ty_outalv.
DATA: gt_outalv TYPE STANDARD TABLE OF ty_outalv.
DATA: gs_outalv TYPE ty_outalv.
*>>>>> INS MG020207
DATA: l_date TYPE sy-datum.
DATA: g_date TYPE sy-datum.
DATA: g_budat TYPE bsik-budat.
*<<<< CR01 START ADD DATA STATEMENT
DATA: wk_belnr LIKE bsid-zuonr,
wk_x_belnr LIKE bsid-zuonr,
ZUONR LIKE BSID-ZUONR,
WRBTR LIKE BSID-WRBTR,
WK_ZUONR LIKE BSID-ZUONR,
WK_WRBTR LIKE BSID-WRBTR.
*>>>> CR01 END ADD DATA STATEMENT
DATA: l_it_bsik TYPE STANDARD TABLE OF bsik. "INS MG050706
DATA: l_wa_bsik TYPE bsik. "INS MG050706
TYPE-POOLS: slis. "INS MG020207
DATA: "INS MG020207
gt_fieldcat TYPE slis_t_fieldcat_alv, "INS MG020207
gs_layout TYPE slis_layout_alv, "INS MG020207
gs_fieldcat TYPE slis_fieldcat_alv. "INS MG020207
END-OF-SELECTION.
SORT t.
LOOP AT t.
AT NEW bukrs.
CLEAR anz_dl.
CLEAR htext-anzahl.
CLEAR htext-datei.
htext-text1 = ' records writen in file '.
CLEAR p_pfad.
CONCATENATE
i_pfad
'CU_CC'
t-bukrs
sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
sy-uzeit
'.txt'
INTO p_pfad.
CLEAR outtab.
REFRESH outtab.
REFRESH: gt_outalv. "INS MG020207
ENDAT.
IF t-shkzg = 'H'.
h_betrg = t-wrbtr * -1.
ELSE.
h_betrg = t-wrbtr.
h_dmbtr = t-dmbtr.
ENDIF.
s-filler1 = s-filler2 = s-filler3 = s-filler4 = s-filler5 = ';'.
s-filler6 = s-filler7 = s-filler8 = ';'.
s-filler9 = s-filler10 = s-filler11 = s-filler12 = s-filler13 = ';'.
s-filler14 = ';'.
s-belnr = t-belnr.
IF t-xblnr NE space. "WD041005a
s-xblnr = t-xblnr. "WD041005a
ELSE. "WD041005a
s-xblnr = t-belnr. "WD041005a
ENDIF. "WD041005a
WHILE s-xblnr(1) EQ '0'. "INS MG130606
SHIFT s-xblnr LEFT. "INS MG130606
ENDWHILE. "INS MG130606
WRITE t-kunnr TO s-kunnr NO-ZERO.
s-lifn2 = s-kunnr.
shift s-lifn2 RIGHT.
s-lifn2(1) = 'R'.
S-KUNNR = T-KUNNR+5(5).
s-bldat+2(1) = '/'.
s-bldat+5(1) = '/'.
s-bldat0(2) = t-bldat4(2).
s-bldat3(2) = t-bldat6(2).
s-bldat6(4) = t-bldat0(4).
s-budat+2(1) = '/'.
s-budat+5(1) = '/'.
s-budat0(2) = t-budat4(2).
s-budat3(2) = t-budat6(2).
s-budat6(4) = t-budat0(4).
s-netdt+2(1) = '/'.
s-netdt+5(1) = '/'.
s-netdt0(2) = t-netdt4(2).
s-netdt3(2) = t-netdt6(2).
s-netdt6(4) = t-netdt0(4).
s-waers = t-waers.
s-dmbtr = t-dmbtr.
s-sgtxt = t-sgtxt.
CLEAR s-twaer.
SELECT SINGLE waers INTO s-twaer
FROM t001
WHERE bukrs = t-bukrs.
IF h_betrg < 0.
hs_betrg+0(1) = '-'.
ELSE.
hs_betrg+0(1) = ' '.
ENDIF.
WRITE h_betrg CURRENCY t-waers TO hs_betrg+1 NO-GROUPING
NO-SIGN
LEFT-JUSTIFIED.
REPLACE ',' WITH '.' INTO hs_betrg.
WRITE hs_betrg TO s-betrg.
IF h_dmbtr < 0.
hs_betrg+0(1) = '-'.
ELSE.
hs_betrg+0(1) = ' '.
ENDIF.
WRITE h_dmbtr CURRENCY t-waers TO hs_betrg+1 NO-GROUPING
NO-SIGN
LEFT-JUSTIFIED.
REPLACE ',' WITH '.' INTO hs_betrg.
WRITE hs_betrg TO s-dmbtr.
s-compcode = t-bukrs. "fw070905
IF p_downl = 'X'.
MOVE s TO outtab-s.
APPEND outtab.
ADD 1 TO anz_dl.
ENDIF.
gs_outalv-belnr = s-belnr. "INS MG020207
*<<<< CR01 START ADD as_outalv-zuonr
gs_outalv-zuonr = s-zuonr. "CR01
*>>>> CR01 EDD ADD as_outalv-zuonr
gs_outalv-kunnr = s-kunnr. "INS MG020207
gs_outalv-bldat = s-bldat. "INS MG020207
gs_outalv-netdt = s-netdt. "INS MG020207
gs_outalv-betrg = s-betrg. "INS MG020207
gs_outalv-waers = s-waers. "INS MG020207
gs_outalv-compcode = s-compcode. "INS MG020207
gs_outalv-budat = s-budat. "INS MG020207
gs_outalv-sgtxt = s-sgtxt.
gs_outalv-kmmnt = s-kmmnt.
gs_outalv-vbeln = s-vbeln.
gs_outalv-xblnr = s-xblnr.
gs_outalv-lifn2 = s-lifn2.
gs_outalv-dmbtr = s-dmbtr.
gs_outalv-twaer = s-twaer.
APPEND gs_outalv TO gt_outalv. "INS MG020207
AT END OF bukrs.
WRITE anz_dl TO htext-anzahl.
WRITE p_pfad TO htext-datei.
CONDENSE htext.
IF p_downl = 'X'.
SKIP 2.
WRITE: / htext.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = p_pfad
filetype = 'ASC'
TABLES
data_tab = outtab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
write: / 'Error creating File:', P_Pfad, sy-subrc.
MESSAGE e405 WITH text-002 p_pfad.
ENDIF.
ENDIF.
*<<<<< INS MG020207
IF p_alvd EQ 'X'.
PERFORM build_layout_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = 'GT_OUTALV'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
i_callback_top_of_page = 'TOP-OF-PAGE'
TABLES
t_outtab = gt_outalv.
ENDIF.
*>>>>> INS MG020207
ENDAT.
ENDLOOP.HI
Have alook at below program
*& Report ZINTERNALTABLE
REPORT zinternaltable.
TYPES:BEGIN OF itab,
num TYPE i,
name(10) TYPE c,
amt type i,
END OF itab.
DATA : wa_itab TYPE itab,
it_itab TYPE STANDARD TABLE OF itab.
DATA : v_lines TYPE i.
wa_itab-num = 1.
wa_itab-name = 'nag'.
wa_itab-amt = 1000.
append wa_itab TO it_itab.
wa_itab-num = 1.
wa_itab-name = 'nag'.
wa_itab-amt = 2000.
append wa_itab TO it_itab.
wa_itab-num = 1.
wa_itab-name = 'nag'.
wa_itab-amt = 1500.
append wa_itab TO it_itab.
wa_itab-num = 2.
wa_itab-name = 'sri'.
wa_itab-amt = 500.
append wa_itab tO it_itab.
wa_itab-num = 2.
wa_itab-name = 'sri'.
wa_itab-amt = 600.
append wa_itab TO it_itab.
wa_itab-num = 2.
wa_itab-name = 'sri'.
wa_itab-amt = 700.
append wa_itab TO it_itab.
wa_itab-num = 3.
wa_itab-name = 'ganesh'.
wa_itab-amt = 1200.
append wa_itab TO it_itab.
wa_itab-num = 3.
wa_itab-name = 'ganesh'.
wa_itab-amt = 1300.
append wa_itab TO it_itab.
wa_itab-num = 3.
wa_itab-name = 'ganesh'.
wa_itab-amt = 1400.
append wa_itab TO it_itab.
wa_itab-num = 4.
wa_itab-name = 'suresh'.
wa_itab-amt = 900.
append wa_itab TO it_itab.
wa_itab-num = 4.
wa_itab-name = 'suresh'.
wa_itab-amt = 300.
append wa_itab TO it_itab.
sort it_itab.
LOOP AT it_itab INTO wa_itab.
at first.
write :/ 'details of sales order:'.
uline.
endat.
at new num.
write :/ 'serial num:', wa_itab-num.
uline.
endat.
WRITE :/ wa_itab-num , wa_itab-name , wa_itab-amt.
at end of num.
uline.
sum.
write :/ 'total amount:',wa_itab-amt.
uline.
endat.
at last.
sum.
uline.
write:/ 'grand total:',wa_itab-amt.
endat.
ENDLOOP.
describe table it_itab lines v_lines.
WRITE:/'no of records :', v_lines.
Regards
Nagesh.Paruchuri -
Hi,
Can anyone help me with ALV that how to display ALV Column Heading in Multiple Line.
Means Multiple line Coulmn heading of ALV.
Please fell free to contact me at
[email protected]
Regards,
Muhammad Usman Malik
SAP ABAP Consultant
Siemens Pakistan
+92-333-2700972Welcome to SDN.
Copy Paste below code and execute the same. The output contains mutiple lines in header but I dont know how to do it in ALV. May be of some help to you.
REPORT ztestvib MESSAGE-ID zz LINE-SIZE 50.
TYPE-POOLS: slis.
DATA: x_fieldcat TYPE slis_fieldcat_alv,
it_fieldcat TYPE slis_t_fieldcat_alv,
l_layout TYPE slis_layout_alv,
x_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
DATA: BEGIN OF itab OCCURS 0,
vbeln LIKE vbak-vbeln,
posnr LIKE vbap-posnr,
male TYPE i,
female TYPE i,
END OF itab.
SELECT vbeln
posnr
FROM vbap
UP TO 20 ROWS
INTO TABLE itab.
x_fieldcat-fieldname = 'VBELN'.
x_fieldcat-seltext_l = 'VBELN'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 1.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'POSNR'.
x_fieldcat-seltext_l = 'POSNR'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 2.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'MALE'.
x_fieldcat-seltext_l = 'MALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_fieldcat-fieldname = 'FEMALE'.
x_fieldcat-seltext_l = 'FEMALE'.
x_fieldcat-tabname = 'ITAB'.
x_fieldcat-col_pos = 3.
APPEND x_fieldcat TO it_fieldcat.
CLEAR x_fieldcat.
x_events-name = slis_ev_top_of_page.
x_events-form = 'TOP_OF_PAGE'.
APPEND x_events TO it_events.
CLEAR x_events .
l_layout-no_colhead = 'X'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = l_layout
it_fieldcat = it_fieldcat
it_events = it_events
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 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.
*& Form top_of_page
text
FORM top_of_page.
*-To display the headers for main list
FORMAT COLOR COL_HEADING.
WRITE: / sy-uline(103).
WRITE: / sy-vline,
(8) ' ' ,
sy-vline,
(8) ' ' ,
sy-vline,
(19) '***'(015) CENTERED,
sy-vline.
WRITE: / sy-vline,
(8) 'VBELN'(013) ,
sy-vline,
(8) 'POSNR'(014) ,
sy-vline,
(8) 'MALE'(016) ,
sy-vline,
(8) 'FMALE'(017) ,
sy-vline.
FORMAT COLOR OFF.
ENDFORM. "top_of_page -
Help with SUM function ??
Hi,
I am trying to build a SUM function into the following SELECT statement;
SELECT emp_code "EmployeeCode", trn_date "TransactionDate", project "ProjectCode",
phase_code "PhaseCode", task_code "TaskCode", reg_hrs "RegularHoursAmt", rate_reg "RegularHoursRate", ot_hrs "OvertimeHoursAmt", rate_ot "OvertimeHoursRate"
Currently when i do the extract to xls I manually compile the "RegularHoursAmt" and "RegularHoursRate" manually and it's quite a task. I'm sure it can be completed in teh SELECT but I'm not clear on how and it's been quite some time since my last foray into SQL. Any assistance appreciated.
I need to sum "RegularHoursAmt" and "RegularHoursRate"
per "EmployeeCode"
by "TransactionDate"
with unique combo of "ProjectCode", "PhaseCode", "TaskCode"
Cheers, PeterHi, Peter,
PJS5 wrote:
Thanks Frank for the quick response. Ok, here goes;
The TABLES already exist and I am only pulling the data for the columns in my SELECT statement so no CREATE of INSERT as such.Post CREATE TABLE and INSERT statements so that the people who want to help you can re-create the problem and test their ideas.
The data is in Oracle 10g 10.1.0.2.0Perfect!
So you want totals that represent the entire day for a given employee.
Yes, but rows are by the unique combo per employee of "ProjectCode", "PhaseCode", "TaskCode"So a row of output will represent a distinct combination of employee, day, ProjectCode, PhaseCode and TaskCode, and that one output row may correspond to more than one row of input; is that right?
eg Tom works on 4 unique "ProjectCode/PhaseCode/TaskCode" efforts on "TransactionDate"What does "effort" mean here? If I could look at some actaul data (or actual fake data; don't post anything like real credit card numbers) and the results you want from that data, perhaps it would be clear.
One of those unique "ProjectCode/PhaseCode/TaskCode" efforts however has 3 timesheet entries as he has added unique Descriptions of what his efforts were aimed at achieving.
We are not extracting the Descriptions and thereby want to SUM those 3 timesheet entries into one row.
Do you also want a total for each employee, over all days? No thanks
Do you want a grand total for all employees and all days? No thanks
Do you want the totals on the same output rows as your current reuslts? That would be handy
If so, use the analytic SUM function. I'm not familiar with this
Do you want separate rows for the the totals? That could helpPost the exact results you want from a small set of given data. It's fine to describe the results, as you did above, but describe them in addition to (not instead of) actually showing them.
Does that make my questions easier to follow?It looks good, but without some sample data and the results you want from that data, I can't say for sure.
Please post CREATE TABLE and INSERT statements (relevant columns only) for a little sample data, so that I (and the others who want to help you) can see exactly what your tables are like, and actually try our solutions. Simplify as much as possible. For example, if the data is actually coming from a multi-table join, but you already know how to join all the tables perfectly, then pretend all the data is in one table, and post CREATE TABLE and INSERT statements for that one table that looks sort of like your current result set. Post just enough data to show what you want to do. Based on what you've said so far, I'm guessing that 10 to 20 rows of raw data, resulting in 3 to 7 rows of output could give a nice example.
Also, post the exact results you want from the sample data you post. Explain, with specific examples, how you get those results from that data.
If parts of your desired output are optional (that is, if some parts "would be handy" or "could help") then post a couple of different sets of results from the same data, and explain, something like this:
"What I'd really love to get for results is" ...
but, if that makes things really complicated or inefficient, I don't absolutely need ... or ...,
so I'd settle for these results: ..."
I know it's a lot of work to post all this information, but it's really necessary. If I could help you without making you do all this, then I would. Unfortunately, I really don't have a good idea of where you're coming from or where you want to go.
Edited by: Frank Kulash on Oct 19, 2010 8:01 PM -
The following query runs fine under 8.1.6 but returns bad result under 8.1.7.2 :
SELECT SUM(NBANOMALIE4), SUM(NBANOMALIE2)
FROM
(SELECT COUNT(*) "NBANOMALIE2" FROM CPN A, ANOCPN B WHERE A.CODENS= '128' AND B.CODANO='2' AND A.NUMFOR = B.NUMFOR ) ,
(SELECT COUNT(*) "NBANOMALIE4" FROM CPN A, ANOCPN B WHERE A.CODENS= '128' AND B.CODANO='4' AND A.NUMFOR = B.NUMFOR )
GROUP BY NBANOMALIE2, NBANOMALIE4;
Result given under 8.1.6 is
SUM(NBANOMALIE4) SUM(NBANOMALIE2)
1 0 (correct)
Result given under 8.1.7.2 is
0 0 (wrong)
if query is changed to "SELECT SUM(NBANOMALIE2), SUM(NBANOMALIE4) ..."
Result given under 8.1.7.2 is
1 1 (wrong too !)
actually the result given for ALL is the result of the last "SUM()" in the select ...
Is it a bug ? if so any patch ? Is there a workaround ?
Thanks for any help
Charlie [email protected]a solution was to use decode()
here is a workaround :
SELECT DECODE(B.CODANO,'2',1,0) NBANOMALIE2, DECODE(B.CODANO,'4',1,0) NBANOMALIE4
FROM CPN A, ANOCPN B
WHERE A.CODENS= '128' AND B.CODANO IN ('2','4') AND A.NUMFOR = B.NUMFOR;
I had it from http://www.orafaq.com/. ...
Charlie [email protected] -
I really need some help! I have a form has a lot of rows and columns. I know how to sum them using Formcalc, but it would be tedious and time-consuming to do it again and again for all my fields.
So, here's kind of how the form looks like:
January February March ....... Total Year
Recyclable Amount
Waste Amount
Total Tons
What I was doing was something like this: Sum(January[0], February[0]....December[0]) under "Total Year". But I would have to repeat this about 20 times for different rows. Is there a script to easily sum across the row, so I don't have to manually change the numbers in the bracket each row? Thanks! I know this might sound confusing, so let me know if my question isn't clear... Thanks in advance!!I really need some help! I have a form has a lot of rows and columns. I know how to sum them using Formcalc, but it would be tedious and time-consuming to do it again and again for all my fields.
So, here's kind of how the form looks like:
January February March ....... Total Year
Recyclable Amount
Waste Amount
Total Tons
What I was doing was something like this: Sum(January[0], February[0]....December[0]) under "Total Year". But I would have to repeat this about 20 times for different rows. Is there a script to easily sum across the row, so I don't have to manually change the numbers in the bracket each row? Thanks! I know this might sound confusing, so let me know if my question isn't clear... Thanks in advance!! -
I have below two tables:
Table A
col1 col2
1 10
1 10
1 10
Table b
Col1 col2
1 20
Desired output:
a.col1 sum(a.col2),sum(b.col2)
1 30 20Please help..
Edited by: [email protected] on Apr 28, 2010 12:37 AMHere is a try with full outer join:
SQL> WITH A AS (SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
2 SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
3 SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
4 SELECT 2 col1, 40 col2 FROM DUAL UNION ALL
5 SELECT 4 col1, 140 col2 FROM DUAL),
6 B AS (SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
7 SELECT 1 col1, 10 col2 FROM DUAL UNION ALL
8 SELECT 2 col1, 50 col2 FROM DUAL UNION ALL
9 SELECT 2 col1, 50 col2 FROM DUAL UNION ALL
10 SELECT 3 col1, 150 col2 FROM DUAL)
11 -- End of sample data
12 SELECT NVL(s_a.col1, s_b.col1) AS col1, sum_a, sum_b
13 FROM (SELECT col1, SUM(col2) AS sum_a
14 FROM a
15 GROUP BY col1) s_a
16 FULL OUTER JOIN
17 (SELECT col1, SUM(col2) AS sum_b
18 FROM b
19 GROUP BY col1) s_b ON s_a.col1 = s_b.col1
20 ORDER BY 1;
COL1 SUM_A SUM_B
1 30 20
2 40 100
3 150
4 140Urs -
Help with Sum using FormCalc in Livecycle
Hello. I'm stuck. I've been doing searches, readings, and all that on how to sum up certain cells in Livecycle. I have tried examples and tutorials and I get stuck when the application says "Error: Accessor ' ' Unknown".
I'm such a novice in using Livecycle and I'm not a programmer. So, if someone can help me on why it does this, that would be awesome!Here you go. I rename it. Couple of things. Too many subforms (unless you intend to do something else with this). Also, make sure you save your forms as "dynamic" if you intend to have user enter info. I couldn't tell if you were importing/exporting to a spreadsheet. Note the formcalc. Your fields need to be named the same. In my example they are: ExpCosts.
I'm not very good with the formcalc/java and variables but am more than willing to help with what I can -
ALV help - Excel sheet comes in blank
I need help with my ALV implementation. The ALV displays fine but when I try to view it in Excel, by clicking on the icon, I get blank pages. Does anybody have any ideas? Below is the code that I am using to display the ALV.
FORM display_alv .
DATA: gr_alv TYPE REF TO cl_salv_table,
gr_func TYPE REF TO cl_salv_functions,
gr_columns TYPE REF TO cl_salv_columns_table,
gr_column TYPE REF TO cl_salv_column_table,
gr_error TYPE REF TO cx_salv_error.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_alv
CHANGING
t_table = it_table.
CATCH cx_salv_msg INTO gr_error.
ENDTRY.
gr_func = gr_alv->get_functions( ).
gr_func->set_all( abap_true ).
gr_alv->display( ).
ENDFORM. " display_alvHi,
have a look at this forum thread:
(here you´ll find a nice example by Rich Heilman).
Best regards. -
Need help with sum from previous years
Hi All,
In a report i have 4 fields. The first field shows the YTD invoice totals for the current FY 2010 (which i accomplished). The other 3 fields are :
2nd field Sum of the value of invoices for the FY 1YEAR prior to the current year
3rd field Sum of the value of invoices for the FY 2YEAR's prior to the current year.
4th field Sum of the value of invoices for the FY 3YEAR's prior to the current year.
How can i get the desired results for the second,third and the fourth fields, please need help or advice.
ThanksHi
If you have the values for several years in the same report you should be able to do what you want using the analytic LEAD and LAG.
LAG will retrieve values from previous rows whereas LEAD will retrieve values from following rows.
The basic syntax is the same and look like this:
LAG(value, offset) OVER ({optional_partition_clause} ORDER BY mandatory_order_clause)
The ORDER BY clause is mandatory and cannot be omitted. However, this ORDER BY has nothing to do with the sort order you manually create in the worksheet. Generally, most people will set their sort order the same as the ORDER BY in the calculation.
Here's an example that gets year to date from 2 financial years ago:
LAG(YTD,2) OVER (ORDER BY FY)
You have to understand that Discoverer will pull values from previous rows not from previous cells as displayed on the report, although if the cells may happen to be rows too then it will appear as though it is pulling previous cells. I personally am very experienced with analytuc functions and can make manipulate data within Discoverer just about any way that I want. Generally, if I can see data on the screen even when they are in different cells or rows I can create functions to manipulate it. This capability only comes about as a result of experience and I would strongly advise you to practice with the analytics and see if you can at least master some of them. You'll find your Discoverer capabilities will improve dramatically and you will become a great asset at work.
When working with a new report I generally duplicate the report as a table so that I can see the values. Then if I need to sort the items in order to line up the values I want to work with I do so. Having worked out what sort order I need I can then see what offset I use then I create the analytic and use it in the main worksheet.
Hope this helps
Best wishes
Michael -
Need help with summing column when using if-then-else
Using logic
<?xdofx:if INVOICE_BILL_AMT_IN_INV_CURR is null then INVPROC_BILL_AMOUNT else INVOICE_BILL_AMT_IN_INV_CURR end if?> for column field.
Having trouble summing the column using the logic above.
Any suggestions would be very much appreciated.
Thanks,
NancyThanks Tim,
That worked. Got rid of my error. However, if the field is null (=''), I get a total.
11.05 + 1429.70 = 1440.75
If the not null (!='') I am not getting a total.
103.74 + 173.13 =
BTW, recently took XML class. Leta Davis highly recommended your blog and I have gotten a lot of great tips from it.
Thanks,
Nancy
Maybe you are looking for
-
This is a noob question, though I do use SQL Server databases all the time with Entity Framework when I code in C# using Visual Studio 2013. The development environment is found below at [A]. I am trying to make a clone of a SQL Server 2008 R2 data
-
Error when Launching Office 365 Pro Plus in Remote Desktop Services
Hello, I have Windows Server 2008 R2 and I have installed Office 365 pro plus volume license but I keep receive the error when I launch the product I receive this error "This Copy of Microsoft Office 2013 cannot be used on a computer running Termin
-
Adcfgclone.pl dbTier gets error
Dear all i made the cloning steps on DB and apps . preclone completed successful on db and apps and autoconfig and i created appsutil also newly. i made everything to make the post clone succeed .everything is good only not post clone. APPS : REDHAT
-
App Locker: admin user (non-admin token) unexpected run behavior
As an administrative user with a filtered token (not choosing Run As Admin), when I double-click an .exe residing in a location that no App Locker rule would allow a non-admin token to run - I expect to see the application blocked by App Locker, but
-
Issue Syncing Covers on Macbook Pro!
I have both a Windows PC and a Macbook Pro 13', and also an Ipod classic 120gbs. When i want to put covers on my albums through itunes on my PC, it works fine, i click the right button on my mouse and i go to information and then i can add the cover