Total time in ALV grid
Hi anyone!
Is there a way to get a total for the column containing time? If I use ls_fcat-do_sum = 'X' the totals line is not displayed.
Thanks in advance.
Specify DO_SUM = 'X' option for the column which you want the totals while filling the fieldcat for it.
sample code is as follows:
Check & Run the follow ABAP Code
*& Report ZALV_Block *
REPORT ZALV_block NO STANDARD PAGE HEADING
MESSAGE-ID ZZ.
*..Type Definitions for ALV Report
TYPE-POOLS SLIS.
Table Declarations. *
TABLES: MARA, "Material Master
MARC, "Plant Data for Material
MARD, "Storage Location Data for Material
VBAP, "Sales Document: Item Data
VBUP. "Sales Document: Item Status
Internal table to store sales orders.......
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "Sales Document
POSNR LIKE VBAP-POSNR, "Sales Document Item
KWMENG LIKE VBAP-KWMENG, "Cumulative order quantity in sales
" Units
END OF IT_VBAP.
internal table to store final data
DATA: BEGIN OF IT_FINAL OCCURS 0,
WERKS LIKE MARD-WERKS, "Plant
MATNR LIKE MARD-MATNR, "Material Number
LGORT LIKE MARD-LGORT, "Storage Location
LABST LIKE MARD-LABST, "Valuated stock with unrestricted use
INSME LIKE MARD-INSME, "Stock in quality inspection
RETME LIKE MARD-RETME, "Blocked Stock Returns
UMLME LIKE MARD-UMLME, "Stock in transfer
MAKTX LIKE MAKT-MAKTX, "Material description
VBELN LIKE VBAP-VBELN, "Sales Document
POSNR LIKE VBAP-POSNR, "Sales Document Item
KWMENG LIKE VBAP-KWMENG, "Cumulative order quantity in sales
" Units
END OF IT_FINAL.
ALV Type declaration *
*..Field Catalog for Basic List.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*..Events For Basic List.
DATA : IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT.
*..Layout For Basic List
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
*..Sort Table For Basic List
DATA: IT_SORT TYPE SLIS_SORTINFO_ALV OCCURS 0 WITH HEADER LINE.
DATA DECLARATIONS *
DATA: V_FLAG,
VINDEX TYPE SY-TABIX,
TOTAL TYPE VBAP-KWMENG. "Open order quantity
*..To Store Program Name
DATA: V_REPID TYPE SYREPID.
*..To know whether basic list contains any data
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR,
S_WERKS FOR MARC-WERKS,
S_LGORT FOR MARD-LGORT.
SELECTION-SCREEN END OF BLOCK B1.
Event:Initialization *
INITIALIZATION.
V_REPID = SY-REPID.
AT Selection Screen. *
AT SELECTION-SCREEN.
PERFORM VALIDATIONS.
Event: Start-of-Selection *
START-OF-SELECTION.
To get data from vbap into internal table IT_VBAP
PERFORM FETCH_OPEN_DATA.
To get data into final internal table IT_FINAL
IF V_FLAG = 'X'.
PERFORM FETCH_FINAL_DATA.
ENDIF.
IF V_FLAG = ''.
MESSAGE I010 WITH 'NO DATA TO BE DISPLAYED'.
EXIT.
ELSE.
--Setting the FIELD CATALOG for ALV
PERFORM FILL_FIELDCAT_HEADER.
*-----Setting the LAYOUT for ALV
PERFORM GET_LAYOUT.
*-----Getting the ALV Events
PERFORM GET_EVENT.
*---- To Sort the list
PERFORM DO_SORT.
ENDIF.
Event: End-of-Selection *
END-OF-SELECTION.
*--Generating the ALV LIST DISPLAY
PERFORM DISPLAY_LIST.
FORM DEFINITIONS *
*& Form VALIDATIONS
To validate data in selection screen
--> p1 text
<-- p2 text
FORM VALIDATIONS.
PERFORM VALIDATE_MATNR.
PERFORM VALIDATE_WERKS.
PERFORM VALIDATE_LGORT.
IF NOT ( ( MARA-MATNR IS INITIAL ) AND
( MARC-WERKS IS INITIAL ) AND
( MARD-LGORT IS INITIAL ) ).
SELECT SINGLE MATNR
WERKS
LGORT
FROM MARD
INTO (MARD-MATNR, MARD-WERKS, MARD-LGORT)
WHERE MATNR = MARA-MATNR
AND WERKS = MARC-WERKS
AND LGORT = MARD-LGORT.
ENDIF.
ENDFORM. " VALIDATIONS
*& Form VALIDATE_MATNR
To validate MATNR
--> p1 text
<-- p2 text
FORM VALIDATE_MATNR.
IF NOT S_MATNR[] IS INITIAL.
SELECT MATNR
UP TO 1 ROWS
INTO (MARD-MATNR)
FROM MARA
WHERE MATNR IN S_MATNR.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-001.
ENDIF.
ENDFORM. " VALIDATE_MATNR
*& Form VALIDATE_WERKS
To validate plant
--> p1 text
<-- p2 text
FORM VALIDATE_WERKS.
IF NOT S_WERKS[] IS INITIAL.
SELECT WERKS
UP TO 1 ROWS
INTO (MARD-WERKS)
FROM MARC
WHERE WERKS IN S_WERKS.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-002.
ENDIF.
ENDFORM. " VALIDATE_WERKS
*& Form VALIDATE_LGORT
To validate storage
--> p1 text
<-- p2 text
FORM VALIDATE_LGORT.
IF NOT S_LGORT[] IS INITIAL.
SELECT LGORT
UP TO 1 ROWS
INTO (MARD-LGORT)
FROM MARD
WHERE LGORT IN S_LGORT.
ENDSELECT.
ENDIF.
IF SY-SUBRC NE 0.
MESSAGE E000 WITH TEXT-003.
ENDIF.
ENDFORM. " VALIDATE_LGORT
*& Form FETCH_OPEN_DATA
To get data into internal table IT_VBAP
--> p1 text
<-- p2 text
FORM FETCH_OPEN_DATA.
IF NOT ( ( MARA-MATNR IS INITIAL ) AND
( MARC-WERKS IS INITIAL ) AND
( MARD-LGORT IS INITIAL ) ).
SELECT VBELN
POSNR
KWMENG
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP
WHERE MATNR IN S_MATNR
AND WERKS IN S_WERKS
AND LGORT IN S_LGORT.
ENDIF.
LOOP AT IT_VBAP.
SELECT * FROM VBUP
INTO VBUP
WHERE VBELN = IT_VBAP-VBELN
AND POSNR = IT_VBAP-POSNR
AND LFSTA NE 'C'.
ENDSELECT.
ENDLOOP.
IF SY-SUBRC NE 0.
REFRESH IT_VBAP.
MESSAGE E000 WITH TEXT-004.
EXIT.
ELSE.
V_FLAG = 'X'.
ENDIF.
To get sum of all quantities as open order quantity
LOOP AT IT_VBAP.
TOTAL = TOTAL + IT_VBAP-KWMENG.
ENDLOOP.
ENDFORM. " FETCH_OPEN_DATA
*& Form FETCH_FINAL_DATA
To get data into final internal table IT_FINAL
--> p1 text
<-- p2 text
FORM FETCH_FINAL_DATA.
SELECT A~MATNR
A~WERKS
A~LGORT
MAKTX
LABST
INSME
RETME
UMLME
VBELN
POSNR
KWMENG
INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
FROM MARD AS A
INNER JOIN MAKT AS B
ON AMATNR = BMATNR
AND SPRAS = 'E'
INNER JOIN VBAP AS C
ON AMATNR = CMATNR
FOR ALL ENTRIES IN IT_VBAP
WHERE VBELN = IT_VBAP-VBELN
AND POSNR = IT_VBAP-POSNR
AND KWMENG = IT_VBAP-KWMENG
AND A~MATNR IN S_MATNR
AND A~WERKS IN S_WERKS
AND A~LGORT IN S_LGORT.
IF SY-SUBRC NE 0.
V_FLAG = SPACE.
MESSAGE E001 WITH 'No data found IN the selection criteria'.
EXIT.
ELSE.
V_FLAG = 'X'.
ENDIF.
ENDFORM. " FETCH_FINAL_DATA
*& Form FILL_FIELDCAT_HEADER
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_HEADER .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_FINAL'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCAT
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.
LOOP AT IT_FIELDCAT INTO WA_FIELDCAT.
CASE WA_FIELDCAT-FIELDNAME.
WHEN 'KWMENG'.
WA_FIELDCAT-COL_POS = '11'.
WA_FIELDCAT-OUTPUTLEN = '22'.
WA_FIELDCAT-SELTEXT_L = 'Net Value'.
WA_FIELDCAT-DO_SUM = 'X'.
ENDCASE.
MODIFY IT_FIELDCAT FROM WA_FIELDCAT INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_HEADER
*& Form GET_LAYOUT
text
--> p1 text
<-- p2 text
FORM GET_LAYOUT .
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM. " GET_LAYOUT
*& Form GET_EVENT
text
--> p1 text
<-- p2 text
FORM GET_EVENT .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = IT_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_EVENTS INTO WA_EVENTS.
CASE WA_EVENTS-NAME.
WHEN 'TOP_OF_PAGE'.
WA_EVENTS-FORM = 'FILL_LIST_HEADER'.
WHEN 'USER_COMMAND'.
WA_EVENTS-FORM = 'PROCESS_BASIC_LIST'.
ENDCASE.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " GET_EVENT
FORM FILL_LIST_HEADER *
FORM FILL_LIST_HEADER.
WRITE:2'Report :' , SY-REPID,
: 85 ' Intelligroup Asia Pvt Ltd' CENTERED,
: 159 'Date :' ,SY-DATUM,
:/2'User :', SY-UNAME,
: 82 ' Hyderabad ' CENTERED ,
: 159 'Pg.No :' ,SY-PAGNO,
:/86 ' Stock Report ' CENTERED.
SKIP 2.
ENDFORM. "FILL_LIST_HEADER
*& Form DISPLAY_LIST
text
--> p1 text
<-- p2 text
FORM DISPLAY_LIST .
CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = 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 = IT_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.
ENDFORM. " DISPLAY_LIST
*& Form do_sort
text
--> p1 text
<-- p2 text
FORM DO_SORT .
*-- Populating the sort table
IT_SORT-FIELDNAME = 'MATNR'.
IT_SORT-TABNAME = 'IT_FINAL'.
IT_SORT-UP = 'X'.
it_sort-subtot = 'X'.
APPEND IT_SORT.
ENDFORM. " do_sort
regards
navjot
award points if helpfull
Similar Messages
-
Can i change the values in total column in ALV Grid program. I had made one report with 3 hirerchy level and for first hirerchy i need different total values just for one column as total values are misleading the users. is it possible to change the value total field in ALV?
hi
make the fields for which u r displaying total as editable.
so when ever u make changes in the column,
see the sample code, i have done a similar program
FORM DATA_CHANGED_MATRIX USING P_ER_DATA_CHANGED TYPE REF TO
CL_ALV_CHANGED_DATA_PROTOCOL P_ONF4 type C E_UCOMM TYPE SY-UCOMM.
DATA: VALUE LIKE YRECORDINGD_QDMS-SCORE.
CLEAR VALUE.
data: begin of wa_tot,
TOTAL_SCORE like yrecordingd_qdms-score,
end of wa_tot.
DATA: BEGIN OF WA_DATA,
SRNO type i,
LOCATION LIKE YCONCERNS_QDMS-LOCATION,
LOC_DESC LIKE YLOCATION_QDMST-LOC_DESC,
TOTAL_SCORE LIKE YRECORDINGD_QDMS-SCORE,
END OF WA_DATA.
FIELD-SYMBOLS: <LS_VALUE1> TYPE ANY,
<LS_VALUE2> TYPE ANY.
DATA: L_VALUE TYPE LVC_VALUE,
ls_mod_cell type lvc_s_modi.
SORT P_ER_DATA_CHANGED->MT_MOD_CELLS BY ROW_ID.
LOOP AT P_ER_DATA_CHANGED->MT_MOD_CELLS INTO LS_MOD_CELL.
CALL METHOD P_ER_DATA_CHANGED->GET_CELL_VALUE
EXPORTING
I_ROW_ID = LS_MOD_CELL-row_id
I_FIELDNAME = LS_MOD_CELL-fieldname
IMPORTING
E_VALUE = L_VALUE.
VALUE = L_VALUE.
IF VALUE < 100.
READ TABLE <TEMP_TAB> INTO <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
MOVE-CORRESPONDING <TEMP_WA> TO WA_TOT.
WA_TOT-TOTAL_SCORE = WA_TOT-TOTAL_SCORE + VALUE.
MOVE-CORRESPONDING WA_TOT TO <TEMP_WA>.
MODIFY <TEMP_TAB> FROM <TEMP_WA> INDEX LS_MOD_CELL-ROW_ID.
CALL METHOD GO_GRID->REFRESH_TABLE_DISPLAY.
ELSE.
CLEAR WA_DATA.
ENDIF.
CLEAR:WA_TOT,VALUE.
ENDLOOP.
ENDFORM. -
How to get Grand Total Text in ALV GRID
Hi Folks,
I am able to get the SUBTOTAL TEXT .....But i need...
How to get Grand Total Text in ALV GRID Display...
Can any one give a Solution for this...Hi Surendar,
Check out this code.. this is showing Total Text in Toal line in the very first column.
REPORT zsales_ord_det_1 .
TABLES: ztable_10.
TYPE-POOLS: slis.
DATA: BEGIN OF it OCCURS 0,
srno(6) type c,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it.
DATA : BEGIN OF it_temp OCCURS 0,
name LIKE ztable_10-name,
age LIKE ztable_10-age,
END OF it_temp.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv.
DATA: v_repid LIKE sy-repid,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
gs_layout TYPE slis_layout_alv,
gd_layout TYPE slis_layout_alv,
i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
START-OF-SELECTION.
v_repid = sy-repid.
SELECT * FROM ztable_10 INTO TABLE it_temp.
LOOP AT it_temp .
it-srno = 'Total'.
it-name = it_temp-name.
it-age = it_temp-age.
APPEND it.
ENDLOOP.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'IT'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = v_repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fieldcat[]
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.
wa_fieldcat-row_pos = 1.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'SRNO'.
wa_fieldcat-tabname = it.
append wa_fieldcat to i_fieldcat.
LOOP AT i_fieldcat INTO wa_fieldcat.
IF wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-do_sum = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat.
ENDIF.
IF wa_fieldcat-fieldname = 'SRNO'.
Hide this field so that it can display it's content i.e.
Total text in Subtotal level
wa_fieldcat-tech = 'X'.
wa_fieldcat-no_out = 'X'.
MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
ENDIF.
ENDLOOP.
wa_sort-spos = 1.
wa_sort-fieldname = 'SRNO'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO i_sort.
gd_layout-no_totalline = 'X'.
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 = '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 = gd_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
it_sort = i_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
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it
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.
Regards,
Seema -
How to change sub total value in ALV Grid.
Hi All,
Can u please explain how to change SUBTOTAL Value in ALV Grid display based on another field value.
EX; F1 subtotal is initial then we have to modify the F2 sub total to 9999.9.
Thanks
Radha.Hi Radha,
I doubt if that can be changed....because the event that i was referring to in my previous post works with ALV List display...But in any case you can try that.....
There is an event in SLIS....(As i told you, i dont remember the name and currently i dont have access to SAP system, so i am not able to verify and let you know that event name).....
Other thatn TOP and END of PAGE events, there is an event for sub-total text......i think it would start with "SUBTOTAL"...
you need to use that event in your events table and pass it to ALV Grid display.
Then create a sub-routine with that name (As you do for TOP-OF-PAGE event)....and in this event you can change the values in runtime (PROVIDED, this event gets triggered for ALV GRID).....
If this does not work, i think calculating sub-totals while you build the internal table would be a better option....(If you have time constraint....else you can do some more research on the same)........
Best Regards,
Ram. -
Automatically update totals in an ALV-grid
Hi there,
Is there a possibility to automatically update a totals-field in an ALV-grid?
At the moment the totals-field is only updated when the ALV-grid is refreshed (PBO). I want an immediate update when the user enters a value in the ALV.
Who can help me?
AngeloHi,
Subramanian has taken his time and effort to help you. if you wish to reward his effort SDN has got a way for that. Since you are new to SDN may i introduce you to the points system at SDN.
You assign points to the replies that you have found to be useful. It's a way to say "thanks" for the effort in the replies.
See: /people/mark.finnern/blog/2004/08/10/spread-the-love for directions.
Click on the Yellow Star icon in each reply.
You can give:
1 - 10 pointer (marks it as a solved problem)
2 - 6 pointers (very helpful)
Lots of 2 pointers (helpful)
Raja -
Total and non-total lines in ALV grid
Hi all,
Does anyone know if there is any standard SAP functionality for retrieving the non-total/raw item lines that lies beneath a total line in an ALV grid (after the user has selected the total line)?
All helpful answers will be rewarded!
Best regards,
MVTry the ALV event AFTER-LINE-OUTPUT may be it can help u to achieve ur requirement.
Append AFTER-LINE-OUTPUT event to the internal table T_EVENT.
CLEAR W_EVENT.
W_EVENT-FORM = SLIS_EV_AFTER_LINE_OUTPUT.
W_EVENT-NAME = SLIS_EV_AFTER_LINE_OUTPUT.u201CAFTER_LINE_OUTPUT event
APPEND W_EVENT TO T_EVENT.
FORM AFTER_LINE_OUTPUT
USING P_RS_LINEINFO TYPE SLIS_LINEINFO.
Here you have to write the logic to retrieve the 'total' line
ENDFROM.
Now call the alv FM
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPID "Program Name
IS_LAYOUT = W_LAYOUT "Layout of the Report
IT_FIELDCAT = T_FIELDCAT "Field Catalog for Report
IT_EVENTS = T_EVENT "For setting the events
TABLES
T_OUTTAB = T_OUTPUT "Report data Internal Table
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2. -
Hi,
Can I use a total line in an ALV grid and hide part of the columns, so that only the total line will be presented for some of the columns ?Hi,
Yes u can use a total column in the ALV Grid.
Check the code below:
AT LAST.
WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
ENDAT.
Regards
Kannaiah -
Total label in ALV GRID.
Hi
I want to display a label in the first column of the totals Row in the ALV. I am using do_sum = 'X' in FieldCatalog. I tried using layout-Totals_text = 'Totals in Million'. but still it is not appearing. The Datatype is char(60) for first column. I am using FM 'REUSE_ALV_GRID_DISPLAY'. Any help.*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
<b> gd_layout-totals_text = 'Totals'(201).</b>
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
If u want the column text to be changed then use as below
fieldcatalog-fieldname = 'EBELN'.
<b> fieldcatalog-seltext_m = 'Purchase Order'.</b>
Hope this helps.
If u want to display a top-of-page then use the below link for reference.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_rephead.htm
Kindly reward poinst and close the thread if ur problem got solved or revert back. -
Percentage Total/Subtotal in ALV Grid
Dear All,
I have to display an ALV report with percentage feilds. Everything is fine but the problem arises when the standard ALV sum functionality is used. It simply adds up all the percentage columns. Making do_sum = 'C' wont help either as it would simple give an average of all the percentage. My requirement is to show them through calculation. I have searched the web and saw some solutions with SUBTOTAL_TEXT nad some with OOP programming but i am not able to get this. Can anybody please help.
<REMOVED BY MODERATOR>
Thanks
MV
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:24 PMhi manish,
try this program.
ALV Grid List with sub-totals
REPORT z_demo_alv_sort.
* This program lists orders (VBAK) with sort and sub-total for *
* 'sold-to-party' (KUNNR) and 'Sales organization' (VKORG) *
TABLES : vbak.
TYPE-POOLS: slis. " ALV Global types
SELECT-OPTIONS :
s_vkorg FOR vbak-vkorg, " Sales organization
s_kunnr FOR vbak-kunnr, " Sold-to party
s_vbeln FOR vbak-vbeln. " Sales document
SELECTION-SCREEN :
SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
DATA:
BEGIN OF gt_vbak OCCURS 0,
vkorg LIKE vbak-vkorg, " Sales organization
kunnr LIKE vbak-kunnr, " Sold-to party
vbeln LIKE vbak-vbeln, " Sales document
netwr LIKE vbak-netwr, " Net Value of the Sales Order
waerk LIKE vbak-waerk, " Document currency
END OF gt_vbak.
INITIALIZATION.
v_1 = 'Maximum of records to read'.
START-OF-SELECTION.
PERFORM f_read_data.
PERFORM f_display_data.
* Form f_read_data
FORM f_read_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
FROM vbak
UP TO p_max ROWS
WHERE kunnr IN s_kunnr
AND vbeln IN s_vbeln
AND vkorg IN s_vkorg.
ENDFORM. " F_READ_DATA
* Form f_display_data
FORM f_display_data.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'VBAK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'VKORG' '' ''.
m_fieldcat 'KUNNR' '' ''.
m_fieldcat 'VBELN' '' ''.
m_fieldcat 'NETWR' 'X' 'WAERK'.
m_fieldcat 'WAERK' '' ''.
m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal
m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal
m_sort 'VBELN' ''. " Sort by vbeln
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = gt_vbak.
ENDFORM. " F_DISPLAY_DATA
***************** END OF PROGRAM Z_DEMO_ALV_SORT **********************
thanks
karthik
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 4:50 PM -
Identify selection of sub-total line in ALV grid
Hi folks,
Is there a way to identify in the report if the user has selected any sub-total line in an ALV grid? Both for REUSE_ALV_GRID_DISPLAY and CL_GUI_ALV_GRID.
Thanks
SagarSagar,
1. I don't think its good design, if you want to process those three lines, you should ask the user to select those 3 rows and process them.
2. If you have no choice, tyr these methods, these might give you some info
GET_SORT_CRITERIA
GET_SUBTOTALS
These methods might give you the info you are looking for. Try it out.
regards,
Ravi -
Problem displaying 'Total' text in ALV grid
My ALV works and displays correct output. However, I am struggling to display the text 'Total' on position in the last row of the grid. The total is for the salary. My code is below..
I have looked on numerous sites and forums for assistance.
*& Report ZALV
REPORT ZALV.
TABLES: ZCONTACT.
TYPE-POOLS: slis. "slis contains all of the ALV data types.
DATA: "fieldcatALOG TYPE slis_t_fieldcat_alv WITH HEADER LINE,
it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
alv_prog_name LIKE sy-repid,
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_save TYPE c VALUE 'X',
it_fieldcat TYPE slis_t_fieldcat_alv,"declares field catalog table of line type alv
wa_fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
it_list_top_of_page TYPE slis_t_listheader,
izontact TYPE TABLE OF zcontact,
h1(10) TYPE c VALUE 'Toatall',
"i_logo TYPE OT.
gt_events TYPE slis_t_event,
gd_prntparams TYPE slis_print_alv,
text(40) type c,
wa_layout TYPE slis_layout_alv.
**Selection Screen details
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: variant like disvariant-variant.
SELECTION-SCREEN END OF BLOCK B1.
**Getting default variant
INITIALIZATION.
gx_variant-report = sy-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
I_SAVE = G_SAVE
CHANGING
CS_VARIANT = GX_VARIANT
EXCEPTIONS
NOT_FOUND = 2.
IF SY-SUBRC = 0.
VARIANT = GX_VARIANT-VARIANT.
ENDIF.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM DISPLAY_ALV_REPORT.
"PERFORM build_alv_header
FORM BUILD_FIELDCATALOG.
*Build field catalog
wa_fieldcat-fieldname = 'ID'.
wa_fieldcat-seltext_m = 'ID'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'LASTNAME'.
wa_fieldcat-seltext_m = 'LASTNAME'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'FIRSTNAME'.
wa_fieldcat-seltext_m = 'FIRSTNAME'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'DOB'.
wa_fieldcat-seltext_m = 'DOB'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'TEL'.
wa_fieldcat-seltext_m = 'Tel'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'ADDRESS'.
wa_fieldcat-seltext_m = 'ADDRESS'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'OCCUPATION'.
wa_fieldcat-seltext_m = 'OCCUPATION'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'WEIGHT'.
wa_fieldcat-seltext_m = 'WEIGHT'.
wa_fieldcat-do_sum = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AGE'.
wa_fieldcat-seltext_m = 'AGE'.
wa_fieldcat-do_sum = 'X'. "Display column total
APPEND wa_fieldcat TO it_fieldcat.
"CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'SALARY'.
wa_fieldcat-seltext_m = 'SALARY'.
wa_fieldcat-do_sum = 'X'.
wa_fieldcat-cfieldname = 'CURRENCYKEY'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'CURRENCY'.
wa_fieldcat-seltext_s = 'CURRENCY'.
APPEND wa_fieldcat TO it_fieldcat.
"CLEAR wa_fieldcat.
ENDFORM. "BUILDING THE FIELD CATALOG
**FORM layout.
*wa_layout-colwidth_optimize = 'X'.
*wa_layout-totals_text ='TOTAL'.
*wa_layout-zebra = 'X'.
*ENDFORM.
"ls_layout-cell_merge = 'X'.
FORM DISPLAY_ALV_REPORT.
alv_prog_name = sy-repid.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = it_fieldcat[]
i_callback_program = alv_prog_name
is_layout = wa_layout
i_callback_top_of_page = 'TOP_OF_PAGE'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ZCONTACT'
i_save = 'X'
it_events = gt_events
is_print = gd_prntparams
is_variant = g_variant
"is_layout = ls_layout
TABLES
t_outtab = it_zcontact
EXCEPTIONS
program_error = 1
OTHERS = 2.
WRITE: H1 UNDER 'SALARY'.
ENDFORM.
**Fetch data from the database
FORM DATA_RETRIEVAL.
SELECT * FROM zcontact INTO TABLE it_zcontact.
ENDFORM.
FORM top_of_page.
*ALV Header declarations
DATA: it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
t_line like wa_listheader-info,
ld_lines TYPE I,
ld_linesc(10) TYPE C.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Contact Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-repid.
wa_listheader-key = 'Program Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-uname.
wa_listheader-key = 'User Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Run Date :'.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
INTO wa_listheader-info
SEPARATED BY '/'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Time :'.
CONCATENATE sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2)
INTO wa_listheader-info
SEPARATED BY ':'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader[]
i_logo = 'KLOGO'.
ENDFORM. "top_of_pageI did this but still i cant display the total text..I have reposted my code. please assist. Im only missing that total label
*& Report ZALV
REPORT ZALV.
TABLES: ZCONTACT.
TYPE-POOLS: slis. "slis contains all of the ALV data types.
TYPES: BEGIN OF t_zcontact,
text(40) TYPE c, "storing the total text
mandt TYPE mandt,
id TYPE zcontactid,
lastname type zcontactlname,
firstname TYPE zcontactfname,
dob TYPE zdateofbirth,
tel TYPE ztel,
address TYPE zaddress,
occupation TYPE zoccup,
weight type zweight,
age TYPE zage,
salary TYPE zsalary,
ecurrency TYPE curcy,
END OF t_zcontact.
TYPES: BEGIN OF wa_zcontact,
mandt TYPE mandt,
id TYPE zcontactid,
lastname type zcontactlname,
firstname TYPE zcontactfname,
dob TYPE zdateofbirth,
tel TYPE ztel,
address TYPE zaddress,
occupation TYPE zoccup,
weight type zweight,
age TYPE zage,
salary TYPE zsalary,
ecurrency TYPE curcy,
END OF wa_zcontact.
TYPES:
i_zcontact TYPE STANDARD TABLE OF t_zcontact." INITIAL SIZE 0.
DATA: itt_zcontact TYPE STANDARD TABLE OF wa_zcontact INITIAL SIZE 0,
wat_zcontact TYPE wa_zcontact.
DATA: "it_zcontact TYPE TABLE OF zcontact,"declares an internal table of type ZCONTACT
gd_repid LIKE sy-repid,
g_variant TYPE disvariant,
gx_variant TYPE disvariant,
g_save TYPE c VALUE 'X',
fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,"declares field catalog table of line type alv
gd_tab_group type slis_t_sp_group_alv,
gd_prntparams TYPE slis_print_alv,
fieldcat TYPE slis_fieldcat_alv, "declares the work area of the field catalog
it_list_top_of_page TYPE slis_t_listheader,
i_zcontact TYPE TABLE OF zcontact,
"h1(10) TYPE c VALUE 'Toatall',
"i_logo TYPE OT.
gt_events TYPE slis_t_event,
gd_layout TYPE slis_layout_alv."work area for the alv layout
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort LIKE LINE OF it_sortcat.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM DISPLAY_ALV_REPORT.
PERFORM BUILD_LAYOUT.
perform build_sortcat.
PERFORM sub_add_text.
"PERFORM build_events.
PERFORM top-of-page.
"PERFORM build_alv_header.
END-OF-SELECTION.
*DATA: gd_layout TYPE slis_layout_alv.
* gd_layout-totals_text = 'TOTAL'.
**Selection Screen details
*SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
*PARAMETERS: variant like disvariant-variant.
*SELECTION-SCREEN END OF BLOCK B1.
***Getting default variant
*INITIALIZATION.
*gx_variant-report = sy-repid.
*CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
*EXPORTING
* I_SAVE = G_SAVE
* CHANGING
* CS_VARIANT = GX_VARIANT
* EXCEPTIONS
* NOT_FOUND = 2.
*IF SY-SUBRC = 0.
* VARIANT = GX_VARIANT-VARIANT.
* ENDIF.
FORM BUILD_FIELDCATALOG.
*Build field catalog
fieldcatalog-fieldname = 'ID'.
fieldcatalog-seltext_m = 'ID'.
fieldcatalog-col_pos = 2.
fieldcatalog-outputlen = 10.
fieldcatalog-datatype = 'CHAR'.
"fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'LASTNAME'.
fieldcatalog-seltext_m = 'LASTNAME'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'FIRSTNAME'.
fieldcatalog-seltext_m = 'FIRSTNAME'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'DOB'.
fieldcatalog-seltext_m = 'DOB'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TEL'.
fieldcatalog-seltext_m = 'Tel'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ADDRESS'.
fieldcatalog-seltext_m = 'ADDRESS'.
fieldcatalog-col_pos = 7.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'OCCUPATION'.
fieldcatalog-seltext_m = 'OCCUPATION'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'WEIGHT'.
fieldcatalog-seltext_m = 'WEIGHT'.
"fieldcatalog-do_sum = 'X'.
fieldcatalog-col_pos = 9.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AGE'.
fieldcatalog-seltext_m = 'AGE'.
"fieldcatalog-do_sum = 'X'. "Display column total
fieldcatalog-col_pos = 10.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'SALARY'.
fieldcatalog-seltext_m = 'SALARY'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype ='CURR'.
fieldcatalog-col_pos = 11.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
"fieldcatalog-fieldname = 'ECURRENCY'.
"fieldcatalog-seltext_s = 'ECURRENCY'.
"APPEND fieldcatalog TO fieldcatalog.
"CLEAR fieldcatalog.
fieldcatalog-fieldname = 'TEXT'.
fieldcatalog-col_pos = 0.
"fieldcatalog-seltext_m = 'TEXT'.
fieldcatalog-tech = 'X'.
fieldcatalog-no_out = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
ENDFORM.
*& Form build_sortcat
* Build Sort catalog
FORM build_sortcat .
"wa_sort-spos = 1.
wa_sort-fieldname = 'TEXT'.
"wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
wa_sort-up = 'X'.
APPEND wa_sort TO it_sortcat.
CLEAR wa_sort.
ENDFORM. " build_sortcat
FORM BUILD_LAYOUT.
*gd_layout-no_input = 'X'.
*gd_layout-colwidth_optimize = 'X'.
*gd_layout-totals_text = 'Totals'(201).
*"gd_LAYOUT-coltab_fieldname = 'SALARY'.
gd_layout-no_totalline = 'X'.
ENDFORM.
*IF sy-subrc = 0.
* LOOP AT fieldcatalog INTO fieldcat.
* IF fieldcat-fieldname = 'WEIGHT' OR
* fieldcat-fieldname = 'AGE'.
** Summation for WEIGHT & AGE
* fieldcat-do_sum = 'X'.
* MODIFY fieldcatalog FROM fieldcat TRANSPORTING do_sum.
* ENDIF.
* IF fieldcat-fieldname = 'TEXT'.
** Hide this field so that it can display it's content i.e.
** Total text in Subtotal level
* fieldcat-tech = 'X'.
* fieldcat-no_out = 'X'.
* MODIFY fieldcatalog FROM fieldcat TRANSPORTING tech no_out.
* ENDIF.
* CLEAR fieldcat.
* ENDLOOP.
* ENDIF.
*ENDFORM. "BUILDING THE FIELD CATALOG
*form build_events.
* data: ls_event type slis_alv_event.
* call function 'REUSE_ALV_EVENTS_GET'
* exporting
* i_list_type = 0
* importing
* et_events = gt_events[].
* read table gt_events with key name = slis_ev_top_of_page
* into ls_event.
* if sy-subrc = 0.
* move 'TOP-OF-PAGE' to ls_event-form.
* append ls_event to gt_events.
* endif.
* read table gt_events with key name = slis_ev_end_of_list
* into ls_event.
* if sy-subrc = 0.
* move 'END_OF_LIST' to ls_event-form.
* append ls_event to gt_events.
* endif.
*endform. " BUILD_EVENTS
"ls_layout-cell_merge = 'X'.
FORM DISPLAY_ALV_REPORT.
gd_repid = sy-repid.
*Pass data and field catalog to ALV function module to display ALV list
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_callback_program = gd_repid
is_layout = gd_layout
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'ZCONTACT'
i_save = 'X'
it_events = gt_events
is_print = gd_prntparams
is_variant = g_variant
"is_layout = ls_layout
TABLES
t_outtab = itt_zcontact
EXCEPTIONS
program_error = 1
OTHERS = 2.
"WRITE: 'TOTAL' UNDER 'ID'.
ENDFORM.
**Fetch data from the database
FORM DATA_RETRIEVAL.
"DATA: ld_subtot(1) type c.
SELECT * FROM zcontact INTO TABLE itt_zcontact UP TO 10 ROWS.
ENDFORM.
FORM sub_add_text.
*Populate field with text value
DATA:
wt_zcontact TYPE t_zcontact,
last TYPE zcontact-ID,
l_text(40) type c,
num type n.
loop at itt_zcontact into wat_zcontact.
* Populate final table
wt_zcontact-TEXT = 'Total salary: '.
"ld_subtot = ld_subtot + 1.
"wat_zcontact-text = ld_subtot.
modify itt_zcontact FROM wat_zcontact.
clear wat_zcontact.
"APPEND wat_zcontact TO itt_zcontact.
endloop.
ENDFORM.
FORM top-of-page.
*ALV Header declarations
DATA: it_listheader TYPE slis_t_listheader,
wa_listheader TYPE slis_listheader,
t_line like wa_listheader-info,
ld_lines TYPE I,
ld_linesc(10) TYPE C.
wa_listheader-typ = 'H'.
wa_listheader-info = 'Contact Details'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-repid.
wa_listheader-key = 'Program Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-info = sy-uname.
wa_listheader-key = 'User Name:'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Run Date :'.
CONCATENATE sy-datum+6(2)
sy-datum+4(2)
sy-datum(4)
INTO wa_listheader-info
SEPARATED BY '/'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
wa_listheader-typ = 'S'.
wa_listheader-key = 'Time :'.
CONCATENATE sy-uzeit(2)
sy-uzeit+2(2)
sy-uzeit+4(2)
INTO wa_listheader-info
SEPARATED BY ':'.
APPEND wa_listheader TO it_listheader.
CLEAR wa_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_listheader[]
i_logo = 'KLOGO'.
ENDFORM. "top_of_page -
Fields are getting displayed two times in alv grid
Hi experts,
I have developed an interactive alv.
in basic list i have given two push buttons.
if first button is selected it should display one list and second button is selected another list.
I am displaying all the three lists using the FM 'REUSE_ALV_GRID_DISPLAY'.
my problem is if select any of the button it is displying the data correctly,
but if I come back to the basic list and click on the same button it is displaying each field two times(in two columns).
and if click the same button third time it is displaying the fields three times(3 columns).
can anybody tell me how to avoid this.
Thanks,
SudheerHI,
It seems like REFRESH of internal tables is missing. Please check and correct.
Thanks,
Vinod. -
How to display sub total text in ALV grid display reporting
Hi,
I want to display a text 'SUB TOTAL' in Sub total row of an ALV report.
Presently I am getting the name of the field used in sorting to get sub totals. But I required to display own text. Could you please give me solution.
Thanks
Giridhar KarnamFor doing this u need to simply modify the layout properties, please award points if found helpful
DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.
L_LAYOUT-SUBTOTALS_TEXT = 'GEN SUBTOT'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2. -
Can we display only sub totals on the alv grid output
hi,
can we display only the subtotals calculated on the grid display.it should display all the data it shpuld display only the subtotals of it.
if yes can any one please give me the code for
will be awarded with points.Hi Raju
You can do that
When you are doing fieldcatalog,comment ws_fieldcat-do_sum = 'x'.
if you comment that it wont display totals.
use sort
i_sort type slis_alv...
clear ws_sort.
ws_sort1-spos = '1'<position of field>
ws_sort-fieldname = 'matnr'.
ws_sort-up = 'x'.
append ws_sort to i_sort.
pass this i_sort to FM -
Activation of sub-totals button in ALV grid
hi experts
Execute the module pool program BCALV_GRID_DEMO .in the o/p screen - how to activate the subtotals button explicitly.HI,
Please refer the code below:
* ALV data declarations
data: it_sortcat type slis_sortinfo_alv occurs 1,
wa_sort like line of it_sortcat.
perform build_sortcat.
*& Form build_sortcat
* Build Sort catalog
FORM build_sortcat .
wa_sort-spos = 1.
wa_sort-fieldname = 'EBELN'.
wa_sort-SUBTOT = 'X'. "subtotals any totals column by this field
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
wa_sort-spos = 2.
wa_sort-fieldname = 'EBELP'.
* gd_sortcat-tabname
APPEND wa_sort TO it_sortcat.
ENDFORM. " build_sortcat
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_sort = it_sortcat
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
Thanks,
Sriram Ponna.
Maybe you are looking for
-
I am trying to install windows on my mac. what is an iso image and how do i get it.
I have windows 8 on a cd. and I am trying to install it using bootcamp. I have no idea of what, where I find an iso image ??
-
FEBAN - FB05 - error F5243 for vendor payment
Hello, I kindly ask for a hint. The vendor payment is included in eleclonical bank file. From transaction FEBAN (Edit bank statement) for item which is not fully cleared we get to trans. FB05 (post with clearing) and try to post to account type K (ve
-
Cant find my installed programs
any program i install, dissapears as soon as i shut down my system. how can i stop this? i dont have a single program right now. pls i need urgent help. tnks
-
Video playback causes itunes to crash
Since version 8 I have been unable to watch purchased videos without iTunes crashing. The only thing that gets around this is completely installing iTunes again, I was wondering if anyone knows of a more permanant fix?
-
Hi I cant make slippy-xd downloaded from the AUR, it looks like I dont have permission to make it work. The windows dont scale here is the output : $ skippy-xd --start-daemon WARNING: Couldn't load config file '/home/maxime/.skippy-xd.rc'. --> checki