ALV grid total line customizing
Dear Masters,
I need a solution for my problem. I need to modify sorting of subtotal and grand total based on currency which criteria i create myself. The standard alv output sort total by currency based on alpahabetical order, e.g: AUD, EUR, IDR, USD. I need to change the sorting into IDR, USD, AUD, EUR. How can i do it in alv grid?
I also like to add new line after grand total line, which is grand total in Local Currency, in this case, in IDR, which rate given. I can get the figure of subtotal, but i don't know how to append new line after grand total line output in alv standard.
Need your suggestion.
Many thanks,
Tiara
Hi,
I have used object oriented ALV. You can remove final total line and have sub total lines. Code below can help you.
1) Fieldcatalog you can do sum for currency values
2) Sort Build you can have sub totals.
3) layout_init you can remove final total line.
4) CALL METHOD grid->set_table_for_first_display you can pass above structure for excepted Result.
fieldcatalog_init
FORM fieldcatalog_init USING lt_fieldcatalog TYPE lvc_t_fcat
value(field_name) value(field_type) value(field_text) value(field_key).
DATA: ls_fieldcatalog TYPE lvc_s_fcat.
CLEAR ls_fieldcatalog.
ls_fieldcatalog-fieldname = field_name.
ls_fieldcatalog-datatype = field_type.
ls_fieldcatalog-reptext = field_text.
ls_fieldcatalog-coltext = field_text.
ls_fieldcatalog-seltext = field_text.
ls_fieldcatalog-tooltip = field_text.
ls_fieldcatalog-key = field_key.
IF field_type = 'CURR'.
ls_fieldcatalog-do_sum = 'X'.
ENDIF.
APPEND ls_fieldcatalog TO lt_fieldcatalog.
ENDFORM. "fieldcatalog_init
sort_build
FORM sort_build USING lt_sort TYPE lvc_t_sort.
DATA: ls_sort TYPE lvc_s_sort.
ls_sort-fieldname = 'BUKRS'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
IF p_comp <> 'X'.
ls_sort-fieldname = 'LIFNR'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDIF.
ls_sort-fieldname = 'WAERS'. "Fieldname on which to sort
ls_sort-subtot = 'X'.
ls_sort-up = 'X'. "Sort Ascending
APPEND ls_sort TO lt_sort.
ENDFORM. "sort_build
layout_init
FORM layout_init USING ls_layout TYPE lvc_s_layo.
DATA lv_date(10) TYPE c.
WRITE sy-datum TO lv_date.
IF p_line = 'X'.
CONCATENATE 'Line Item wise Report as on' lv_date INTO w_string2 SEPARATED BY space.
ELSEIF p_vend = 'X'.
CONCATENATE 'Vendor Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
ELSEIF p_comp = 'X'.
CONCATENATE 'Company Summary Report as on' lv_date INTO w_string2 SEPARATED BY space.
ENDIF.
ls_layout-zebra = 'X'.
ls_layout-grid_title = w_string2.
ls_layout-sel_mode = 'A'.
ls_layout-no_merging = 'X'.
ls_layout-cwidth_opt = 'X'.
ls_layout-no_totline = 'X'.
IF p_line = 'X'.
ls_layout-ctab_fname = 'COLINFO'.
ENDIF.
ENDFORM. "layout_init
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = va_layout "&see below
i_save = 'A' "&see below
i_default = ''
CHANGING
it_outtab = it_apout[]
it_fieldcatalog = gt_fieldcatalog
it_sort = gt_sort.
Edited by: Himanshu Dave on May 11, 2009 2:33 PM
Similar Messages
-
Alv grid dispaly in custom container....?
Hay friends i have shown ALV grid display in custom container .....in that some fields are input fields...
how can i modify my internal table (which is shown in ALV )...by knowing that this field is changed...i need to update in my internal table...
need help...
reply soon...Hello
All you need to know can be found in thread About events of class cl_gui_alv_grid and the links mentioned therein.
Regards
Uwe -
How to Expand ALV Grid Total Width
I have to display 1476 characters in an ALV grid and then the users will use what they need when creating a layout.
Problem is ALV stops after displaying 1375 (or so) characters) - any parm or action to do this (maybe in the catalog setup sent to the program? Thanks!Hi Scott
This may be a restriction ALV Grid puts. My recommendation will be that, split some fields and generate more than one rows with the same key (you should then add a new key field which will hold line numbers specific to one definite key). When you sort with ALV Grid's sort option the keys will vertically merged (if you do not turn off this feature via layout or field catalog settings). I know this is not so pretty but ALV is not intended to show that kind of stuff.
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a> -
ALV grid total or based on two key fields
Hello experts,
I have ALV grid with vendor, g/l account and amount field.
I want to have sum or total of each vendor, and if vendor having mutliple g/l accounts i want to have sum for each g/l account.
ex: vendor g/l account amount.
10 aa 100
10 bb 200
11 cc 300
olp : 10 aa 100
10 bb 200
11 cc 300
ex2 : vendor g/ account amount
10 aa 100
10 aa 200
11 cc 300
o/p 10 aa 300.
11 cc 300.
Could you please help me and any suggestions
<<Text removed>>
Thanks
reddy.
Edited by: Matt on Jul 27, 2011 9:21 AMHello Reddy,
Try using the sort functionality of ALV grid
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = lwa_layout
it_toolbar_excluding = i_excl_func
i_default = c_x
CHANGING
it_outtab = i_outtab[]
it_fieldcatalog = i_fieldcat[]
it_sort = li_sort[] "use this functionality as per your requirement
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
Hope this may be helpful.
Sharin -
hi there...I know there´s a lot of posts about this subject but i didn't find what i´m looking for...
I want to know if there´s some way to give a total and a sub-total of a field, but instead of the total and subtotal sums I just want a count of the number of rows for the field that I've sorted.
FIELDCATALOG-FIELDNAME = 'BUKRS'.
FIELDCATALOG-SELTEXT_M = 'BUKRS'.
FIELDCATALOG-COL_POS = 0.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'BUTXT'.
FIELDCATALOG-SELTEXT_M = 'BUTXT'.
FIELDCATALOG-COL_POS = 1.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'LIFNR'.
FIELDCATALOG-SELTEXT_M = 'LIFNR'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'NAME1'.
FIELDCATALOG-SELTEXT_M = 'NAME1'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MBLNR'.
FIELDCATALOG-SELTEXT_M = 'MBLNR'.
FIELDCATALOG-COL_POS = 4.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MJAHR'.
FIELDCATALOG-SELTEXT_M = 'MJAHR'.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'CPUDT'.
FIELDCATALOG-SELTEXT_M = 'CPUDT'.
FIELDCATALOG-COL_POS = 6.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'BUDAT'.
FIELDCATALOG-SELTEXT_M = 'BUDAT'.
FIELDCATALOG-COL_POS = 7.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'USNAM'.
FIELDCATALOG-SELTEXT_M = 'BUDAT'.
FIELDCATALOG-COL_POS = 8.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MENGE'.
FIELDCATALOG-SELTEXT_M = 'MENGE'.
FIELDCATALOG-COL_POS = 9.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'DMBTR'.
FIELDCATALOG-SELTEXT_M = 'DMBTR'.
FIELDCATALOG-COL_POS = 10.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
* SORT
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'BUKRS'.
WA_SORT-TABNAME = 'ITAB'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
WA_SORT-SPOS = 2.
WA_SORT-FIELDNAME = 'LIFNR'.
WA_SORT-TABNAME = 'ITAB'.
WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
in the alv i want to know the number of rows for each value of lifnr (sub-total) and in the end the total of the all values of lifnr
thanksHi,
It is better to obtain this information not in ALV but working on the table. Using control level processing it is easy to achieve.
data: begin of it_overview occurs 0
lifnr type ..
tot_item type i, "number of lifnr withing subtotal
end of it_overwiev.
data: pos type i. "to remember the position.
"your output table
Loop at it_ouptut.
at new lifnr.
pos = sy-tabix. "remember first position of new LIFNR
endat.
at end of lifnr.
it_overview-lifnr = it_output-lifnr.
it_overview-tot_item = sy-tabix - pos. "calculate how many within one LIFNR
append it_overview. "store it in the table
clear pos.
endat.
endloop.
this way table IT_OVERVIEW stores LIFNRs and number of items forming their subtotals.
To get total use:
DESCRIEBE TABLE it_output.
it_output-lifnr = 'TOTAL_ITEMS'. "total items within all LIFNRs
it_output-tot_item = sy-tfill. "is equal to total lines in the table
append it_output.
Regards
Marcin -
hi all,
I have an overflow error in alv total field.
first i filled alv grid using et_table_for_first_display, again i changed itab data
and use refresh_table_display to refresh data.
the alv contains total fields in field catalog.... when i try to 'refresh_table_display '
it comes an over flow error is coming and it comes every sort of records.. how can i trap this error ..??
thanks and regards
JoseHi Anup,
While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
In the method where you fill the field catalog , just add this component.
eg:
form catalog_fill changing p_field_catalog.
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'. "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
<b>ls_fcat-do_sum = 'X'.</b>
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'PRICE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'PRICE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Airfare' .
append ls_fcat to field_catalog .
endform.
In this way, you can get the total of any field in ALV.
Regards,
SP. -
ALV Grid Total Text (OOPS)
Hi All,
I have a simple ALV Grid Report(OOPS), I would like to give a Text for Total Row. In REUSE_ALV_GRID we have the option of giving this text, but i am not able to figure it out how to get the same in OOPS.
Regards
AnupHi Anup,
While using ALV with OOP methodology, you can create an extra row for giving the sum of any field.
In the field catalog, there is a component named 'DO_SUM', if set, will give the total value for the field.
In the method where you fill the field catalog , just add this component.
eg:
form catalog_fill changing p_field_catalog.
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'. "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
<b>ls_fcat-do_sum = 'X'.</b>
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'PRICE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'PRICE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Airfare' .
append ls_fcat to field_catalog .
endform.
In this way, you can get the total of any field in ALV.
Regards,
SP. -
ALV Grid Insert Line - Dumps only on certain computers
We have some ALV Grids in our program. Every time i open one my computer the first cell is marked, so the insert line function just adds another line. But on an other computer, the frist cell is somehow not marked, which leads to a dump on inserting a line, cause the return parameter for the row_idx is not filled. First i thought it's the user, but it isn't.
So i guess that the GUI might be at fault, how could i determin the differences? Or is there a setting for that?
Edited by: Robert Graf on Oct 30, 2008 1:35 PMHello Robert
When you open the SAP LogonPad then you find a symbol in the left upper corner. Click on it (left mouse) and choose function "About SAP Logon..." (Über SAP Logon...).
Then you see the exact version, build and patch-level of your SAP-GUI.
Regards
Uwe -
Hi,
I have created an application that uses a web dynpro alv grid. I want to display totals - is there a setting that can do this automatically - if so, can you please tell me how to do this? Thanks,Hi
You can take help of following code snippet to create totals for a particular column
Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column,
lt_column type salv_wd_t_column_ref,
ls_column type salv_wd_s_column_ref.
Data: lr_field_amnt type REF TO CL_SALV_WD_FIELD.
* get reference of ALV component
lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
* get function settings
lr_function_settings ?= wd_this->alv_config_table.
* display columns in correct order
lr_column_settings ?= wd_this->alv_config_table.
lt_column = lr_column_settings->get_columns( ).
loop at lt_column into ls_column.
CASE ls_column-id.
when 'AMOUNT'
* aggregate field
CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
EXPORTING
FIELDNAME = 'AMOUNT'
RECEIVING
VALUE = lr_field_amnt.
* create aggregate rule as total
CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
EXPORTING
AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
RECEIVING
VALUE = lv_aggr_rule.
endcase.
Regards
Manas DUa -
Hi,
I have a ALV grid where I have a column as a editable. Now the problem is ALV grid is displaying 2 rows and only first line should be editable. Any idea how to do.
KK.Hi,
1. * Type of final output table
TYPES : BEGIN OF ty_output.
INCLUDE STRUCTURE zjay_alv.
For cell editing and displaying cell as push button
TYPES : <b>cellstyles TYPE lvc_t_styl</b> ,
END OF ty_output.
data itab2 TYPE STANDARD TABLE OF ty_output.
2. w_layout-stylefname = 'CELLSTYLES' ."
3. CLEAR : wa2, w_style.
READ TABLE itab2 INTO wa2 index 2.
IF sy-subrc EQ 0.
w_style-fieldname = 'ERSDA'.
w_style-style = cl_gui_alv_grid=>mc_style_disabled.
REFRESH wa2-cellstyles.
APPEND w_style TO wa2-cellstyles.
MODIFY itab2 FROM wa2 TRANSPORTING cellstyles
WHERE matnr = wa2-matnr.
ENDIF.
4. CALL METHOD o_grid->set_table_for_first_display
EXPORTING
is_layout = w_layout
CHANGING
it_outtab = itab2
it_fieldcatalog = i_fieldcat.
Kindly reward points by clicking the star on the left of reply,if it helps. -
Hi Experts,
i have issue were in i need to show sum of the amount. like example...
for Custmer 100 there are vendor number 10,20,30,40,50. so for all this vendor numbers..
vendor----- amount
10 -
100
20----
200
30----
300
40----
400
50-------500
so in the output i want it to be..
customer--vendornumber--
amount
1000--10--
1500
20---
30---
40---
50---
.hope u experts have undestood. so how can i add the it and show it in the output....
am forwarding my code also..
Corrects answers will be fully rewarded..
REPORT zrfi007 NO STANDARD PAGE HEADING LINE-SIZE 255 MESSAGE-ID z01.
TYPE-POOLS: slis, abap.
* TYPES Declaration
TYPES: BEGIN OF ty_lfa1,
lifnr TYPE lfa1-lifnr,
name1 TYPE lfa1-name1,
END OF ty_lfa1.
TYPES: BEGIN OF ty_bsik,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
END OF ty_bsik.
TYPES: BEGIN OF ty_lfb1,
lifnr TYPE lfb1-lifnr,
bukrs TYPE lfb1-bukrs,
END OF ty_lfb1.
TYPES: BEGIN OF ty_final,
bukrs TYPE bsik-bukrs,
lifnr TYPE bsik-lifnr,
belnr TYPE bsik-belnr,
bldat TYPE bsik-bldat,
days TYPE sy-datum,
waers TYPE bsik-waers,
dmbtr TYPE bsik-dmbtr,
* waers type bsik-waers,
wrbtr TYPE bsik-wrbtr,
zfbdt TYPE bsik-zfbdt,
zbd1t TYPE bsik-zbd1t,
zbd2t TYPE bsik-zbd2t,
zbd3t TYPE bsik-zbd3t,
name1 TYPE lfa1-name1,
current TYPE bsik-dmbtr,
d30 TYPE bsik-dmbtr,
d60 TYPE bsik-dmbtr,
d90 TYPE bsik-dmbtr,
d120 TYPE bsik-dmbtr,
d180 TYPE bsik-dmbtr,
d240 TYPE bsik-dmbtr,
d360 TYPE bsik-dmbtr,
da365 TYPE bsik-dmbtr,
* ct_date TYPE sy-datum,
* date TYPE datum,
* days TYPE char8,
END OF ty_final.
* Data Declaration.
DATA: gt_lfa1 TYPE STANDARD TABLE OF ty_lfa1,
wa_lfa1 TYPE ty_lfa1.
DATA: gt_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final.
DATA: gt_bsik TYPE STANDARD TABLE OF ty_bsik,
wa_bsik TYPE ty_bsik.
DATA: gt_lfb1 TYPE STANDARD TABLE OF ty_lfb1,
wa_lfb1 TYPE ty_lfb1.
DATA: days TYPE sy-datum.
* ALV Components
**** ALV Internal Table
DATA : i_layout TYPE slis_layout_alv OCCURS 0 WITH HEADER LINE,
i_events TYPE slis_t_event,
i_fieldcat TYPE slis_t_fieldcat_alv,
i_print TYPE slis_print_alv,
i_list_top TYPE slis_t_listheader,
i_list_end TYPE slis_t_listheader,
i_sort TYPE slis_t_sortinfo_alv.
DATA: wa_fieldcat LIKE LINE OF i_fieldcat.
* ALV Variable.
DATA: v_top TYPE slis_formname VALUE 'TOP_OF_PAGE',
v_eop TYPE slis_formname VALUE 'END_OF_PAGE',
v_eol TYPE slis_formname VALUE 'END_OF_LIST',
v_tol TYPE slis_formname VALUE 'TOP_OF_LIST'.
**** ALV Variants
DATA: i_variant LIKE disvariant.
* Selection screen
DATA: v_bukrs TYPE bukrs,
v_lifnr TYPE kunnr,
pa_bldat TYPE bldat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_bukrs FOR v_bukrs NO INTERVALS NO-EXTENSION OBLIGATORY,
s_lifnr FOR v_lifnr.
* bldat FOR v_bldat no-extension.
PARAMETERS: p_bldat TYPE bsik-bldat.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: p_detail RADIOBUTTON GROUP r1 DEFAULT 'X',
p_sumry RADIOBUTTON GROUP r1.
SELECTION-SCREEN END OF BLOCK b2.
* Top-Of-Page Declaration Header
DATA: lwa_list_top LIKE LINE OF i_list_top.
DATA: lv_header(70),
lv_text(50),
lv_text1(60),
lv_text2(50),
lv_text3(50) ,
lv_text4(50),
lv_date TYPE char10,
lv_time TYPE char10.
DATA: lv_butxt LIKE t001-butxt,
lv_butxt1 LIKE lfa1-name1,
lv_butxt2 LIKE lfb1-lifnr.
INITIALIZATION.
*TOP-OF-PAGE.
* Validations for Selection screen
AT SELECTION-SCREEN ON s_bukrs.
IF NOT s_bukrs[] IS INITIAL.
SELECT SINGLE bukrs FROM lfb1
INTO s_bukrs
WHERE bukrs IN s_bukrs.
ENDIF.
IF sy-subrc NE 0.
MESSAGE e003.
ENDIF.
AT SELECTION-SCREEN ON s_lifnr.
IF NOT s_lifnr[] IS INITIAL.
SELECT SINGLE lifnr FROM lfa1
INTO s_lifnr
WHERE lifnr IN s_lifnr.
IF sy-subrc NE 0.
MESSAGE e005.
ENDIF.
ENDIF.
AT SELECTION-SCREEN ON p_bldat.
IF NOT p_bldat IS INITIAL.
SELECT SINGLE bldat FROM bsid
INTO p_bldat
WHERE bldat = p_bldat.
IF sy-subrc NE 0 .
MESSAGE e004.
ENDIF.
ENDIF.
* Selection For Top-of-page.
** Get company code description
SELECT SINGLE butxt
FROM t001 INTO lv_butxt
WHERE bukrs IN s_bukrs.
* SELECT SINGLE lifnr FROM lfb1
* INTO lv_butxt2 WHERE bukrs IN s_bukrs.
* SELECT SINGLE name1 FROM lfa1
* INTO lv_butxt1 WHERE lifnr = lv_butxt2.
START-OF-SELECTION.
PERFORM data_retrival.
PERFORM f_layout_init.
PERFORM f_eventtab_build.
i_variant-report = sy-repid.
PERFORM f_print_control.
* PERFORM f_build_header_list.
* perform f_build_header_list1.
* PERFORM f_build_fieldcat.
IF p_detail = 'X'.
PERFORM f_build_sort.
PERFORM fill_fieldcat.
PERFORM f_build_header_list.
ELSE.
PERFORM f_build_sort1.
PERFORM fill_fieldcat_sum.
PERFORM f_build_header_list1.
ENDIF.
PERFORM f_list_display TABLES gt_final[].
END-OF-SELECTION.
*& Form data_retrival
* text
* --> p1 text
* <-- p2 text
FORM data_retrival .
SELECT bukrs
lifnr
belnr
bldat
waers
dmbtr
wrbtr
zfbdt
zbd1t
zbd2t
zbd3t
FROM bsik INTO TABLE gt_bsik
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr.
SELECT lifnr
name1
FROM lfa1 INTO TABLE gt_lfa1
FOR ALL ENTRIES IN gt_bsik
WHERE lifnr = gt_bsik-lifnr.
LOOP AT gt_bsik INTO wa_bsik.
READ TABLE gt_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_bsik-lifnr.
MOVE-CORRESPONDING wa_bsik TO wa_final.
MOVE-CORRESPONDING wa_lfa1 TO wa_final.
DATA: days TYPE char2,
c4 TYPE char2.
DATA: days1 TYPE sy-datum.
DATA:duedate TYPE rfpos-faedt.
CALL FUNCTION 'NET_DUE_DATE_GET'
EXPORTING
i_zfbdt = wa_final-zfbdt
i_zbd1t = wa_final-zbd1t
i_zbd2t = wa_final-zbd2t
i_zbd3t = wa_final-zbd3t
i_shkzg = ' '
i_rebzg = ' '
* I_KOART = 'D'
IMPORTING
e_faedt = duedate.
CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
EXPORTING
i_datum_bis = duedate
i_datum_von = wa_final-bldat
* I_KZ_EXCL_VON = '0'
* I_KZ_INCL_BIS = '0'
* I_KZ_ULT_BIS = ' '
* I_KZ_ULT_VON = ' '
* I_STGMETH = '0'
* I_SZBMETH = '1'
IMPORTING
e_tage = days
EXCEPTIONS
days_method_not_defined = 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.
wa_final-days = duedate.
DATA : wf_char TYPE char10.
wf_char = days.
IF wf_char+0(1) EQ '*' .
SKIP.
ELSE.
IF days EQ 0.
wa_final-current = wa_bsik-wrbtr.
ELSEIF days LE 30 AND days GT 0.
wa_final-d30 = wa_bsik-wrbtr.
ELSEIF days LE 60 AND days GT 30 .
wa_final-d60 = wa_bsik-wrbtr.
ELSEIF days LE 90 AND days GT 60.
wa_final-d90 = wa_bsik-wrbtr.
ELSEIF days LE 120 AND days GT 90.
wa_final-d120 = wa_bsik-wrbtr.
ELSEIF days LE 180 AND days GT 120.
wa_final-d180 = wa_bsik-wrbtr.
ELSEIF days LE 240 AND days GT 180.
wa_final-d240 = wa_bsik-wrbtr.
ELSEIF days LE 360 AND days GT 240.
wa_final-d360 = wa_bsik-wrbtr.
ELSEIF days GT 365 .
wa_final-da365 = wa_bsik-wrbtr.
ENDIF.
ENDIF.
APPEND wa_final TO gt_final.
CLEAR: wa_final,
days,
duedate,days1.
ENDLOOP.
ENDFORM. " data_retrival
*& Form fill_fieldcat
* text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Document Number' 'BELNR',
'Document Date' 'BLDAT',
'Due Date' 'DAYS',
'Total In Document Currency' 'WRBTR',
'Currency' 'WAERS',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
* '181-365 days' 'D365',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat
*& Form fill_fieldcat_sum
* text
FORM fill_fieldcat_sum.
PERFORM fill_fields USING: 'Vendor Number' 'LIFNR',
'Vendor Name' 'NAME1',
'Total In Reporting Currency' 'DMBTR',
'Current' 'CURRENT',
'1-30 days' 'D30',
'31-60 days' 'D60',
'61-90 days' 'D90',
'91-120 days' 'D120',
'121-180 days' 'D180',
'181-240 days' 'D240',
'241-360 days' 'D360',
'Above 365 days' 'DA365'.
ENDFORM. "fill_fieldcat_sum
*& Form fill_fields
* text
* -->&01 text
* -->&02 text
FORM fill_fields USING &01 &02 .
wa_fieldcat-tabname = 'T_OUTPUT'. "t_output_provgr
wa_fieldcat-fieldname = &02.
wa_fieldcat-seltext_m = &01.
* wa_fieldcat-ref_fieldname = fieldname.
* wa_fieldcat-ref_tabname = 'SFLIGHT'.
* w_fieldcat-do_sum = &03.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. "fill_fields
*& Form f_layout_init
* Set the layout
FORM f_layout_init.
* P_layout-min_linesize = 170.
* p_layout-max_linesize = 170.
* P_layout-no_colhead = abap_true.
* p_layout-detail_popup = abap_true.
i_layout-colwidth_optimize = abap_true.
i_layout-zebra = abap_true.
* i_layout-subtotals_text = 'SubTotal'.
* i_layout-totals_text = 'Total'.
ENDFORM. " f_layout_init
*& Form f_eventtab_build
* Set the events
FORM f_eventtab_build.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.
READ TABLE i_events WITH KEY name = slis_ev_top_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_top TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_page
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eop TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_eol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_top_of_list
INTO ls_event.
IF sy-subrc = 0.
MOVE v_tol TO: ls_event-form,
ls_event-name.
APPEND ls_event TO i_events.
ENDIF.
ENDFORM. " f_eventtab_build
*& Form f_print_control
* Set the print control
FORM f_print_control .
* i_print-no_print_listinfos = abap_true.
* i_print-no_print_selinfos = abap_true.
* i_print-reserve_lines = 2.
* i_print-no_change_print_params = abap_true.
ENDFORM. " f_print_control
*& Form f_build_header_list
* Build the header list (top of page)
FORM f_build_header_list .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
* Header
CLEAR lwa_list_top.
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
* Company Code
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text2.
lwa_list_top-info = s_bukrs-low.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
** Vendor Number
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text3.
* lwa_list_top-info = lv_butxt2.
* APPEND lwa_list_top TO i_list_top.
* CLEAR lwa_list_top.
**Vendor Name
* lwa_list_top-typ = 'S'.
* lwa_list_top-key = lv_text4.
* lwa_list_top-info = lv_butxt1.
* APPEND lwa_list_top TO i_list_top.
ENDFORM. " f_build_header_list
*& Form f_build_header_list1
* text
* --> p1 text
* <-- p2 text
FORM f_build_header_list1 .
lv_header = 'Vendor Open Item Analysis By Balance Of Overdue Items'(h01).
lv_text = 'Company Name:'(s01).
lv_text1 = 'Open Item As Key Date:'(s02).
lv_text2 = 'Company Code:'(s03).
lv_text3 = 'Vendor Number:'(s04).
lv_text4 = 'Vendor Name:'(s05).
lwa_list_top-typ = 'H'.
lwa_list_top-info = lv_header.
APPEND lwa_list_top TO i_list_top.
* Run date Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-datum TO lv_date MM/DD/YYYY.
lwa_list_top-key = 'Date :'(025).
lwa_list_top-info = lv_date.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_date.
* Run time Display
lwa_list_top-typ = 'S'. " Item
WRITE: sy-uzeit TO lv_time USING EDIT MASK '__:__:__'.
lwa_list_top-key = 'Time :'(026).
lwa_list_top-info = lv_time.
APPEND lwa_list_top TO i_list_top.
CLEAR: lwa_list_top,
lv_time.
CLEAR lwa_list_top.
* Company Name
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text.
lwa_list_top-info = lv_butxt.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
*Open Item As Key Date
lwa_list_top-typ = 'S'.
lwa_list_top-key = lv_text1.
lwa_list_top-info = p_bldat.
APPEND lwa_list_top TO i_list_top.
CLEAR lwa_list_top.
ENDFORM. " f_build_header_list1
*& Form f_build_sort
* Set the sorting sequence
FORM f_build_sort .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'NAME1'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
** l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'LIFNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '1'.
* l_sort-fieldname = 'VBELN'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
* l_sort-spos = '2'.
* l_sort-fieldname = 'POSNR'.
* l_sort-up = abap_true.
* l_sort-subtot = abap_true.
* APPEND l_sort TO i_sort.
ENDFORM. " f_build_sort
*& Form f_list_display
* Display the ALV list report
* -->PT_DATA Internal table containing the data
FORM f_list_display TABLES pt_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = i_variant-report
is_layout = i_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sort
i_default = 'X'
i_save = 'A'
is_variant = i_variant
it_events = i_events[]
is_print = i_print
TABLES
t_outtab = pt_data.
ENDFORM. "f_list_display
*& Form TOP_OF_PAGE
* TOP_OF_PAGE Event
FORM top_of_page. "#EC CALLED
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
* i_logo = 'ZLOGO_BAB'
it_list_commentary = i_list_top
i_alv_form = 'X'.
* PERFORM f_print_header USING SPACE SPACE SPACE.
ENDFORM. "TOP_OF_PAGE
*& Form END_OF_PAGE
* END_OF_PAGE Event
FORM end_of_page. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF PAGE ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_PAGE
*& Form END_OF_LIST
* END_OF_LIST Event
FORM end_of_list. "#EC CALLED
* DATA: l_pos(3) TYPE n VALUE 0,
* l_foot(30) VALUE '*** END OF REPORT ***'.
* l_pos = ( sy-linsz / 2 ) - ( STRLEN( l_foot ) / 2 ).
* ULINE.
* WRITE: /, AT l_pos l_foot.
ENDFORM. "END_OF_LIST
*& Form f_print_header
* Print the header (Top-Of-Page)
* -->P_P_TITLE1 Title text 1
* -->P_P_TITLE2 Title text 2
* -->P_P_TITLE3 Title text 3
FORM f_print_header USING p_title1 LIKE sy-title
p_title2 LIKE sy-title
p_title3 LIKE sy-title.
DATA: l_post1 TYPE i,
l_post2 TYPE i,
l_post3 TYPE i,
l_posin TYPE i.
l_post1 = ( sy-linsz / 2 ) - ( STRLEN( p_title1 ) / 2 ).
l_post2 = ( sy-linsz / 2 ) - ( STRLEN( p_title2 ) / 2 ).
l_post3 = ( sy-linsz / 2 ) - ( STRLEN( p_title3 ) / 2 ).
l_posin = sy-linsz - 17.
WRITE: / 'Report :', sy-cprog.
WRITE AT l_post1 p_title1.
WRITE AT l_posin 'Date :'.
WRITE sy-datum.
WRITE: / 'Cli/Sys :', sy-mandt, '/', sy-sysid.
WRITE AT l_post2 p_title2.
WRITE AT: l_posin 'Time :'.
WRITE sy-uzeit.
WRITE: / 'UserID :', sy-uname.
WRITE AT l_post3 p_title3.
WRITE AT l_posin 'Page :'.
WRITE sy-pagno NO-ZERO.
ENDFORM. " f_print_header
*& Form f_build_sort1
* text
* --> p1 text
* <-- p2 text
form f_build_sort1 .
DATA: l_sort TYPE slis_sortinfo_alv.
l_sort-spos = '1'.
l_sort-fieldname = 'LIFNR'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
l_sort-spos = '2'.
l_sort-fieldname = 'NAME1'.
l_sort-up = abap_true.
l_sort-group = '*'.
* l_sort-subtot = 'X'.
APPEND l_sort TO i_sort.
* l_sort-spos = '3'.
* l_sort-fieldname = 'DMBTR'.
* l_sort-up = abap_true.
* l_sort-group = '*'.
* l_sort-subtot = 'X'.
* APPEND l_sort TO i_sort.
endform. " f_build_sort1
Regards
Sunita.Hey,
U can try out "SORTING THE VENDORS AND DO THE SUM in the NETWR"... try it out....see u sort the customers...rit?...keep it as usual and little mentoned above...
hope dis help u out...
Thanks. -
Hi,
We are using REUSE_ALV_GRID_DISPLAY for diaplying grid . we want the totals to be displayed for some fields.
but for percentage fields we want to calculate the values. How do we do this?Hi Asharaghu,
FOR TOTAL:
there is a property of fieldcatalog, that is do_sum.
USE COED LIKE:
PERFORM fieldcat USING:
'1' 'KUNNR' 'I_MARD' 'CUSTOMER NO' ,
'2' 'DMBTR' 'I_MARD' 'CURRENCY' ,
FORM fieldcat USING value(p_0029)
value(p_0030)
value(p_0031)
value(p_0032)
wa_fieldcat-col_pos = p_0029.
wa_fieldcat-fieldname = p_0030.
wa_fieldcat-tabname = p_0031.
wa_fieldcat-reptext = p_0032.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO i_fieldcat.
ENDFORM. " FIELDCAT
Then pass i_fieldcat through REUSE_ALV_GRID_DISPLAY.
in final output you will get the total of currency field.
Hope this can solve your problems.
Regards,
Tutun -
Refresh Editable ALV Grid inside a custom Container
Hello all,
I am having a screen with custom container in which i am populating datas and a entry screen which is going to have my
filtering condition for this custom container screen..
The problem i am facing is whenever i come out of the custom container screen after displaying and again give the
necessary filtering data in the previous screen...
the custom container screen displays wrong values...
But when i refresh the data with the refresh icon in the container right datas are coming...
I even used CALL METHOD C_ALVGD->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = STABLE
EXCEPTIONS
FINISHED = 1
OTHERS = 2. after displaying the values using
CALL METHOD C_ALVGD->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = T_FUNC
IS_LAYOUT = IT_LAYOUT
I_SAVE = 'A'
CHANGING
IT_OUTTAB = IT_ZCAWNT_V
IT_FIELDCATALOG = IT_FCAT
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
OTHERS = 4.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I have refreshed my internal table once when i display and again fetched from the DB according to the filtering conditions given
in the first screen.
I have tried clearing the Object created once when i display and again recreated it.But could not get the output.
solution would be really helpful...Hey all,
Thanks a lot for helping me...
The problem is solved....
i just used,
CALL METHOD C_ALVGD->FREE. 'Grid inside the container
CLEAR C_ALVGD.
CALL METHOD C_CCONT->FREE. "Container
CLEAR C_CCONT.
when i click BACK Button from screen 2 to screen1. -
ME57 ALV Grid adding some custom fields (columns)
Hi all,
does anyone know if it is possible to add some custom col's to the ALV where i see the Overview of PO Requests in ME57 ?
seems to me that i have to find a possibilty to expand the structure MEREQ3214 .
can i do this with the exit MEREQ001 ? if yes, which component should i use ?
Thanks for some ideas.
TonyHi Tony,
I am facing the same issue. Did you ever get to any solution regarding it ?
Thanks,
Gaurav -
Blank Line in an ALV Grid on screen
Hello,
I have added one ALV grid on a custom screen and appended it to the Opportunity Management transaction in CRM. The issue is that as soon as i toggle from display to change mode in the transaction, a blank line is itself appended to the ALV grid. I dont want this blank line. How do i suppress it? Can anyone help me with this.
Rgds
PriyankaYes you are correct But then how do i take care of the toggle and the blank line that is appended on the ALV screen table at the time of toggle ... coz toggle is called as a standard method in the standard code and i dont wanna change that.
Rgds
Priyanka
Maybe you are looking for
-
I have iTunes Match and I have three problems.
1) I am unable to add my "Holiday Music" playlist to my iPhone. I deleted the playlist "Christmas Music" and added "Holiday Music". I manually drag and dropped it to my iPhone on iTunes, but the content never showed up. I have tried just about ev
-
PSE 6 generating thumbnails on 128 pics for 2 days
I'm running Win 7 and PSE 6 and have 37,000+ pics and videos in my catalog...been using PSE since v2. I came home from vacation the other day, imported 128 pics from an SD card, and PSE 6 has been generating thumbnails for those pics for almost 2 day
-
PSFunction - problem with the syntax
Hi folks, I grabbed a Function-Example from: get-help about_Functions. I'm having some problems to understand that simple function. It goes like that: function Get-NewPix $start = Get-Date -Month 1 -Day 1 -Year 2013 $allpix = Get-ChildItem -Path $env
-
hi, I am using 11g 1.2 and ADF BC I followed the sample "http://andrejusb.blogspot.com/2010/05/crud-operations-in-oracle-adf-11g-table.html" and built a same thing in my bound task-flow. the 'Edit' , 'Insert' , 'Save' and 'Undo' button worked perfect
-
Creative Cloud Set-Up won't run
I have just downloaded the Creative Cloud Set-Up program so that I can install creative cloud on my desktop P.C. but it won't run. I can see the icon on my desktop but I just can't seem to get it to open or run the program. I've tried re-downloading