Query for calculation in ALV Total
HI All,
I am using Sub_tot = "X" & do_sum="X" to get the subtotals & Totals for different columns Using REUSE_ALV_LIST_DISPLAY.
I am calculating percentage in column "C" depending on result of Column "A" & Column "B", which is also achieved.
My requirement is, Percentage in Total column to be calculated with use of TOTAL OF COLUMN "A" & TOTAL OF COLUMN "B". Because simply totaling all the values of percentage column will not work.
Any Pointers will be helpful.
Thanks In advance.
Regards,
Siddhesh Sanghvi.
hi ,
this is another example for displaying the subtotals in many times ...
report zvg_alv_slist2 .
type-pools: slis.
G L O B A L I N T E R N A L T A B L E S
data: gt_fieldcat type slis_t_fieldcat_alv,
gs_layout type slis_layout_alv,
gt_events type slis_t_event.
data: it_sort type slis_t_sortinfo_alv ,
wa_sort type slis_sortinfo_alv .
data: gs_print type slis_print_alv.
data: begin of it_sflight occurs 0,
carrid like sflight-carrid,
connid like sflight-connid,
fldate like sflight-fldate,
price like sflight-price,
planetype like sflight-planetype,
seatsmax like sflight-seatsmax,
seatsocc like sflight-seatsocc,
paymentsum like sflight-paymentsum,
end of it_sflight.
*DATA: GI_SFLIGHT LIKE STANDARD TABLE OF ST_SFLIGHT.
data: g_repid like sy-repid.
data: gt_list_top_of_page type slis_t_listheader.
data: v_total(5).
start-of-selection.
g_repid = sy-repid.
perform init_fieldcat using gt_fieldcat[].
perform build_eventtab using gt_events[].
perform build_comment using gt_list_top_of_page[].
perform get_data.
perform set_layout using gs_layout.
SORTING
clear wa_sort.
wa_sort-fieldname = 'CARRID'.
wa_sort-up = 'X'.
wa_sort-group = '*'.
wa_sort-subtot = 'X'.
append wa_sort to it_sort.
clear wa_sort.
wa_sort-fieldname = 'CONNID'.
wa_sort-up = 'X'.
wa_sort-group = 'UL'.
wa_sort-subtot = 'X'.
append wa_sort to it_sort.
DISPLAY LIST
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_interface_check = ' '
i_callback_program = g_repid
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_sort = it_sort[]
it_events = gt_events
is_print = gs_print
tables
t_outtab = it_sflight
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 INIT_FIELDCAT
form init_fieldcat using p_gt_fieldcat type slis_t_fieldcat_alv.
data: ls_fieldcat type slis_fieldcat_alv,
l_index type sy-tabix.
data :rep like sy-repid.
rep = sy-repid.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = rep
i_internal_tabname = 'IT_SFLIGHT'
i_inclname = rep
changing
ct_fieldcat = gt_fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-subrc.
endif.
sort gt_fieldcat by col_pos.
loop at gt_fieldcat into ls_fieldcat.
l_index = sy-tabix.
if ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-do_sum = 'X'.
ls_fieldcat-sp_group = 'X'.
modify gt_fieldcat from ls_fieldcat index l_index .
endif.
endloop.
endform. " INIT_FIELDCAT
*& Form BUILD_EVENTTAB
form build_eventtab using p_gt_events type slis_t_event.
data: ls_event type slis_alv_event.
clear ls_event.
ls_event-name = slis_ev_top_of_page.
ls_event-form = 'XTOP_OF_PAGE'.
append ls_event to p_gt_events.
clear ls_event.
ls_event-name = slis_ev_top_of_list.
ls_event-form = 'XTOP_OF_LIST'.
append ls_event to p_gt_events.
clear ls_event.
clear ls_event.
ls_event-name = slis_ev_end_of_page.
ls_event-form = 'XEND_OF_PAGE'.
append ls_event to p_gt_events.
ls_event-name = slis_ev_end_of_list.
ls_event-form = 'XEND_OF_LIST'.
append ls_event to p_gt_events.
clear ls_event.
endform. " BUILD_EVENTTAB
*& Form BUILD_COMMENT
form build_comment using p_gt_list_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader.
ls_line-typ = 'H'." = Header, S = Selection, A = Action
ls_line-key = 'KEY'.
ls_line-info = 'INFO'.
append ls_line to p_gt_list_top_of_page.
endform. " BUILD_COMMENT
*& Form SELECTION
form get_data..
data: l_rows type i value 3.
Read data from table SFLIGHT
select carrid
connid
fldate
price
planetype
seatsmax
seatsocc
paymentsum
from sflight
into table it_sflight.
up to l_rows rows.
sort it_sflight.
endform. " SELECTION
*& Form SET_LAYOUT
form set_layout using p_gs_layout type slis_layout_alv.
* P_GS_LAYOUT-F2CODE = P_F2CODE.
p_gs_layout-zebra = 'X'.
p_gs_layout-colwidth_optimize = 'X'.
p_gs_layout-no_input = 'X'.
p_gs_layout-no_colhead = space.
p_gs_layout-totals_text = 'Total Price'.
p_gs_layout-subtotals_text = 'Sub Total'.
p_gs_layout-totals_only = 'X'.
p_gs_layout-key_hotspot = 'X'.
p_gs_layout-detail_popup = 'X'.
p_gs_layout-no_subtotals = space.
p_gs_layout-expand_all = 'X'.
p_gs_layout-group_buttons = 'X'."space.
endform. " SET_LAYOUT
FORM XTOP_OF_PAGE *
form xtop_of_page.
data : lv_page(5),
lv_text(20).
MOVE SY-PAGNO TO LV_PAGE.
write:/ 'X_TOP_OF_PAGE'.
endform. "xtop_of_page
FORM XTOP_OF_LIST *
form xtop_of_list.
write:/ 'X_TOP_OF_LIST'.
endform. "xtop_of_list
FORM XEND_OF_PAGE *
form xend_of_page.
write:/ 'X_END_OF_PAGE'.
endform. "xend_of_page
FORM XEND_OF_LIST *
form xend_of_list.
write:/ 'X_END_OF_LIST'.
data : lv_page(5),
lv_text(20).
data : l_lines type i,
l_line type i.
clear v_total.
write sy-pagno to v_total left-justified.
export v_total to memory id 'V_TOTAL'.
do sy-pagno times.
lv_page = sy-index.
concatenate 'Page' lv_page 'of' v_total
into lv_text separated by space.
if sy-index = 1.
read line 2 of page sy-index.
else.
read line 1 of page sy-index.
endif.
sy-lisel+60(20) = lv_text.
modify current line .
enddo.
endform. "xend_of_list
USER_COMMAND *
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when 'EXIT'.
leave to screen 0.
when '&IC1'.
data: text(256),text1(6),text2(5).
move rs_selfield-tabindex to text1.
move rs_selfield-sumindex to text2.
concatenate 'Double clicked on (field:'
rs_selfield-fieldname
'Value:'
rs_selfield-value
text1
text2
into text
separated by space.
call function 'POPUP_TO_DISPLAY_TEXT'
exporting
textline1 = text.
endcase.
endform. "user_command
regards,
venkat.
Similar Messages
-
Query for calculating financialyear
help me to write a query which will check if the record createdon
is within the current financialyear i.e. June 2014- July 2015
RecordCreatedon
logic
2014-10-28
yes
2014- 12-15
Yes
2012- 01-19
No
Note : query for calculating financialyear should be hardcoded .It looks like your sample data range is wrong "June 2014- July 2015"
To get an idea, I consider June 2014 - May 2015 as financial year, try the below:
create Table test_Table (RecordCreatedon date)
Insert into test_table values('2014-10-28'),('2014- 12-15'),('2014- 06-01'),('2014- 05-30')
,('2015- 02-28'),('2015- 05-30'),('2015- 06-01')
Select *,
case when year(Dateadd(month,-5,RecordCreatedon) )=YEAR(getdate()) Then 'yes' else 'no' end Logic
From test_Table
Drop table test_Table -
Query for calculating raw material requirements for the remaining quantities in sale order.
Dear SAP Experts,
Clients requirement :
Client wish to know the quantities of raw materials needs to run the production order inorder to complete the remaining quantities in sale order.
Need Clarification:
I"m using the below query for this requirement. I wish to know whether this query suits for my clients requirement or not. If its so, I need to know how to group by T4.[Code] (Raw material Name) and need to get the sum of T4.[Quantity] (BOM quantity) and (T1.[OpenQty]*T4.[Quantity]) as TOTALQTY under each raw material group
SELECT T0.[DocNum], T0.[DocDate], T0.[CardCode],T0.[CardName], T1.[ItemCode], T1.[Dscription], T1.[Quantity] as salesorderQty , T1.[OpenQty], T2.onhand, T4.[Code] as Raw material Name,T4.[Quantity] as BOMQTY, (T1.[OpenQty]*T4.[Quantity]) as TOTALQTY FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.[DocEntry] = T1.[DocEntry] INNER JOIN OITM T2 ON T1.[ItemCode] = T2.[ItemCode] INNER JOIN OITT T3 ON T2.[ItemCode] = T3.[Code] INNER JOIN ITT1 T4 ON T3.[Code] = T4.[Father] WHERE T0.[DocStatus] ='o'You're posting in the Portuguese B1 space.
You might want to post in the English one: SAP Business One Application -
Hi Experts,
I would like to write a FMS query to allow for auto calculation based on the Inputs of 2 other fields before Adding the Sales Order.
For example. A query on Sales Order where I have Item ABCD and Quantity 200.
I have a UDF named Abatement where the value is fixed 35%. And other is Assessable Value fixed with MRP Price say 350
And based on the result should be given in Assessable Value field.
Formula is Assessable Value fixed 350 then Abatement 35 % = 122.50 and then 350-122.50 = 227.50 should be displayed in the Assessable value field.
Kindly provide me the solution for the query.
Regards
AmolHi,
Try this:
SELECT ((select $[RDR1.U_AssessableValue]) - ((select $[RDR1.U_Abatement]) * ((select $[RDR1.U_AssessableValue])/100)))
Please post screen shot sale order window with UDF filed and values.
Thanks & Regards,
Nagarajan -
Query about calculating Purchase Order Total
Sorry, please ignore this. I've realised my stupid mistake now. Sorry for wasting your valuable time.
Edited by: jimr on May 27, 2009 11:07 AMyou have two different REQ numbers,...
.. ah, you found a mistake.. Good,.. please mark this thread as answered -
Currency Translation for Calculated Key figures
Hello Friends I want to use the Currency Translation for Calculated Key figures.
But when I go to Query and go to conversion tab it is always greyed out. Does that mean we can set the fixed conversion type for calculated key figures. like ZSAD Total debit - credit -flow value.
What is the way to do fixed currency translation in query for calculated key figures.
All the below is done now just want to specify this in query but I can'nt since it is greyed out.
All the below is done
I have created a Currency Translation Type " FiscperConversion" "ZVHGR" now this has Exchange Rate Type from Variable "ZVARN" (Which is a variable single value manual input on 0RTYPE Infoobject for exchange rate.)
2. Now Currency Tab: Target Currency is selected from Variable placed in the Report. ZRPVAR.
3. Now the Variable Time Reference is used. Standard Infoobject 0FISCPER
which is beginning of period.Hi soniya
Your calculated KF is result of some calculation ...so system will not allow u to do any translation on it...to get CT on CKF you should do it on base key figure...still if you wish to do then you can create a formula variable having processing type a customer exit...write code in cmod to rad exchange rate and multiply ur CKF by this formula variable....
Thanks
Tripple k -
ALV Totals , Subtotals for a particular field in ALV Grid report
Hi,
I have an issue in ALV totals and subtotals.
Scenario is like this.
i have a vendor data to be pulled out of SAP and to be shown in the form of report.
i am populating all the data and doing do_sum based on Vendor ( has expansin & collapse option ) and display the number of reports .
Vendor -
100
Vendor1 -
1
Vendor2----
2.
Vendor100----
100.
but my problem is in the same report i have a date field .
if i have a five vendors created on 03/03/2008. in the same report for the date field having ( expansion & collapse ) , when i expand based on that date can i be able to sum up all the vendors created on 03/03/2008 and display in the same report along with the vendor count.
Let me know . Thank you in advance
Regards,
RyHi Roby,
Have a look at this sample code
It will help u,
REPORT ZIN_FI_AGEING
message-id zbdc
no standard page heading.
Title : For Ageing Details
Author :
Date : 22/11/2004
Transport/Correction Id :
Clarify case ID :
Application : FI
Program Type :
Frequency :
Purpose :
Comments :
Request No :
TABLES DELCARATIONS
Tables: zzgeinz9a, "Actual line item table
t001. "Plants/Branches
ALV TTPE DELCARATIONS
type-pools: slis.
*Type Declarations for Field Catalog
data : i_fldcat_head type slis_t_fieldcat_alv,
wa_fldcat_head type slis_fieldcat_alv.
*Type Declarations for ALV Events
data : i_events type slis_t_event,
wa_event like line of i_events.
*Type Declarations for Layout Design
data : wa_layout type slis_layout_alv.
*Type Declarations for Sorting Fields
data: it_sort type slis_sortinfo_alv occurs 0 with header line.
*Type Declarations for Displaying Images on Grid
data : i_comment type slis_t_listheader,
wa_comment type slis_listheader.
*Type Declarations for Grouping fields
data : wa_group type slis_sp_group_alv,
i_group type slis_t_sp_group_alv.
DATA DELCARATIONS
data: v_flag, "Status Flag
v_repid like sy-repid, "Program Name
p_year(4) type c, "Year
v_due_days type i. "To hold the due days
CONSTANTS DELCARATIONS
constants: c_x type c value 'X',
c_bukrs(4) type c value '0373'.
INTERNAL TABLES DELCARATIONS
*--Internal table to hold the required data
data: begin of it_final_vendor occurs 0,
rzzlifnr like zzgeinz9a-rzzlifnr, "Vendor
name1 like lfa1-name1, "Vendor Name
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
belnr like bkpf-belnr, "FI Doc No
doc_date like bkpf-awkey, "Document Date
zbd1t like bsik-zbd1t, "Cash discount days 1
bldat like bkpf-bldat, "Document Date
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
not_due like zzgeinz9a-hsl, "Not Yet Due
hsl like zzgeinz9a-hsl, "local currency
found type c, "Existance Flag
end of it_final_vendor.
data: begin of it_final_vendor_temp occurs 0,
rzzlifnr like zzgeinz9a-rzzlifnr, "Vendor
name1 like lfa1-name1, "Vendor Name
belnr like bkpf-belnr, "FI Doc No
bldat like bkpf-bldat, "Document Date
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
hsl like zzgeinz9a-hsl, "local currency
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
not_due like zzgeinz9a-hsl, "Not Yet Due
buck_0_30 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_31_60 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_61_90 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_91_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
doc_date like bkpf-awkey, "Document Date
found type c, "Existance Flag
end of it_final_vendor_temp.
data: begin of it_final_customer occurs 0,
rzzkunnr like zzgeinz9a-rzzkunnr, "Customer
name1 like kna1-name1, "Customer Name
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
belnr like bkpf-belnr, "FI Doc No
doc_date like bkpf-awkey, "Document Date
zbd1t like bsik-zbd1t, "Cash discount days 1
bldat like bkpf-bldat, "Document Date
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
not_due like zzgeinz9a-hsl, "Not Yet Due
hsl like zzgeinz9a-hsl, "local currency
found type c, "Existance Flag
end of it_final_customer.
data: begin of it_final_customer_temp occurs 0,
rzzkunnr like zzgeinz9a-rzzkunnr, "Customer
name1 like kna1-name1, "Customer Name
belnr like bkpf-belnr, "FI Doc No
bldat like bkpf-bldat, "Document Date
rzz_ebeln like zzgeinz9a-rzz_ebeln, "P.O. Ref No
hsl like zzgeinz9a-hsl, "local currency
due_date like bkpf-bldat, "Due Date
due_days type i, "Due Days
not_due like zzgeinz9a-hsl, "Not Yet Due
buck_0_30 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_31_60 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_61_90 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_91_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
buck_180 like zzgeinz9a-hsl, "Invoiceamt in localcurr
docnr like zzgeinz9a-DOCNR, "Accounting Doc No
refdocnr like zzgeinz9a-REFDOCNR, "Reference document no
doc_date like bkpf-awkey, "Document Date
found type c, "Existance Flag
end of it_final_customer_temp.
*--Internal Table to hold the Cash discount days 1 for Vendors
data: begin of it_final_bsik occurs 0,
belnr like bsik-belnr,
zbd1t like bsik-zbd1t,
end of it_final_bsik.
*--Internal Table to hold the Cash discount days 1 for Customers
data: begin of it_final_bsid occurs 0,
belnr like bsid-belnr,
zbd1t like bsid-zbd1t,
end of it_final_bsid.
INITIALIZATION
v_repid = sy-repid.
SELECTION SCREEN
selection-screen: begin of block b1 with frame title text-h01.
selection-screen skip.
select-options: s_vendor for zzgeinz9a-rzzlifnr modif id ven.
parameters: p_comp1 like t001-bukrs modif id ven.
parameters: p_rundt1 like bkpf-bldat modif id ven.
select-options: s_cust for zzgeinz9a-rzzkunnr modif id cst.
parameters: p_comp2 like t001-bukrs modif id cst.
parameters: p_rundt2 like bkpf-bldat modif id cst.
selection-screen skip.
selection-screen: begin of block b2 with frame title text-h02.
parameters : p_vendor radiobutton group gr1 default 'X'
user-command test,
p_cust radiobutton group gr1.
selection-screen: end of block b2.
selection-screen: end of block b1.
**************************AT Selection Screen OutPut ******************
at selection-screen output.
loop at screen.
if p_cust = 'X'.
if screen-group1 = 'VEN'.
screen-active = '0'.
screen-input = '0'.
screen-output = '0'.
screen-invisible = '0'.
endif.
elseif p_vendor = 'X'.
if screen-group1 = 'CST'.
screen-active = '0'.
screen-input = '0'.
screen-output = '0'.
screen-invisible = '0'.
endif.
endif.
modify screen.
endloop.
SELECTION SCREEN ON
at selection-screen on s_vendor.
*--Validating Vendor
if not s_vendor[] is initial.
perform validate_s_vendor.
endif.
at selection-screen on s_cust.
*--Validating Customer
if not s_cust[] is initial.
perform validate_s_cust.
endif.
at selection-screen on p_comp1.
*--Validating Company Code.
if not p_comp1 is initial.
perform validate_p_comp1.
endif.
at selection-screen on p_comp2.
*--Validating Company Code.
if not p_comp2 is initial.
perform validate_p_comp2.
endif.
START OF SELECTION
start-of-selection.
if p_vendor = 'X'.
perform get_vendor_data.
elseif p_cust = 'X'.
perform get_customer_data.
endif.
END OF SELECTION
end-of-selection.
if p_vendor = 'X'.
*--Generating the output for vendor
perform generate_field_catalog_vendor.
perform get_events_vendor.
perform generate_layout_vendor.
perform generate_sort_vendor.
perform generate_group_vendor.
perform disp_alv_grid_vendor.
elseif p_cust = 'X'.
*--Generating the output for customer
perform generate_field_catalog_cust.
perform get_events_customer.
perform generate_layout_customer.
perform generate_sort_customer.
perform generate_group_customer.
perform disp_alv_grid_customer.
endif.
*& Form validate_s_vendor
Validating the Vendor
form validate_s_vendor.
select rzzlifnr up to 1 rows
into (zzgeinz9a-rzzlifnr)
from zzgeinz9a
where rzzlifnr in s_vendor.
endselect.
if sy-subrc ne 0.
message e004 with 'Invalid Range of Vendor'(002)
s_vendor-low 'To'(006) s_vendor-high.
endif.
endform. " validate_s_vendor
*& Form validate_s_cust
Validating the Customer
form validate_s_cust.
select rzzkunnr up to 1 rows
into (zzgeinz9a-rzzkunnr)
from zzgeinz9a
where rzzkunnr in s_cust.
endselect.
if sy-subrc ne 0.
message e004 with 'Invalid Range of Customer'(005)
s_cust-low 'To'(006) s_cust-high.
endif.
endform. " validate_s_cust
*& Form validate_p_comp1
Validating the Company Code
form validate_p_comp1.
select single bukrs
into (t001-bukrs)
from t001
where bukrs eq p_comp1.
if sy-subrc ne 0.
message e004 with 'Company Code'(004) p_comp1 'Does not Exists'(003)
endif.
endform. " validate_p_comp1
*& Form validate_p_comp2
Validating the Company Code
form validate_p_comp2.
select single bukrs
into (t001-bukrs)
from t001
where bukrs eq p_comp2.
if sy-subrc ne 0.
message e004 with 'Company Code'(004) p_comp2 'Does not Exists'(003)
endif.
endform. " validate_p_comp2
*& Form get_vendor_data
Getting the Vendor Related Docs
form get_vendor_data.
select a~rzzlifnr
b~name1
a~docnr
a~refdocnr
a~rzz_ebeln
a~hsl
into corresponding fields of table it_final_vendor
from zzgeinz9a as a
inner join lfa1 as b
on arzzlifnr = blifnr
where rzzlifnr in s_vendor
and rbukrs eq p_comp1.
if sy-subrc eq 0.
v_flag = 'X'.
p_year = sy-datum+0(4).
perform get_doc_date using p_comp1
p_year.
perform move_records.
sort it_final_vendor by rzzlifnr.
perform generate_data.
else.
v_flag = space.
endif.
endform. " get_vendor_data
*& Form get_customer_data
Getting the Customer Related Docs
form get_customer_data.
select a~rzzkunnr
b~name1
a~docnr
a~refdocnr
a~rzz_ebeln
a~hsl
into corresponding fields of table it_final_customer
from zzgeinz9a as a
inner join kna1 as b
on arzzkunnr = bkunnr
where rzzkunnr in s_cust
and rbukrs eq p_comp2.
if sy-subrc eq 0.
v_flag = 'X'.
p_year = sy-datum+0(4).
perform get_doc_date_cust using p_comp2
p_year.
perform move_records_cust.
sort it_final_customer by rzzkunnr.
perform generate_data_cust.
else.
v_flag = space.
endif.
endform. " get_customer_data
*& Form get_doc_date
Getting the Document Date and FI Doc No
-->P_P_COMP1 Company Code
-->P_P_YEAR Fiscal Year
form get_doc_date using p_p_comp1
p_p_year.
loop at it_final_vendor.
concatenate it_final_vendor-refdocnr '*' into
it_final_vendor-doc_date.
modify it_final_vendor index sy-tabix.
endloop.
clear it_final_vendor.
data: v_doc_date(11) type c,
v_belnr like bkpf-belnr,
v_bldat like bkpf-bldat.
loop at it_final_vendor.
concatenate it_final_vendor-refdocnr '%' into v_doc_date.
select single belnr
bldat
into corresponding fields of it_final_vendor
from bkpf
where bukrs eq p_p_comp1
and gjahr eq p_p_year
and awkey like v_doc_date.
modify it_final_vendor.
endloop.
clear:it_final_vendor.
endform. " get_doc_date
*& Form move_records
Moving records to final internal table
form move_records.
*--Checking the existance of belnr in bsik
clear it_final_vendor.
select belnr
zbd1t
into table it_final_bsik
from bsik
for all entries in it_final_vendor
where belnr eq it_final_vendor-belnr
and bukrs eq c_bukrs.
clear it_final_bsik.
loop at it_final_vendor.
read table it_final_bsik with key belnr = it_final_vendor-belnr.
if sy-subrc eq 0.
it_final_vendor-zbd1t = it_final_bsik-zbd1t.
it_final_vendor-due_date = it_final_vendor-bldat +
it_final_bsik-zbd1t.
it_final_vendor-found = 'X'.
modify it_final_vendor.
endif.
endloop.
endform. " move_records
*& Form generate_data
Segregating the records based on due_date
form generate_data.
delete it_final_vendor[] where found ne 'X'.
sort it_final_vendor by belnr.
loop at it_final_vendor.
if it_final_vendor-due_date > p_rundt1.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-not_due.
elseif it_final_vendor-due_date < p_rundt1.
it_final_vendor-due_days = p_rundt1 - it_final_vendor-DUE_DATE.
endif.
*--filling 0-30 bucket.
if it_final_vendor-due_days ge 0 AND it_final_vendor-due_days le 30.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_0_30.
*--filling 31-60 bucket.
elseif it_final_vendor-due_days ge 31 AND it_final_vendor-due_days le 60
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_31_60.
*--filling 61-90 bucket.
elseif it_final_vendor-due_days ge 61 AND it_final_vendor-due_days le 90
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_61_90.
*--filling 91-180 bucket.
elseif it_final_vendor-due_days ge 91 AND it_final_vendor-due_days
le 180.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_91_180.
*--filling 180 bucket.
elseif it_final_vendor-due_days gt 180.
move-corresponding it_final_vendor to it_final_vendor_temp.
move it_final_vendor-hsl to it_final_vendor_temp-buck_180.
endif.
append it_final_vendor_temp.
clear it_final_vendor_temp.
endloop.
endform. " generate_data
*& Form DISP_ALV_GRID_VENDOR
Displaying the output in grid For Vendor
form DISP_ALV_GRID_VENDOR.
*--Generating the OUTPUT GRID FOR VENDOR
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = wa_layout
IT_FIELDCAT = i_fldcat_head
IT_EXCLUDING =
IT_SPECIAL_GROUPS = i_group
IT_SORT = it_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_events
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = it_final_vendor_temp
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.
endform. " DISP_ALV_GRID
*& Form get_doc_date_cust
text
-->P_P_COMP2 Company Code
-->P_P_YEAR Fiscal Year
form get_doc_date_cust using p_p_comp2
p_p_year.
loop at it_final_customer.
concatenate it_final_customer-refdocnr '*' into
it_final_customer-doc_date.
modify it_final_customer index sy-tabix.
endloop.
clear it_final_customer.
data: v_doc_date(11) type c,
v_belnr like bkpf-belnr,
v_bldat like bkpf-bldat.
loop at it_final_customer.
concatenate it_final_customer-refdocnr '%' into v_doc_date.
select single belnr
bldat
into corresponding fields of it_final_customer
from bkpf
where bukrs eq p_p_comp2
and gjahr eq p_p_year
and awkey like v_doc_date.
modify it_final_customer.
endloop.
clear:it_final_customer.
endform. " get_doc_date_cust
*& Form move_records_cust
Moving Customer Data to Final Internal Table
form move_records_cust.
*--Checking the existance of belnr in bsid
select belnr
zbd1t
into table it_final_bsid
from bsid
for all entries in it_final_customer
where belnr eq it_final_customer-belnr
and bukrs eq c_bukrs.
clear it_final_bsid.
loop at it_final_customer.
read table it_final_bsid with key belnr = it_final_customer-belnr.
if sy-subrc eq 0.
it_final_customer-zbd1t = it_final_bsid-zbd1t.
it_final_customer-due_date = it_final_customer-bldat +
it_final_bsid-zbd1t.
it_final_customer-found = 'X'.
modify it_final_customer.
endif.
endloop.
endform. " move_records_cust
*& Form generate_data_cust
Generating the Customer Output
form generate_data_cust.
delete it_final_customer[] where found ne 'X'.
sort it_final_customer by belnr.
loop at it_final_customer.
if it_final_customer-due_date > p_rundt2.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-not_due.
elseif it_final_customer-due_date < p_rundt2.
it_final_customer-due_days = p_rundt2 - it_final_customer-DUE_DATE.
endif.
*--filling 0-30 bucket.
if it_final_customer-due_days ge 0 AND it_final_customer-due_days le 30
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_0_30.
*--filling 31-60 bucket.
elseif it_final_customer-due_days ge 31 AND it_final_customer-due_days
le 60
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_31_60.
*--filling 61-90 bucket.
elseif it_final_customer-due_days ge 61 AND it_final_customer-due_days
le 90
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_61_90.
*--filling 91-180 bucket.
elseif it_final_customer-due_days ge 91 AND
it_final_customer-due_days
le 180.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_91_180.
*--filling 180 bucket.
elseif it_final_customer-due_days gt 180.
move-corresponding it_final_customer to it_final_customer_temp.
move it_final_customer-hsl to it_final_customer_temp-buck_180.
endif.
append it_final_customer_temp.
clear it_final_customer_temp.
endloop.
endform. " generate_data_cust
*& Form generate_field_catalog_vendor
Generating the Field Catalog for Vendor
form generate_field_catalog_vendor.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'IT_FINAL_VENDOR_TEMP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = i_fldcat_head
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if not i_fldcat_head[] is initial.
loop at i_fldcat_head into wa_fldcat_head.
case wa_fldcat_head-fieldname.
when 'RZZLIFNR'.
wa_fldcat_head-col_pos = '1'.
wa_fldcat_head-ref_tabname = ' '.
wa_fldcat_head-seltext_m = 'Vendor No'(001).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
when 'NAME1'.
wa_fldcat_head-col_pos = '2'.
wa_fldcat_head-seltext_m = 'Vendor Name'(007).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '35'.
when 'BELNR'.
wa_fldcat_head-col_pos = '3'.
wa_fldcat_head-seltext_m = 'Invoice No'(008).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-KEY = ' '.
when 'BLDAT'.
wa_fldcat_head-col_pos = '4'.
wa_fldcat_head-seltext_m = 'Document Date'(009).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'RZZ_EBELN'.
wa_fldcat_head-col_pos = '5'.
wa_fldcat_head-seltext_m = 'PO.Ref.No'(010).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'HSL'.
wa_fldcat_head-col_pos = '6'.
wa_fldcat_head-seltext_m = 'Invoice Amount'(011).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DUE_DATE'.
wa_fldcat_head-col_pos = '7'.
wa_fldcat_head-seltext_m = 'Due Date'(012).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-ref_tabname = ' '.
when 'DUE_DAYS'.
wa_fldcat_head-col_pos = '8'.
wa_fldcat_head-seltext_m = 'Due Days'(013).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '9'.
when 'NOT_DUE'.
wa_fldcat_head-col_pos = '9'.
wa_fldcat_head-seltext_m = 'Not Due'(014).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_0_30'.
wa_fldcat_head-col_pos = '10'.
wa_fldcat_head-seltext_m = '0 To 30'(015).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_31_60'.
wa_fldcat_head-col_pos = '11'.
wa_fldcat_head-seltext_m = '31 To 60'(016).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_61_90'.
wa_fldcat_head-col_pos = '12'.
wa_fldcat_head-seltext_m = '61 To 90'(017).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_91_180'.
wa_fldcat_head-col_pos = '13'.
wa_fldcat_head-seltext_m = '91 To 180'(018).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_180'.
wa_fldcat_head-col_pos = '14'.
wa_fldcat_head-seltext_m = 'Beyond 180'(019).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'REFDOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'DOC_DATE'.
wa_fldcat_head-no_out = 'X'.
when 'FOUND'.
wa_fldcat_head-no_out = 'X'.
endcase.
modify i_fldcat_head from wa_fldcat_head index sy-tabix.
endloop.
endif.
endform. " generate_field_catalog_vendor
*& Form get_events_vendor
Getting ALV Events
form get_events_vendor.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
importing
et_events = i_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.
if not i_events[] is initial.
read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
wa_event-form = 'GENERATE_USERCOMMAND'.
modify i_events from wa_event index sy-tabix.
read table i_events into wa_event with key name = 'END_OF_LIST'(025)
wa_event-form = 'GENERATE_USERCOMMAND_FOOTER'.
modify i_events from wa_event index sy-tabix.
endif.
endform. " get_events_vendor
*& Form GENERATE_USERCOMMAND
Displaying Header-Text and Logo on Grid
form generate_usercommand .
clear i_comment[].
wa_comment-typ = 'H'.
wa_comment-info = 'Vendor Ageing Report'(026).
append wa_comment to i_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_comment
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID = 'X'
endform. " GENERATE_USERCOMMAND
*& Form GENERATE_USERCOMMAND_FOOTER
Displaying Footer-Text on Grid
form generate_usercommand_footer.
clear i_comment[].
clear wa_comment.
wa_comment-typ = 'S'.
wa_comment-key = 'GE-Betz'(027).
append wa_comment to i_comment.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_comment
I_LOGO = ''
i_end_of_list_grid = 'X'.
endform. " GENERATE_USERCOMMAND_FOOTER
*& Form generate_layout_vendor
Generating the ALV Layout
form generate_layout_vendor.
WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "OPTIMIZING FIELD WIDTH
wa_layout-zebra = 'X'. "PUTTING ZEBRA COLORS
wa_layout-confirmation_prompt = 'X'. "DISPLAYS CONFIRMATION DIALOG
wa_layout-totals_text = 'Totals'(028). "DISPLAYS TOTALS TEXT
wa_layout-subtotals_text = 'Sub Totals'(029)."DISPLAYS SUBTOTALS TEXT
endform. " generate_layout_vendor
*& Form generate_sort_vendor
Sorting the Internal Table by Vendor
form generate_sort_vendor.
it_sort-fieldname = 'RZZLIFNR'.
it_sort-tabname = 'IT_FINAL_VENDOR_TEMP'.
it_sort-up = 'X'.
it_sort-subtot = 'X'.
append it_sort.
endform. " generate_sort_vendor
*& Form generate_group_vendor
Grouping the Data
form generate_group_vendor.
clear i_group.
wa_group-sp_group = 'A'.
wa_group-text = 'RZZLIFNR'.
append wa_group to i_group.
endform. " generate_group_vendor
*& Form GENERATE_FIELD_CATALOG_CUST
Generating Field Catalog for Customer
form GENERATE_FIELD_CATALOG_CUST.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'IT_FINAL_CUSTOMER_TEMP'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = i_fldcat_head
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
if not i_fldcat_head[] is initial.
loop at i_fldcat_head into wa_fldcat_head.
case wa_fldcat_head-fieldname.
when 'RZZKUNNR'.
wa_fldcat_head-col_pos = '1'.
wa_fldcat_head-ref_tabname = ' '.
wa_fldcat_head-seltext_m = 'Customer No'(020).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
when 'NAME1'.
wa_fldcat_head-col_pos = '2'.
wa_fldcat_head-seltext_m = 'Customer Name'(021).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '35'.
when 'BELNR'.
wa_fldcat_head-col_pos = '3'.
wa_fldcat_head-seltext_m = 'Invoice No'(008).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-KEY = ' '.
when 'BLDAT'.
wa_fldcat_head-col_pos = '4'.
wa_fldcat_head-seltext_m = 'Document Date'(009).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'RZZ_EBELN'.
wa_fldcat_head-col_pos = '5'.
wa_fldcat_head-seltext_m = 'PO.Ref.No'(010).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '13'.
wa_fldcat_head-ref_tabname = ' '.
when 'HSL'.
wa_fldcat_head-col_pos = '6'.
wa_fldcat_head-seltext_m = 'Invoice Amount'(011).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DUE_DATE'.
wa_fldcat_head-col_pos = '7'.
wa_fldcat_head-seltext_m = 'Due Date'(012).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '12'.
wa_fldcat_head-ref_tabname = ' '.
when 'DUE_DAYS'.
wa_fldcat_head-col_pos = '8'.
wa_fldcat_head-seltext_m = 'Due Days'(013).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '9'.
when 'NOT_DUE'.
wa_fldcat_head-col_pos = '9'.
wa_fldcat_head-seltext_m = 'Not Due'(014).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_0_30'.
wa_fldcat_head-col_pos = '10'.
wa_fldcat_head-seltext_m = '0 To 30'(015).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_31_60'.
wa_fldcat_head-col_pos = '11'.
wa_fldcat_head-seltext_m = '31 To 60'(016).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_61_90'.
wa_fldcat_head-col_pos = '12'.
wa_fldcat_head-seltext_m = '61 To 90'(017).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_91_180'.
wa_fldcat_head-col_pos = '13'.
wa_fldcat_head-seltext_m = '91 To 180'(018).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'BUCK_180'.
wa_fldcat_head-col_pos = '14'.
wa_fldcat_head-seltext_m = 'Beyond 180'(019).
wa_fldcat_head-ddictxt = 'M'.
wa_fldcat_head-outputlen = '16'.
wa_fldcat_head-do_sum = 'X'.
when 'DOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'REFDOCNR'.
wa_fldcat_head-no_out = 'X'.
when 'DOC_DATE'.
wa_fldcat_head-no_out = 'X'.
when 'FOUND'.
wa_fldcat_head-no_out = 'X'.
endcase.
modify i_fldcat_head from wa_fldcat_head index sy-tabix.
endloop.
endif.
endform. " GENERATE_FIELD_CATALOG_CUST
*& Form get_events_customer
Getting ALV Events
form get_events_customer.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
importing
et_events = i_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.
if not i_events[] is initial.
read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
wa_event-form = 'GENERATE_USERCOMMAND_CUST'.
modify i_events from wa_event index sy-tabix.
read table i_events into wa_event with key na -
Hi Dear All,
We have two real time infocubes and two aggregation levels based on these cubes in one multiprovider
first cube1 is like
char1| char2| keyfig_coefficient(single value for each combination of char1 and char2)
same aggregation level1
(we have input query to fill coefficients by one responsible user)
second cube2 is like
char1| char2| keyfig_quantity| keyfig_result
same aggregation level2
Input ready query should be like (for all other users of different org units)
char1|char2|keyfig_coeff| keyfig_quant(for input) | keyfig_result = keyfig_coeff*keyfig_quant(calculated value, should be saved to cube2)
And we don't have pregenerated lines in cube2, users have to add new lines themselves by wad.
Question is, what is the optimal (easiest) way to make calculation and save result data to cube2 where keyfigures for calculation should be used from different infoproviders. I need just a hint.
Appreciate any help.
Nadya.I found decision, agregation levels sould be based on multiprovider, not included.
-
Re: Statistics Query for Total runtimes for Process Chain incorrect
Hi Guys,
I am building a Query for Total runtimes for Process Chain Statistics. I used the Cube 0TCT_MC21 for Query - 0TCT_MC21_Q0101.
I dragged in Keyfigure section - startdate, end date, Start time are all correct and fine but the End time (0TCTENDTIM) is coming incorrect. Is something else i should use to get the End time?
Please let me know if any suggestions?
RegardsJust check if the end times are in GMT ?? usually happens with timestamps....
-
Query for Totals on a Sales Order
Does someone have a query for sales order that sums the total # of orders for each user and sums total quantity and Amts?
ThanksThat would not be a hard query to write. If you have started on the query, you may paste it if you are having difficulties getting the desired result.
Suda -
Query for Total sales by customer
Hi,
I want to create a query for getting a total of all sales for all Customers for the date range entered by the user.
How can I do it?
JyotiIf I can add my thoughts. The query from Jyoti fails for me due to the Where statement. Try the following:
SELECT T0.CardName, T0.Address, T1.CreditLine, T2.PymntGroup as 'Payment Terms', T1.Balance, T0.DocTotal
FROM OINV T0 INNER JOIN OCRD T1 ON T0.CardCode = T1.CardCode INNER JOIN OCTG T2 ON T0.GroupNum = T2.GroupNum
WHERE T0.DocDate BETWEEN '[%0]' AND '[%1]'
Having said that I use the built in Sales Analysis report to get the sales by customer by date.
regards,
Ralph -
Design Table with no of columns used for calculating the total
Hello,
I need to design a table/s for calculating the column values based on the operators provided. Like I have a table say
TableID, Col1 , Col2 ,Col3 ... Total Value
Total Value Column is calculating Col1 (operator value provided by the user) Col 2 (operator value provided by the user) Col3 etc
Although I m thinking to create another table which stores operator values, however not sure how to calculate the total.
like it can be COl 1 +Col2 -Col3 %Col4 etc.
Please help.Can you show some data example+ desired result?
DECLARE @t TABLE(a INT,b INT,c INT);
INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
SELECT *
, ( SELECT COUNT(val)
FROM (VALUES (a)
, (b)
, (c)
) AS value(val)
) AS CountVal
FROM @t;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Problem with subtotal calculation in ALV reports
Hi All,
I am doing one program for calculating subtoals in ALV . For this i want to display subtotal text at each envey subtotal 's row.
For that i have created one form 'SUB_SUBTOT_TEXT' and it has given to IT_EVENTS-FORM. But SUB_SUBTOT_TEXT Form is not called by IT_EVENTS event.
what are all the mandatories for displaying subtotal text.
Can any one please help me.
Thanks in Advance.Hi Sree,
*& Table declaration
&----TABLES: ekko.&----
*& Type pool declaration
TYPE-POOLS: slis. " Type pool for ALV&----
*& Selection screen
SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.&----
*& Type declaration
&----* Type declaration for internal table to store EKPO data
TYPES: BEGIN OF x_data,
ebeln TYPE char30, " Document no.
ebelp TYPE ebelp, " Item no
matnr TYPE matnr, " Material no
matnr1 TYPE matnr, " Material no
werks TYPE werks_d, " Plant
werks1 TYPE werks_d, " Plant
ntgew TYPE entge, " Net weight
gewe TYPE egewe, " Unit of weight
END OF x_data.&----
*& Internal table declaration
DATA:* Internal table to store EKPO data
i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
Internal table for storing field catalog information
i_fieldcat TYPE slis_t_fieldcat_alv,
Internal table for Top of Page info. in ALV Display
i_alv_top_of_page TYPE slis_t_listheader,
Internal table for ALV Display events
i_events TYPE slis_t_event,
Internal table for storing ALV sort information
i_sort TYPE slis_t_sortinfo_alv,
i_event TYPE slis_t_event.&----
*& Work area declaration
&----DATA:
wa_ekko TYPE x_data,
wa_layout TYPE slis_layout_alv,
wa_events TYPE slis_alv_event,
wa_sort TYPE slis_sortinfo_alv.&----
*& Constant declaration
&----CONSTANTS:
c_header TYPE char1
VALUE 'H', "Header in ALV
c_item TYPE char1
VALUE 'S'.&----
*& Start-of-selection event
&----START-OF-SELECTION.* Select data from ekpo
SELECT ebeln " Doc no
ebelp " Item
matnr " Material
matnr " Material
werks " Plant
werks " Plant
ntgew " Quantity
gewei " Unit
FROM ekpo
INTO TABLE i_ekpo
WHERE ebeln IN s_ebeln
AND ntgew NE '0.00'. IF sy-subrc = 0.
SORT i_ekpo BY ebeln ebelp matnr .
ENDIF.* To build the Page header
PERFORM sub_build_header.* To prepare field catalog
PERFORM sub_field_catalog.* Perform to populate the layout structure
PERFORM sub_populate_layout.* Perform to populate the sort table.
PERFORM sub_populate_sort.* Perform to populate ALV event
PERFORM sub_get_event.END-OF-SELECTION.* Perform to display ALV report
PERFORM sub_alv_report_display.
*& Form sub_build_header
To build the header
No Parameter
FORM sub_build_header .* Local data declaration
DATA: l_system TYPE char10 , "System id
l_r_line TYPE slis_listheader, "Hold list header
l_date TYPE char10, "Date
l_time TYPE char10, "Time
l_success_records TYPE i, "No of success records
l_title(300) TYPE c. " Title
Title Display
l_r_line-typ = c_header. " header
l_title = 'Test report'(001).
l_r_line-info = l_title.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR l_r_line.* Run date Display
CLEAR l_date.
l_r_line-typ = c_item. " Item
WRITE: sy-datum TO l_date MM/DD/YYYY.
l_r_line-key = 'Run Date :'(002).
l_r_line-info = l_date.
APPEND l_r_line TO i_alv_top_of_page.
CLEAR: l_r_line,
l_date.ENDFORM. " sub_build_header
*& Form sub_field_catalog
Build Field Catalog
No Parameter
FORM sub_field_catalog .* Build Field Catalog
PERFORM sub_fill_alv_field_catalog USING: '01' '01' 'EBELN' 'I_EKPO' 'L'
'Doc No'(003) ' ' ' ' ' ' ' ', '01' '02' 'EBELP' 'I_EKPO' 'L'
'Item No'(004) 'X' 'X' ' ' ' ', '01' '03' 'MATNR' 'I_EKPO' 'L'
'Material No'(005) 'X' 'X' ' ' ' ', '01' '03' 'MATNR1' 'I_EKPO' 'L'
'Material No'(005) ' ' ' ' ' ' ' ',
'01' '04' 'WERKS' 'I_EKPO' 'L'
'Plant'(006) 'X' 'X' ' ' ' ', '01' '04' 'WERKS1' 'I_EKPO' 'L'
'Plant'(006) ' ' ' ' ' ' ' ', '01' '05' 'NTGEW' 'I_EKPO' 'R'
'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM. " sub_field_catalog&----
*& Form sub_fill_alv_field_catalog
*& For building Field Catalog
*& p_rowpos Row position
*& p_colpos Col position
*& p_fldnam Fldname
*& p_tabnam Tabname
*& p_justif Justification
*& p_seltext Seltext
*& p_out no out
*& p_tech Technical field
*& p_qfield Quantity field
*& p_qtab Quantity table
FORM sub_fill_alv_field_catalog USING p_rowpos TYPE sycurow
p_colpos TYPE sycucol
p_fldnam TYPE fieldname
p_tabnam TYPE tabname
p_justif TYPE char1
p_seltext TYPE dd03p-scrtext_l
p_out TYPE char1
p_tech TYPE char1
p_qfield TYPE slis_fieldname
p_qtab TYPE slis_tabname.* Local declaration for field catalog
DATA: wa_lfl_fcat TYPE slis_fieldcat_alv. wa_lfl_fcat-row_pos = p_rowpos. "Row
wa_lfl_fcat-col_pos = p_colpos. "Column
wa_lfl_fcat-fieldname = p_fldnam. "Field Name
wa_lfl_fcat-tabname = p_tabnam. "Internal Table Name
wa_lfl_fcat-just = p_justif. "Screen Justified
wa_lfl_fcat-seltext_l = p_seltext. "Field Text
wa_lfl_fcat-no_out = p_out. "No output
wa_lfl_fcat-tech = p_tech. "Technical field
wa_lfl_fcat-qfieldname = p_qfield. "Quantity unit
wa_lfl_fcat-qtabname = p_qtab . "Quantity table IF p_fldnam = 'NTGEW'.
wa_lfl_fcat-do_sum = 'X'.
ENDIF.
APPEND wa_lfl_fcat TO i_fieldcat.
CLEAR wa_lfl_fcat.
ENDFORM. " sub_fill_alv_field_catalog&----
*& Form sub_populate_layout
Populate ALV layout
No Parameter
FORM sub_populate_layout . CLEAR wa_layout.
wa_layout-colwidth_optimize = 'X'." Optimization of Col widthENDFORM. " sub_populate_layout&----
*& Form sub_populate_sort
Populate ALV sort table
No Parameter
FORM sub_populate_sort .* Sort on material
wa_sort-spos = '01' .
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.* Sort on plant
wa_sort-spos = '02'.
wa_sort-fieldname = 'WERKS'.
wa_sort-tabname = 'I_EKPO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort .
CLEAR wa_sort.
ENDFORM. " sub_populate_sort&----
*& Form sub_get_event
Get ALV grid event and pass the form name to subtotal_text
event
No Parameter
FORM sub_get_event .
CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
'SUBTOTAL_TEXT'. DATA: l_s_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 4
IMPORTING
et_events = i_event
EXCEPTIONS
list_type_wrong = 0
OTHERS = 0.* Subtotal
READ TABLE i_event INTO l_s_event
WITH KEY name = slis_ev_subtotal_text.
IF sy-subrc = 0.
MOVE c_formname_subtotal_text TO l_s_event-form.
MODIFY i_event FROM l_s_event INDEX sy-tabix.
ENDIF.ENDFORM. " sub_get_event&----
*& Form sub_alv_report_display
For ALV Report Display
No Parameter
FORM sub_alv_report_display .
DATA: l_repid TYPE syrepid .
l_repid = sy-repid .* This function module for displaying the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = l_repid
i_callback_top_of_page = 'SUB_ALV_TOP_OF_PAGE'
is_layout = wa_layout
it_fieldcat = i_fieldcat
it_sort = i_sort
it_events = i_event
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = i_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'Error in ALV report display'(055).
ENDIF.ENDFORM. " sub_alv_report_display&----
FORM sub_alv_top_of_page
Call ALV top of page
No parameter
----FORM sub_alv_top_of_page. "#EC CALLED* To write header for the ALV
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_alv_top_of_page.
ENDFORM. "alv_top_of_page&----
*& Form subtotal_text
Build subtotal text
P_total Total
p_subtot_text Subtotal text info
FORM subtotal_text CHANGING
p_total TYPE any
p_subtot_text TYPE slis_subtot_text.
Material level sub total
IF p_subtot_text-criteria = 'MATNR'.
p_subtot_text-display_text_for_subtotal
= 'Material level total'(009).
ENDIF.* Plant level sub total
IF p_subtot_text-criteria = 'WERKS'.
p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
ENDIF.
ENDFORM. "subtotal_text
Hopes its helpful.
Regards,
Raj. -
Accessing the field values in different fields for calculation
Hi,
I am creating a report in which I have used breaks for grouping the customers by their category. I have used summary on the amount field to calculate the sum in the individual category and also for total amount.
Now, I also want to add an column which could display the percentages of individual contributions.
So, its like I have to write a query accessing the total percentage, categorized percentage and individual amount.
My question: How can I access the various fields values in the query of some other field specifically sum and total sum( because it shows the sum([Amount]) for category sum and total sum both)
-BOBJuserHmmm, I assume you are talking about WebIntelligence here...
Ok, so let's go: you can access every "object" in the report simply by it's name. Every cell contains either a constant value (e.g. some text) or a formula, the simplest one can be just the value of an "object" from the query.
There is a formula bar on top which you can activate, where you can easily see the content of a specific cell and also copy/paste the formula from the cell, as well as access all the built-in functions.
WebI has a built-in calculator which works very similar to a "micro" olap engine, so you can access every sort of aggregate (of a measure) via a correspondig formula, irrelevant in which cell you are using it.
Nevertheless, there is a "computation context" which depends on the place where you put the formula, e.g. summary row, detail row, etc.
for more info: see the manual )
hth, Walter -
Hi All
I have a table called Agent. Each Agent processes requests.
So accordingly Request is another table.
Now the Agent can process the request successfully, fail or it could be
in progress.
So accordingly I have a status column in the Request table which can have the following values
New - when the request is allocated to the agent
Open- When the agent opens the request
Action- when the agent acted upon the request
Sold - when the agent was successful in processing the request
Fail - when the agent could not process the request
In the Request table there is column called requestDate which is the
date when the Request was first inserted (i.e when its New)
Now whenever the agent acts upon the request from the front end
the status change is logged in a RequestLog table.
So when the agent changes the status to Open, an entry is logged into
RequestLog table.
So when the agent open the request an entry in the RequestLog table
would go with the status as open , the reference of the requestId &
the date on which the status is changed
Similar entries will be logged for each request when the agent acts on
the respective requests like if its Sold then the status will be sold,
the date of sale & the corresponding request Id will be logged into the
RequestLog table.
In the Request table the status will be changed to "Open" or "Sold" but the
requestDate will not change & it will remain the date when it was inserted
Now I want to generate a Report which shows the list of all agents within a state
with all total number of requests they have handled, how many are in Opened status,
how many are in Sold status & how many are in Fail status. I also have to show the
average time(in days) it took for each agent to Open the request, make the sale or qualify it
as Fail. This average time I want it for an agent & not request specific.
& In the end I have to show the grand total of all the requests handled by all the agents,
grand total of opened status requests,grand total of Sold status requests,grand total of Fail status requests as well as the total average time it took to Open ,total average time it took to sale & total average time it takes to Fail
I have dabbled with simple SQL but not a complex report type like above. So I would need help from all you experts.
Here is what I plan to do
my from clause would include the Agent, Request, RequestLog table
where Request.requestdate between <fromDate> and <toDate>
group by agent.agentname,
Select would have count(agent.requestid),
Now how do i show the list of Open requests, sold requests & fail requests in different columns since all these values are in the same column.
Also I am aware of the average fnction but I need help on how to use the same in such a scenario.
Do post your thoughts on the same.
RegardsHi All
I have made some queries to fetch the Report data. I would want you to post your comments on the same.
This is my first query which returns the total count of request per dealer, how much are in open, sent & dead state & total per status.
select AGENT.COMPANY_NAME,count(REQUEST.REQUEST_ID) TOTAL ,
sum(decode(REQUEST.status,'Open',1,0)) OPEN,
sum(decode(REQUEST.status,'Sent',1,0)) SENT,
sum(decode(REQUEST.status,'Dead',1,0)) DEAD
from AGENT, REQUEST
where
AGENT.STATE='ACT'
and REQUEST.REQUEST_TYPE='B'
and REQUEST.CONFIRMATION='Y'
and AGENT.DEALER_ID = REQUEST.DEALER_NUMBER
group by grouping sets(AGENT.COMPANY_NAME, ())
Then I have to retrieve the average number of days it takes to change the request to Open, average number of days it takes to change the request to Sent & average number of days it takes to change the request to Dead
per Agent. The base date is stored in REQUEST table (request_date column) & the subsequent change of status is stored in activity_date column
of ACTIVITY table
Here is what I do get the average number of days it takes to change the status for the Agent
select AGENT.COMPANY_NAME,
avg( decode (REQUEST.status,'Open',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_OPEN,
avg( decode (REQUEST.status,'Sent',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_SENT,
avg( decode (REQUEST.status,'Dead',ACTIVITY.ACTIVITY_DATE - REQUEST.REQUEST_DATE,0)) AVG_DEAD
from REQUEST, ACTIVITY, AGENT
where
AGENT.STATE='ACT'
and REQUEST.REQUEST_TYPE='B'
and REQUEST.CONFIRMATION='Y '
and REQUEST.dealer_number = AGENT.DEALER_ID
and REQUEST.STATUS = ACTIVITY.STATUS
group by grouping sets(AGENT.COMPANY_NAME, ())
I hope this is the right way for calculating average number of days
Since most part of the queries is the same
I tried to merge both the queries into one because I need to render the report in that fashion. But the moment I merge the query its giving absurd results.
Do post your thoughts on the same
Regards
Maybe you are looking for
-
Upgrading from Coldfusion 8 to 10, Flex won't work
Coldfusion 10 Flex 3 Existing Flash Application works with Coldfusion 8 Flex Integration is turned on. Running latest update 12 Linux Machine When I bring up the application I get the following error: mx.messaging.channels::AMFChannel)#3 in
-
Somehow I do not have the "refresh I Cloud" on my Outlook anymore? How do I get it back?
somehow I do not have the "refresh I Cloud" on my Outlook anymore? How do I get it back?
-
hi all, i am new to ip i am encountering an error in the web page while i open the start modeler , the error says 'Error While Obtaining JCO Connection' and i am able to see the tabs below.please let me know how can i proceed.thanks alot.
-
Oversea opportunity in SD/XI/BW.
Hello all, Am an ABAPer with one and half years of experience. 1)Which one of these three is best so that i a have maximum onsite(oversea) opportunities and my ABAP knowledge is utilised. 2)Can somebody tell me how and to what extend(Percantage wise
-
Inconsistencies with Read Out Loud on different Windows systems
Hello, I create 508-compliant accessible documents for my employer. These documents are read by several different reviewers internally, and we have noticed that there are differences with how the documents read for some reviewers. Some reviewers have