ALV Grand total currency wise.
Hi,
I am totalling the fields in ALV according wise. If i have two currency i.e USD and INR then total should come as Grand Total of all USD and INR. But in output it displays the cross(x) sign .
So how to use it
Hi,
hope this will help you,
For the totals of each currencies, I just inserted the following code in my form 'fill_fieldcat':
wa_fieldcat-fieldname = 'DMBTR'.
wa_fieldcat-ref_fieldname = 'DMBTR'.
wa_fieldcat-ref_tabname = 'BSEG'.
wa_fieldcat-cfieldname = 'WAERS'
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
And of course, there must be a currency field that will serve as the reference for the calculation of totals for the different currencies
Also refer this code
*& Form sub_field_cat
text
FORM sub_field_cat .
it_fieldcat1-fieldname = 'PERNR'.
it_fieldcat1-seltext_m = text-003.
it_fieldcat1-col_pos = 0.
it_fieldcat1-outputlen = 8.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
it_fieldcat1-fieldname = 'WORKDATE'.
it_fieldcat1-seltext_m = text-012.
it_fieldcat1-col_pos = 1.
it_fieldcat1-outputlen = 8.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
it_fieldcat1-fieldname = 'WEKLY'.
it_fieldcat1-seltext_m = text-015.
it_fieldcat1-col_pos = 2.
it_fieldcat1-outputlen = 7.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
it_fieldcat1-fieldname = 'LGART'.
it_fieldcat1-seltext_m = text-013.
it_fieldcat1-col_pos = 3.
it_fieldcat1-outputlen = 4.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
it_fieldcat1-fieldname = 'STDAZ'.
it_fieldcat1-seltext_m = text-014.
it_fieldcat1-col_pos = 4.
it_fieldcat1-outputlen = 7.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
it_fieldcat1-fieldname = 'RAUFNR'.
it_fieldcat1-seltext_m = text-016.
it_fieldcat1-col_pos = 5.
it_fieldcat1-outputlen = 12.
APPEND it_fieldcat1 TO it_fieldcat1.
CLEAR it_fieldcat1.
ENDFORM. " sub_field_cat
*& Form sub_display_data
text
FORM sub_display_data .
*--To sort the output through material number
DATA : lwa_sort TYPE slis_sortinfo_alv.
DATA : lit_sort TYPE slis_t_sortinfo_alv.
*--Pass the values to the table
lwa_sort-fieldname = 'PERNR'. "Field name in o/p inttable
lwa_sort-tabname = 'it_final2'. "Output Internal table
lwa_sort-spos = '1'. "Sort sequence
lwa_sort-up = 'X'. "Sort in ascending order
lwa_sort-down = ' '. "Sort in descending order
lwa_sort-subtot = 'X'. "Subtotal
APPEND lwa_sort TO lit_sort.
*--Pass the values to the table
lwa_sort-fieldname = 'WORKDATE'. "Field name in o/p inttable
lwa_sort-tabname = 'it_final2'. "Output Internal table
lwa_sort-spos = '2'. "Sort sequence
lwa_sort-up = 'X'. "Sort in ascending order
lwa_sort-down = ' '. "Sort in descending order
lwa_sort-subtot = ' '. "Subtotal
APPEND lwa_sort TO lit_sort.
*--Pass the values to the table
lwa_sort-fieldname = 'WEKLY'. "Field name in o/p inttable
lwa_sort-tabname = 'it_final2'. "Output Internal table
lwa_sort-spos = '3'. "Sort sequence
lwa_sort-up = 'X'. "Sort in ascending order
lwa_sort-down = ' '. "Sort in descending order
lwa_sort-subtot = ' '. "Subtotal
APPEND lwa_sort TO lit_sort.
wa_layout-colwidth_optimize = 'X'.
IF NOT it_final2[] IS INITIAL.
*--Call the function module to display the ALV report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = wa_layout
i_callback_program = v_repid
it_fieldcat = it_fieldcat1[]
i_default = c_chk
i_save = c_save
it_sort = lit_sort
TABLES
t_outtab = it_final2
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.
ELSE.
*--Message No data found
MESSAGE i888 WITH text-017.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " sub_display_data
Reward if found helpful...
Cheers,
Chandra Sekhar.
Similar Messages
-
hi friends,
how to find alv grand totals with out subtotals.
for ex for subtotals we use do_sum,
like that what we use for grand totals with out subtotals.Hi,
Do not pass the Sort table to ALV...pass X for the DO_SUM in the fieldcatalog for the field you want to have total.
g_fieldcat-tabname = 'I_INA2011'.
g_fieldcat-fieldname = 'HRTOT'.
g_fieldcat-coltext = 'Total Hours Work'(006).
g_fieldcat-do_sum = 'X'. " Pass this
APPEND g_fieldcat TO i_fieldcat.
CLEAR g_fieldcat.
* Calling method to display data.
CALL METHOD g_alv_grid->set_table_for_first_display
EXPORTING
is_layout = g_layout
i_save = 'A'
CHANGING
it_fieldcatalog = i_fieldcat
it_outtab = i_ina2011. -
hi gurus pls help me on this issue....... i want grand total on each column of this report.
for example field 'metric-safety'. if possbile try to edit this and send me.
TYPE-POOLS : slis.
Tables : Marc, " Plant Data for Material
Mbew, " Material Valuation
Ekpo, " Purchasing Document Item
Eord, " Purchasing Source List
Zpmt. " Purchasing Metric Table
Internal Tables Declaration----
Data : Begin of metric occurs 0,
matnr like marc-matnr, " Material number
werks like marc-werks, " Plant
minbe like marc-minbe, " Recoder Point
eisbe like marc-eisbe, " Safety Stock
stprs like mbew-stprs, " Standard Price
lifnr like eord-lifnr, " Vendor
menge like ekpo-menge, " PO Quantity
scalc type p decimals 2,
safety(20) type c,
tcalc type p decimals 2,
Target(20) type c,
acalc type p decimals 2,
actual(20) type c,
ecalc type p decimals 2,
excess(20) type c,
ucalc type p decimals 2,
usafety(20) type c,
*******Custom table
inscr like zpmt-inscr, " Inventory Score
stkot like zpmt-stkot, " Stock Out
impct like zpmt-impct, " Impact
nafta like zpmt-nafta, " %nafta
stscr like zpmt-stscr, " Stock Out Score
end of metric.
Data : final like metric occurs 0 with header line.
DATA: fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
**Data : Begin of output occurs 0,
lifnr like eord-lifnr, " Vendor
eisbe like marc-eisbe, " Safety Stock
minbe like marc-minbe, " Re-order Point
stprs like mbew-stprs, " Standard Price
sstock(13) type c, " Value of Safety Stock
Actual(13) type c, " Actual
Excess(13) type c, " Excess Inv
underSs(13) type c, " Under Safety Stock
end of output.
Data type Declaration----
Data : a type c value '$'.
Data : safety(20) type c,
target(20) type c,
actual(20) type c,
excess(20) type c,
usafety(20) type c,
repid like sy-repid.
data : i_pos type i.
Selection Screen----
selection-screen : begin of block b1 with frame Title tname.
Select-options: Mat for marc-matnr, " Material Number Selection
Plt for marc-werks, " Plant Selection
Vdr for eord-lifnr. " Vendor Selection
selection-screen : end of block b1.
Initialization----
initialization.
tname = 'Purchasing Metric Report'.
At Selection-Screen----
At selection-screen.
IF mat = ' ' and Plt = ' ' and Vdr = ' '.
message e000.
*elseif mat metric-matnr.
*message e001.
*elseif plt metric-werks.
*message e002.
*elseif vdr metric-lifnr.
*message e003.
endif.
Start-of-Selection----
Start-of-selection.
*******For Data Retrival
Perform Data_retrival.
*******For Calculation
Perform Calculation.
*******For Building Fieldcatalog
Perform Build_fieldcatalog.
*******Alv Display
Perform Alv_display.
*& Form Get_Data
text
FORM Data_retrival .
SELECT a~matnr
a~werks
a~eisbe
a~minbe
b~matnr
b~stprs
c~matnr
c~lifnr
d~matnr
d~menge
into corresponding fields of table metric from
( ( ( marc as a inner join mbew as b on bmatnr = amatnr )
inner join eord as c on cmatnr = amatnr )
inner join ekpo as d on dmatnr = amatnr )
where amatnr in mat and awerks in plt and c~lifnr in vdr.
if sy-subrc = 0.
sort metric by matnr.
endif.
ENDFORM. " Get_Data
*& Form Calculation
text
FORM Calculation .
loop at metric.
******calculation for safety stock ( safety stock * standard price )
metric-scalc = metric-eisbe * metric-stprs.
move metric-scalc to safety.
condense safety.
concatenate a safety into metric-safety.
******calculation for target ( safety stock + standard price )
metric-tcalc = ( metric-eisbe * metric-stprs ) + metric-stprs.
move metric-tcalc to target.
condense target.
concatenate a target into metric-target.
******calculation for Actual ( Po quantity * standard price )
metric-acalc = metric-menge * metric-stprs.
move metric-acalc to actual.
condense actual.
concatenate a actual into metric-actual.
******calculation for Excess Inv ( Actual - Target )
metric-ecalc = ( metric-menge * metric-stprs ) - ( ( metric-eisbe * metric-stprs ) + metric-stprs ).
move metric-ecalc to excess.
condense excess.
concatenate a excess into metric-excess.
******calculation for Under Safety Stock ( actual < safety stock. then actual + safety stock (Else) zero )
if actual < safety.
metric-menge * metric-stprs < metric-eisbe * metric-stprs.
metric-ucalc = ( metric-menge * metric-stprs ) + ( metric-eisbe * metric-stprs ).
else.
metric-ucalc = 0.
endif.
move metric-ucalc to usafety.
condense usafety.
concatenate a usafety into metric-usafety.
collect metric into final.
endloop.
ENDFORM. " Calculation
*--End-for-Selection--
*end-of-selection.
*loop at final.
*write : / final-lifnr, final-safety, final-target, final-actual, final-excess, final-usafety.
*endloop.
*& Form Build_fieldcatalog
text
--> p1 text
<-- p2 text
FORM Build_fieldcatalog .
fcat-fieldname = 'LIFNR'.
fcat-seltext_m = 'Vendor'.
fcat-col_pos = i_pos.
fcat-outputlen = 10.
fcat-emphasize = 'X'.
fcat-key = 'X'.
fcat-do_sum = 'X'.
fcat-edit = 'X'.
append fcat to fcat.
clear fcat.
i_pos = i_pos + 1.
fcat-fieldname = 'SAFETY'.
fcat-seltext_m = 'Safety Stock'.
fcat-col_pos = 2.
fcat-outputlen = 10.
fcat-emphasize = 'X'.
fcat-do_sum = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'ACTUAL'.
fcat-seltext_m = 'Actual'.
fcat-col_pos = 3.
fcat-outputlen = 10.
fcat-emphasize = 'X'.
fcat-do_sum = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'TARGET'.
fcat-seltext_m = 'Target'.
fcat-col_pos = 4.
fcat-outputlen = 10.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'EXCESS'.
fcat-seltext_m = 'Excess Inv'.
fcat-col_pos = 5.
fcat-outputlen = 10.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'USAFETY'.
fcat-seltext_m = 'Under Safety Stock'.
fcat-col_pos = 6.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'INSCR'.
fcat-seltext_m = 'Iventory Score'.
fcat-col_pos = 7.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'STKOT'.
fcat-seltext_m = 'Stock Out'.
fcat-col_pos = 6.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'IMPCT'.
fcat-seltext_m = 'Impact'.
fcat-col_pos = 6.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'NAFTA'.
fcat-seltext_m = '%Nafta'.
fcat-col_pos = 6.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
fcat-fieldname = 'STSCR'.
fcat-seltext_m = 'Safety Out Score'.
fcat-col_pos = 6.
fcat-outputlen = 20.
fcat-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fcat to fcat.
clear fcat.
ENDFORM. " Build_fieldcatalog
*& Form Alv_display
text
--> p1 text
<-- p2 text
FORM Alv_display .
repid = sy-repid.
*CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = fcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_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
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = final
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.
repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fcat[]
it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
is_variant = z_template
tables
t_outtab = final
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.
thx in advancehi,
for subtotal and grand total do the same thing like following,
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
if uesful rewars points -
How to combined 2 ALV grand total
Hi All,
We are using list display I have two ALV lists with same fields I want to combined the grand total of ALV lists and do some calculations and display in ALV_END_OF_LIST.Is it possible?
Thanks in Advance
Regards
DeepakHI,
Declare a Varialbe, and Move the First ALV total to thsi field, and while doing the Second ALV, add the total to that new field and print that field in the ALV_END_OF_LIST.
Regards
Sudheer -
How to create a grand total row wise in obiee reports
Hello every one,
Can any one please suggest me how can I achieve the below scenario
Presently I have
Total_bill_to_client Total wip_to_bill total_realization_amount total_carry_forwardamount
123334523234.00 4532423334.00 5324323234343434.00 3243242324324343324.00
I want this to be displayed in PIE graph,but before that I need to change the format, can you help me how to get this.
Total_bill_to_client 123334523234.00
Total_wip_to_bill 4532423334.00
total_realization_amount 5324323234343434.00
total_carry_forwardamount 3243242324324343324.00
Help me.
Thanks,
Ven
Edited by: 991688 on Mar 15, 2013 11:04 AMIs'nt there any dimension in your analysis here .? I see only measures but what are you asking OBIEE to base its pie and slices on to show the Pie Graph?
Let us know.
Thanks,
SVS -
Help regarding how to show total and grand total
hi all
please help me to show the total / grand total fund wise
i m giving final output that i want
which functions may i use .
following is my query
SELECT MUT_NAME , NATURE , BROK_TYPE ,sum(BROKERAGE) brokerage FROM (
SELECT MUT_NAME , NATURE , BROK_TYPE ,BROKERAGE FROM (
select mf.mut_name , si.nature ,'UPFRONT' BROK_TYPE , sum(up1.paid_brok) BROKERAGE from upfront_paid up , upfront_paid_dtl upd , upfront_pr up1 , scheme_info si , mut_fund mf
where up.slab_id = upd.slab_id
and up.SLAB_ID = up1.paid_slab_id
and up.sch_code = si.sch_code
and si.mut_code = mf.mut_code
-- and si.mut_code = 'MF004'
group by grouping sets ( (mf.mut_name , si.nature) ) ROLLUP(MF.MUT_NAME,SI.NATURE)
UNION ALL
select mf.mut_name , si.nature ,'TRAIL' BROK_TYPE , sum(up1.paid_brok) BROKERAGE from TRAIL_paid up , TRAIL_paid_dtl upd , TRAIL_pr up1 , scheme_info si , mut_fund mf
where up.slab_id = upd.slab_id
and up.SLAB_ID = up1.paid_slab_id
and up.sch_code = si.sch_code
and si.mut_code = mf.mut_code
-- and si.mut_code = 'MF004'
group by grouping sets ( (mf.mut_name , si.nature) ) ) ROLLUP(MF.MUT_NAME,SI.NATURE)
UNION ALL
SELECT 'TOTAL ' MUT_NAME , ' ' NATURE , ' ' BROK_TYPE ,SUM(BROKERAGE) FROM (
select mf.mut_name , si.nature ,'UPFRONT' BROK_TYPE , sum(up1.paid_brok) BROKERAGE
from upfront_paid up , upfront_paid_dtl upd , upfront_pr up1 , scheme_info si , mut_fund mf
where up.slab_id = upd.slab_id
and up.SLAB_ID = up1.paid_slab_id
and up.sch_code = si.sch_code
and si.mut_code = mf.mut_code
--and si.mut_code = 'MF004'
group by grouping sets ( (mf.mut_name , si.nature) ) ROLLUP(MF.MUT_NAME,SI.NATURE)
UNION ALL
select mf.mut_name , si.nature ,'TRAIL' BROK_TYPE , sum(up1.paid_brok) BROKERAGE from TRAIL_paid up , TRAIL_paid_dtl upd , TRAIL_pr up1 , scheme_info si , mut_fund mf
where up.slab_id = upd.slab_id
and up.SLAB_ID = up1.paid_slab_id
and up.sch_code = si.sch_code
and si.mut_code = mf.mut_code
-- and si.mut_code = 'MF004'
group by grouping sets ( (mf.mut_name , si.nature) ) ) ROLLUP(MF.MUT_NAME,SI.NATURE)))
GROUP BY grouping sets (MUT_NAME),( NATURE ),( BROK_TYPE)
ORDER BY MUT_NAME , NATURE , BROK_TYPE
Sl. No. Fund House Fund Type Brokerage Type "Type-wise
Commission " Gross Commission
(1) Fidelity Mutual Fund Equity Upfront Commission xxx
Trail xxx
Others xxx
Debt Upfront Commission xxx
Trail xxx
Others xxx
T O T A L : xxxxx
(2) Franklin Templeton Mutual Fund Equity Upfront Commission
Trail
Per Form
AUM Linked
SIP Advance Annual Brokerage
Others
Debt Upfront Commission
Trail
Others
T O T A L : xxxxx
CONSOLIDATED TOTAL COMMISSION : xxxxxany help appriciated.how can i use compute in procedure
actually i am giving the output from query to ref_cursor and from front end ( .NET) they are fetch rows and show the output.
i want output as fallows
fund name -- nature --- brok type --- brokerage
1] fidelity equity upfront 2000
equity trail 1000
debth upfront 1500
debth trail 500
Fidelity 5000
2] abc --
so on hope this clears you
Message was edited by:
Pankaj M -
Currency wise grand totals IN ALV
Hi friends,
I have problem in alv report, my requirement is want to display the
currency wise grand totals in ALV Report.if any having this idea please
address the solution.
yours
ramakrishna.Yif i am not wrong then ithink you are talking about subtotal as per currency .
then you have to use sort fnality..
you have to write your fieldcat for currency value field
wfieldcat-do_sum = 'X'.
data : isort type slis_t_sortinfo_alv,
wsort type slis_sortinfo_alv.
wsort-spos = 1.
wsort-up = 'X'.
wsort-fieldname = ' YOUR CURRency key field in caps'.
wsort-group = 'UL'.
append wsort to isort.
you have to pass that to reuse alv fm it_sort = isort.
regards
shiba dutta -
Sub total wise Grand total in ALV report
Dear All,
I am displaying a list of material through material group wise so for each material i want to display sub-total for stock and grand total of stock(material group wise).Here it is adding up all the stock displayed for different AUOM(alternative unit of measure ) which is for same material so i want to pick only the sub-total and sum up in my Grand total.
How to pick only the Sub-total Results and Add in ALV List for Grand total.
Thanks & Regards,
Arun.
Edited by: Arun Kumaran on Sep 24, 2008 7:46 AMHi arun,
check these links
total and subtotal in alv
ALV SUBTOTAL
Regards,
Anirban -
How to do subtotal and grand total as per currency in a tree ALV
Hi Experts,
I am doing a tree ALV for SD output. I met an urgent problem that is how to do subtotal and grand total on the field (netwr) as per currency (waerk) in the tree ALV. I am using below codes to create the tree ALV.
l_tree_container_name = 'CCONTAINER1'.
CREATE OBJECT objCustomContainer
EXPORTING
container_name = l_tree_container_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
create tree control
CREATE OBJECT objTree1
EXPORTING
parent = objCustomContainer
node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
item_selection = ' '
no_html_header = 'X'
no_toolbar = ''
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
illegal_node_selection_mode = 5
failed = 6
illegal_column_name = 7.
DATA l_hierarchy_header TYPE treev_hhdr.
call method buildHierarchyHeader
IMPORTING
p_hierarchy_header = l_hierarchy_header.
Build fieldcatalog
call method buildFieldcatalog.
CALL METHOD objTree1->set_table_for_first_display
EXPORTING
is_hierarchy_header = l_hierarchy_header
CHANGING
it_fieldcatalog = l_fieldcatalog
it_outtab = lt_order.
CALL METHOD objTree1->update_calculations.
CALL METHOD objTree1->frontend_update.
filling fieldcatalog,
LS_FIELDCATALOG-FIELDNAME = 'NETWR'.
LS_FIELDCATALOG-SCRTEXT_S = 'Net Value'.
LS_FIELDCATALOG-COL_POS = l_pos.
LS_FIELDCATALOG-OUTPUTLEN = 15.
LS_fieldcatalog-do_dum= 'X'.
LS_FIELDCATALOG-DATATYPE = 'CURR'.
APPEND LS_FIELDCATALOG TO l_FIELDCATALOG.
CLEAR LS_FIELDCATALOG.
l_pos = l_pos + 1.
I could see the subtotal and grandtotal in tree ALV but they are simply sumed up regardless different currency.
Thank you very much for your kindly helps.
Yuhi
good
go through this report and work accordingly.
REPORT ZALV.
TYPE-POOLS: SLIS.
DATA: G_REPID LIKE SY-REPID,
GS_PRINT TYPE SLIS_PRINT_ALV,
GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
GT_EVENTS TYPE SLIS_T_EVENT,
GT_SORT TYPE SLIS_T_SORTINFO_ALV,
GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
COL_POS TYPE I.
DATA: BEGIN OF ITAB,
FIELD1(5) TYPE C,
FIELD2(5) TYPE C,
FIELD3(5) TYPE P DECIMALS 2,
END OF ITAB.
DATA: BEGIN OF ITAB1 OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB1.
DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
INCLUDE STRUCTURE ITAB.
DATA: END OF ITAB_FIELDCAT.
Print Parameters
PARAMETERS:
P_PRINT AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
P_RESERV TYPE I. "NO OF FOOTER LINE
INITIALIZATION.
G_REPID = SY-REPID.
PERFORM PRINT_BUILD USING GS_PRINT. "Print PARAMETERS
START-OF-SELECTION.
TEST DATA
MOVE 'TEST1' TO ITAB1-FIELD1.
MOVE 'TEST1' TO ITAB1-FIELD2.
MOVE '10.00' TO ITAB1-FIELD3.
APPEND ITAB1.
MOVE 'TEST2' TO ITAB1-FIELD1.
MOVE 'TEST2' TO ITAB1-FIELD2.
MOVE '20.00' TO ITAB1-FIELD3.
APPEND ITAB1.
DO 50 TIMES.
APPEND ITAB1.
ENDDO.
END-OF-SELECTION.
PERFORM BUILD.
PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
PERFORM COMMENT_BUILD CHANGING GT_LIST_TOP_OF_PAGE.
PERFORM CALL_ALV.
FORM BUILD.
DATA FIELD CATALOG
Explain Field Description to ALV
DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD1'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
*FIELDCAT_LN-NO_OUT = 'X'. "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
FIELDCAT_LN-KEY = ' '. "SUBTOTAL KEY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD2'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-NO_OUT = 'X'.
FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
APPEND FIELDCAT_LN TO GT_FIELDCAT.
CLEAR FIELDCAT_IN.
FIELDCAT_LN-FIELDNAME = 'FIELD3'.
FIELDCAT_LN-TABNAME = 'ITAB1'.
FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
FIELDCAT_LN-REF_TABNAME = 'MSEG'. "<- REF TABLE IN THE DICTIONNARY
FIELDCAT_LN-NO_OUT = ' '.
FIELDCAT_LN-DO_SUM = 'X'. "SUM UPON DISPLAY
APPEND FIELDCAT_LN TO GT_FIELDCAT.
DATA SORTING AND SUBTOTAL
DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD1'.
GS_SORT-SPOS = 1.
GS_SORT-UP = 'X'.
GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
CLEAR GS_SORT.
GS_SORT-FIELDNAME = 'FIELD2'.
GS_SORT-SPOS = 2.
GS_SORT-UP = 'X'.
*GS_SORT-SUBTOT = 'X'.
APPEND GS_SORT TO GT_SORT.
ENDFORM.
FORM CALL_ALV.
ABAP List Viewer
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'ITAB1'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = GT_SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = GT_EVENTS[]
IT_EVENT_EXIT =
IS_PRINT = GS_PRINT
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
HEADER FORM
FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
CONSTANTS:
GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
*GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = LT_EVENTS.
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
define END_OF_PAGE event
READ TABLE LT_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO LS_EVENT.
IF SY-SUBRC = 0.
MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
APPEND LS_EVENT TO LT_EVENTS.
ENDIF.
ENDFORM.
FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
DATA: GS_LINE TYPE SLIS_LISTHEADER.
CLEAR GS_LINE.
GS_LINE-TYP = 'H'.
GS_LINE-INFO = 'HEADER 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'S'.
GS_LINE-KEY = 'STATUS 1'.
GS_LINE-INFO = 'INFO 1'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
GS_LINE-KEY = 'STATUS 2'.
GS_LINE-INFO = 'INFO 2'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
CLEAR GS_LINE.
GS_LINE-TYP = 'A'.
GS_LINE-INFO = 'ACTION'.
APPEND GS_LINE TO GT_TOP_OF_PAGE.
ENDFORM.
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
ENDFORM.
FORM END_OF_PAGE.
WRITE at (sy-linsz) sy-pagno CENTERED.
ENDFORM.
PRINT SETTINGS
FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
LS_PRINT-PRINT = P_PRINT. "PRINT IMMEDIATE
LS_PRINT-NO_PRINT_SELINFOS = P_NOSINF. "NO SELECTION INFO
LS_PRINT-NO_COVERPAGE = P_NOCOVE. "NO COVER PAGE
LS_PRINT-NO_NEW_PAGE = P_NONEWP.
LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
LS_PRINT-RESERVE_LINES = P_RESERV.
ENDFORM.
thanks
mrutyun^ -
I need the grand total for particular coulumn for ALV grid report(OOPs).
Hello,
I have used the following code,
But i m not getting the grand total by default.No error but not getting the desired result.
Could you please help me in this regard.
FORM display_simple_alv.
DATA : lr_msg TYPE REF TO cx_salv_msg.
DATA : lv_header TYPE REF TO cl_salv_form_layout_grid,
lv_h_label TYPE REF TO cl_salv_form_label,
lv_h_flow TYPE REF TO cl_salv_form_layout_flow.
DATA: gr_sorts TYPE REF TO cl_salv_sorts.
DATA: gr_agg TYPE REF TO cl_salv_aggregations.
TRY .
cl_salv_table=>factory( IMPORTING r_salv_table = gr_salv_table
CHANGING t_table = gt_invdetails4 ).
CATCH cx_salv_msg INTO lr_msg.
ENDTRY .
Display Basic Toolbar
gr_functions = gr_salv_table->get_functions( ).
gr_functions->set_all( abap_true ).
TRY .
gr_columns = gr_salv_table->get_columns( ).
gr_columns->set_optimize( ).
CATCH cx_salv_not_found.
ENDTRY .
TRY .
gr_column ?= gr_columns->get_column( 'KUNNR' ).
gr_column->set_long_text( text-009 ).
gr_column->set_medium_text( text-009 ).
gr_column->set_short_text( text-009 ).
gr_column ?= gr_columns->get_column( 'NAME1' ).
gr_column->set_long_text( text-010 ).
gr_column->set_medium_text( text-010 ).
gr_column->set_short_text( text-011 ).
gr_column ?= gr_columns->get_column( 'AMOUNT' ).
gr_column->set_long_text( text-012 ).
gr_column->set_medium_text( text-012 ).
gr_column->set_short_text( text-012 ).
gr_column ?= gr_columns->get_column( 'TAX' ).
gr_column->set_long_text( text-013 ).
gr_column->set_medium_text( text-013 ).
gr_column->set_short_text( text-013 ).
gr_column ?= gr_columns->get_column( 'IVA' ).
gr_column->set_long_text( text-014 ).
gr_column->set_medium_text( text-014 ).
gr_column->set_short_text( text-015 ).
gr_column ?= gr_columns->get_column( 'TOTAL_AMOUNT' ).
gr_column->set_long_text( text-016 ).
gr_column->set_medium_text( text-016 ).
gr_column->set_short_text( text-017 ).
gr_column ?= gr_columns->get_column( 'CURRENCY' ).
gr_column->set_long_text( text-018 ).
gr_column->set_medium_text( text-018 ).
gr_column->set_short_text( text-018 ).
gr_column ?= gr_columns->get_column( 'ZINTERNAL_REFNO' ).
gr_column->set_long_text( text-019 ).
gr_column->set_medium_text( text-019 ).
gr_column->set_short_text( text-019 ).
gr_column ?= gr_columns->get_column( 'MATERIAL_AMOUNT' ).
gr_column->set_long_text( text-020 ).
gr_column->set_medium_text( text-020 ).
gr_column->set_short_text( text-021 ).
gr_column ?= gr_columns->get_column( 'LABOUR_VALUE' ).
gr_column->set_long_text( text-022 ).
gr_column->set_medium_text( text-022 ).
gr_column->set_short_text( text-023 ).
gr_column ?= gr_columns->get_column( 'FAILURE_COST' ).
gr_column->set_long_text( text-024 ).
gr_column->set_medium_text( text-024 ).
gr_column->set_short_text( text-021 ).
gr_sorts = gr_salv_table->get_sorts( ).
gr_sorts->add_sort( columnname = 'AMOUNT' subtotal = abap_true ). "for subtotal
gr_agg = gr_salv_table->get_aggregations( ).
gr_agg->add_aggregation( 'AMOUNT' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY .
Set top of page
CREATE OBJECT lv_header.
lv_h_label = lv_header->create_label( row = 1 column = 1 ).
lv_h_label->set_text( text-001 ).
lv_h_label = lv_header->create_label( row = 1 column = 5 ).
lv_h_label->set_text( text-002 ).
lv_h_label = lv_header->create_label( row = 1 column = 14 ).
lv_h_label->set_text( text-003 ).
lv_h_flow = lv_header->create_flow( row = 3 column = 04 ).
lv_h_flow->create_text( text = text-004 ).
lv_h_flow = lv_header->create_flow( row = 3 column = 05 ).
lv_h_flow->create_text( text = text-005 ).
lv_h_flow = lv_header->create_flow( row = 3 column = 06 ).
lv_h_flow->create_text( text = name ).
set the top of list using the header for Online.
gr_salv_table->set_top_of_list( lv_header ).
ALV Display
gr_salv_table->display( ).
ENDFORM . " DISPLAY_SIMPLE_ALVHi Sridevi,
To get the grand total, you need to pass the SORT itab to the function module. You need to populate the internal table with the fields on which you want the total or subtotal. If you donu2019t pass this table, you wonu2019t get it.
For ex:
ls_sort_wa-spos = 1.
ls_sort_wa-fieldname = gs_plant-werks.
ls_sort_wa-up = 'X'.
ls_sort_wa-subtot = 'X'.
APPEND ls_sort_wa TO gt_sort.
So the above code, gives the sub total plant wise.
and if you want the sum(grand total) you can set the DO_SUM to u2018Xu2019 for that particular field in the field catalog.
So with this approach, you can get the sub total and grand total for a particular field.
If you donu2019t want the subtotal, just set DO_SUM, you will get the total.
Thanks,
Srini. -
Hi,
i am getting following ALv.
KUNNR BUY_CURR BUY_AMT SELL_CURR SELL_AMT AMT
now i want subtotal and grand total based on curr, mens based on BUY_CURR and SELL_CURR.
plz suggest.
thanxhi,
for that 2 fields use this statement.
fieldcatalog-fieldname = 'DMBTR'.
fieldcatalog-REF_TABNAME = 'BSEG'.
fieldcatalog-seltext_m = 'LOCAL CURRENCY'.
fieldcatalog-col_pos = 19.
fieldcatalog-cfieldname = 'WAERS1'. , < ---- use this
fieldcatalog-do_sum = 'X'.
fieldcatalog-emphasize = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog. -
Urgent:Grand total in hierarchical alv
I am printing a hierarchical alv with subtotals. I want to print the grand total for the whole numeric columns ...
Can anyone explain me how i can do this.
Thanks and regards,
SubhakarHi,
In this case you not only require the totals but the subtotals also.
For achieving this output you will have to sort the alv on the first column and also give subtotals there.
use
data: SORTF TYPE SLIS_SORTINFO_ALV,
TSORT TYPE SLIS_T_SORTINFO_ALV.
in the function module reuse_alv_grid_display give
it_sort = tsort.
eg:
FORM ALV_SHOW.
LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
LAYOUT-BOX_TABNAME = 'IT_DISPLAY'.
LAYOUT-INFO_FIELDNAME = 'LINE_COLOR'.
LAYOUT-ZEBRA = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = TCATALOG
IS_VARIANT = VAR1
I_SAVE = 'A'
IT_SORT = TSORT
IT_EVENTS = TEVENT[]
TABLES
T_OUTTAB = IT_DISPLAY.
ENDFORM . "ALV_SHOW
and write a subroutine for sort...
form sort.
CLEAR SORTF.
SORTF-spos = 1.
SORTF-fieldname = 'column_1'.
SORTF-tabname = 'IT_table used for display in alv'.
SORTF-up = 'X'.
SORTF-subtot = 'X'.
APPEND SORTF TO TSORT.
endform.
If this doesn't help I will send you the whole source of a sample program..
Abdullah -
Hide grand total field on ALV report, But keep the sub total fields
Dear Experts,
1) How to hide grand total field on ALV report, But keep the sub total fields.
2) How to populate rate per ton & calculate total price according to the qty in delivering document.Dear Experts,
1) How to hide grand total field on ALV report, But keep the sub total fields.
2) How to populate rate per ton & calculate total price according to the qty in delivering document. -
Alv subtotals and grand total for a field
Hi friends,
I Have an internal table ITAB1
in that i have a senario as below.
In my GRID display iam getting values in the layou as follows
BUKRS = 1000
LIFNR MATNR STCST
100 abc 500,00
100 pqr 400,00
100 xyz 200,00
sub total
200 pto 700,00
200 vbr 900,00
sub total
BUKRS = 2000
LIFNR MATNR STCST
150 abc 500,00
150 pqr 400,00
150 xyz 200,00
sub total
260 pto 700,00
260 vbr 900,00
sub total
GRAND TOTAL =
Now my requirement is at the end of every vendor i need sub total for STCST field.
and at the end of every company code i need GRAND TOTAL for STCST field.
Its alv grid display.
how can i do that.
Regards,
Priyanka.Check this sample code may it will help u:
*& Report Z_ALV_SUBTOTAL
REPORT z_alv_subtotal.
*& 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 width
ENDFORM. " 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
Edited by: Joyjit Ghosh on Aug 21, 2008 5:25 PM -
Subtotal in ALV grid for a particular type and Grand total in ALV
Hi,
I need to have sub total for a particular type(eg: goods, services).. and grand total at end in ALV grid..
ALV output required as below:
Type VAT registration number Country Total Gross Amounts Total Tax Amounts Total Amount, ex-tax
Goods ATU12345678 AT 222.42 0 222.42
Goods NL123456789B02 NL 3,417.00 0 3,417.00
Goods Total 3,639.42 - 3,639.42
Services ATU12345678 AT 2,342.34 0 2,342.34
Services NL123456789B02 NL 223.33 0 223.33
Services Total 2,565.67 - 2,565.67
Grand Total 6,205.09 - 6,205.09
Let me as to how to achieve the above type in ALV grid...
Regards
Shivacheck this link..
Grand Totals in ALV grid disply function module
or do like this..
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
*& Form getD_data
text
--> p1 text
<-- p2 text
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
*& Form disp_alv
text
--> p1 text
<-- p2 text
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv
Maybe you are looking for
-
Contribute 3: I am getting the following error: Title is "Problem running software" Message is It appears that your computer's clock has been moved back. Please restore the clock to it's previous time. This product won't run until the clock is proper
-
All photos in portrait format are displayed blurred in the preview mode "fill" of the library. In all other modes e.g. "fit"or "1:2" the photos are sharp. How can I change this, so that the photos are still sharp when displaying them in the mode "fil
-
Authorisation of reader (android)
how do I authorise my device an android eReader whit my ID Adobe thank you jgg95
-
Compare iWork/Office for Mac with Office Windows
I am an expert PC user switching to mac... I am moving toward google apps, but their doc program is not nearly as robust as MS WORD (windows). So, I need a sophisticated word processor... I have iWork 09 (bought it with the computer) and am consideri
-
Multiple Image Upload with save to database not working in IE anymore
Since updating IE to SP3 ADDT Multiple Image Upload with save to database does not work anymore in IE. It will show a regular file upload field, an does not allow selection of multiple files. It does work in Firefox, but not all my clients use firefo