Adding/Enabling Totals & Subtotals Button in ALV Report Output
Hi Guys,
I would like to know , how to add / enable Totals & Subtotals Button on the application tool bar in alv report output.
Regards,
Kishan
ok so here i am sending my code....its also interactive...
and in second list i am displaying quantity....
*& Report ZINT_ALV
REPORT zint_alv.
TYPE-POOLS:slis.
TABLES:mara,
makt,
mseg.
DATA:BEGIN OF itab OCCURS 0,
matnr LIKE mara-matnr,
maktx LIKE makt-maktx,
END OF itab.
DATA:BEGIN OF itab1 OCCURS 0,
mblnr LIKE mseg-mblnr,
menge LIKE mseg-menge,
meins LIKE mseg-meins,
werks LIKE mseg-werks,
END OF itab1.
DATA:fcat TYPE slis_t_fieldcat_alv,
fcat1 TYPE slis_t_fieldcat_alv,
eve TYPE slis_t_event,
eve1 TYPE slis_t_event.
DATA:t_mat LIKE mara-matnr,
s_mat LIKE mara-matnr,
g_repid LIKE sy-repid.
SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.
SELECTION-SCREEN:END OF BLOCK blk1.
INITIALIZATION.
PERFORM build_fcat USING fcat.
PERFORM build_eve.
START-OF-SELECTION.
PERFORM get_data.
PERFORM dis_data.
*& Form build_fcat
text
-->T_FCAT text
FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
DATA:wa_fcat TYPE slis_fieldcat_alv.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-ref_fieldname = 'MATNR'.
wa_fcat-ref_tabname = 'MARA'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-input = ' '.
wa_fcat-edit = 'X'.
wa_fcat-input = 'X'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
wa_fcat-tabname = 'ITAB'.
wa_fcat-fieldname = 'MAKTX'.
wa_fcat-seltext_m = 'Description'.
APPEND wa_fcat TO t_fcat.
CLEAR wa_fcat.
ENDFORM. "build_fcat
*& Form build_eve
text
FORM build_eve.
DATA:t_eve TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = eve
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.
ENDFORM. "build_eve
*& Form get_data
text
FORM get_data.
SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
FROM mara INNER JOIN makt
ON maramatnr = maktmatnr
WHERE mara~matnr IN mat.
ENDFORM. "get_data
*& Form dis_data
text
FORM dis_data.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid "'ZINT_ALV'
i_callback_user_command = 'USER_COMMAND'
i_grid_title = 'Interactive ALV'
it_fieldcat = fcat
it_events = eve
TABLES
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "dis_data
*& Form user_command
text
-->U_COM text
FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
CLEAR fcat1.
CASE u_com.
WHEN '&IC1'.
READ TABLE itab INDEX sel_field-tabindex.
IF sel_field-fieldname = 'MATNR'.
IF sy-subrc = 0.
t_mat = itab-matnr.
PERFORM build_cat1 USING fcat1.
PERFORM build_eve1.
PERFORM get_data1.
PERFORM dis_data1.
ENDIF.
ENDIF.
SET PARAMETER ID 'MAT' FIELD t_mat.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDCASE.
ENDFORM. "user_command
*& Form build_fcat1
text
-->T_FCAT1 text
FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
DATA:wa_fcat1 TYPE slis_fieldcat_alv.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MBLNR'.
wa_fcat1-seltext_m = 'Material Doc.'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MENGE'.
wa_fcat1-seltext_m = 'Quantity'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'MEINS'.
wa_fcat1-seltext_m = 'UOM'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
wa_fcat1-tabname = 'ITAB1'.
wa_fcat1-fieldname = 'WERKS'.
wa_fcat1-seltext_m = 'Plant'.
APPEND wa_fcat1 TO t_fcat1.
CLEAR wa_fcat1.
ENDFORM. "build_fcat1
*& Form build_eve1
text
FORM build_eve1.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = eve1
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.
ENDFORM. "build_eve1
*& Form get_data1
text
FORM get_data1.
SELECT mblnr menge meins werks FROM mseg
INTO CORRESPONDING FIELDS OF TABLE itab1
WHERE matnr = t_mat.
ENDFORM. "get_data1
*& Form dis_data1
text
FORM dis_data1.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid "'ZINT_ALV'
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = fcat1
it_events = eve1
TABLES
t_outtab = itab1
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. "dis_data1
Similar Messages
-
How to give push button in alv report output
hi,
my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
regards,
siva kumarhave a look at this thread, also has a sample report at the end from Uwe Schieferstein.
[button on alv list|How to add and program a pushbutton on ALV grid line;
seems not to work try this:
How to add and program a pushbutton on ALV grid line
Edited by: Micky Oestreich on May 15, 2008 10:20 PM -
Add buttons in ALV Report output
Dear Friends,
I am developing one ALV report in PP moule for calculating Shelf Life. The output is coming properly in ALV.
But my additional requirement is ADD coustomise buttons in ALV Reports.
Please give me an idea how can I insert buttons in my alv report?
Thanks & Regards
VasuHi vasu,
consider the code given below.
FORM F4200_PF_STATUS_SET *
FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
REFRESH i_extab.
PERFORM f4210_exclude_fcodes CHANGING i_extab.
The PF status is an exact copy of the PF status 'STANDARD' of program
SAPLSALV but with command 'CHNG' added to it.
SET PF-STATUS 'ZSOM_STANDARD' EXCLUDING i_extab.
ENDFORM.
*& Form f4210_exclude_fcodes
FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
DATA: ws_fcode TYPE slis_extab.
CLEAR ws_fcode.
ws_fcode = '&EB9'. " Call up Report.
APPEND ws_fcode TO i_extab.
ws_fcode = '&ABC'. " ABC Analysis.
APPEND ws_fcode TO i_extab.
ws_fcode = '&NFO'. " Info Select.
APPEND ws_fcode TO i_extab.
ws_fcode = '&LFO'. " Information.
APPEND ws_fcode TO i_extab.
ENDFORM. " f4210_exclude_fcodes
*& Form f4300_user_command
FORM f4300_user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'. "Double Click line Item
READ TABLE i_data INDEX selfield-tabindex.
IF i_data-qmnum NE space.
SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
CLEAR ucomm.
ENDIF.
WHEN 'CHNG'. " Change Notification Icon
READ TABLE i_data INDEX selfield-tabindex.
IF i_data-qmnum NE space.
SET PARAMETER ID 'IQM' FIELD i_data-qmnum.
CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.
CLEAR ucomm.
ENDIF.
ENDCASE.
CLEAR ucomm.
ENDFORM. " f4300_user_command
EXPLANATION
In this program, first we created a PF status (ZSOM_STANDARD), which was an exact copy of STANDARD of program SAPLSALV through transaction SE41 (Menu Painter). Then we added another button to it,with a new fcode called CHNG. After this this we set this PF status instead of STANADRD.
We initialize a third event USER_COMMAND and associate a form with it. In this form we can capture the function codes and write any functionality under it. If we write functionality for an existing fcode, then this gets precedence over the default functionality that might be associated with it.
In this example, we capture a standard fcode &IC1 that is nothing but double clicking a line of the report. We are capturing the notification number of that line and calling transaction IW52 with it. We are also doing the same when a user clicks on the new Change Notification button.
When the user clicks the Back button in IW52, it comes back to the report.
Please reward for the same.
Message was edited by: Prakhar Saxena -
Adding color to few rows in ALV report output
Hi,
I have developed a ALV report program which displays the project details of the employees.In the output the rows containing the employees who have been part of the project should be displayed in different color.I have used necessary code for this but still the rows are not displayed in different color.
Given below is my program.Please suggest me possible solution for this.
REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.{ REPORT ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
end of ty_zheempl.
types: begin of ty_zhealoc,
project like zhealoc-project,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
role like zhealoc-role,
end of ty_zhealoc.
types: begin of ty_output,
empid like zheempl-empid,
grade like zheempl-grade,
location like zheempl-location,
pu like zheempl-pu,
name1 like zheempl-name1,
role like zhealoc-role,
stdat like zhealoc-stdat,
endat like zhealoc-endat,
cellcolor(4) type c,
end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
t_zhealoc type standard table of ty_zhealoc,
t_output type standard table of ty_output with header line,
t_output1 type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
wa_zhealoc type ty_zhealoc,
wa_output type ty_output,
wa_output1 type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
s_empid for wa_zheempl-empid.
parameters: p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters: p_prtosr radiobutton group g1 default 'X',
p_prusly radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters: p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters: p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
IF p_shwhis = 'X'.
SELECT l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
where project IN s_proj
AND endat < p_date
OR endat > p_date.
t_output-cellcolor = 'C310'.
MODIFY t_output transporting cellcolor where endat < p_date.
ELSE.
select l~empid
l~grade
l~location
l~pu
l~name1
c~role
c~stdat
c~endat
INTO TABLE t_output
FROM ( zheempl AS l
INNER JOIN zhealoc
AS c ON lempid = cempid )
WHERE project in s_proj
AND endat > p_date.
ENDIF.
wa_fieldcat-col_pos = '1'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'EMPID'.
wa_fieldcat-seltext_m = 'Employee ID'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'NAME1'.
wa_fieldcat-seltext_m = 'Name 1'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ROLE'.
wa_fieldcat-seltext_m = 'Role of employee in the project'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'STDAT'.
wa_fieldcat-seltext_m = 'Start Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '5'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'ENDAT'.
wa_fieldcat-seltext_m = 'End Date'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '6'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'GRADE'.
wa_fieldcat-seltext_m = 'Salary Level'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '7'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'PU'.
wa_fieldcat-seltext_m = 'Department Number'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '8'.
wa_fieldcat-tabname = 't_output'.
wa_fieldcat-fieldname = 'LOCATION'.
wa_fieldcat-seltext_m = 'Work Location'.
wa_fieldcat-hotspot = 'X'.
APPEND wa_fieldcat to t_fieldcat.
CLEAR wa_fieldcat.
t_layout-no_input = 'X'.
t_layout-colwidth_optimize = 'x'.
t_layout-info_fieldname = 'LINE_COLOR'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
i_callback_top_of_page = 'TOP'
is_layout = t_layout
IT_FIELDCAT = T_FIELDCAT
i_save = 'X'
TABLES
t_outtab = T_OUTPUT
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Form top.
Refresh it_top.
wa_top-typ = 'S'.
wa_top-key = 'Requestor'.
wa_top-info = sy-uname.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Program'.
wa_top-info = sy-repid.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Page'.
wa_top-info = sy-pagno.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'S'.
wa_top-key = 'Date'.
wa_top-info = sy-datum.
APPEND wa_top to it_top.
CLEAR wa_top.
wa_top-typ = 'H'.
wa_top-info = 'Project Details'.
APPEND wa_top to it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top.
ENDFORM.} -
Reg: passing totals /subtotals of a ALV to a smartform
I have a editable ALV report which has a button to call a smartform . Once the user edits some fields I need to pass the refreshed total to the smartform. I want to know - in what structure the totals/subtotals of the ALV report are stored.
Banu,
Even if you figure out how to get the subtotals / totals from a ALV, I would still suggest you to use the features of SMART Forms to calculate the same again in the form.
http://help.sap.com/saphelp_nw04/helpdata/en/55/610e2db57911d4b62c006094192fe3/content.htm
So, that way if your form is triggered even without doing the subtotalling done by the user you are on the safer side as the form will still display what you have designed it for.
Regards,
Ravi
Note :Please mark all the helpful answers -
How to do the ALV report output in groups and caluculate the tOTALS(URGENT
Hi
In my ALV report output .I have to group the output based on the DAYS field
0-10 days in one group
10-30 days in one group
above 30 days one group
There is also a field by name "AMOUNT" in my output.
I have to calculate SUBTOTALs at the end of every group and at the end of the report i should caluculate GRAND TOTAL.
Please remember that i should not use any any BLOCKED ALVs and for Totals i should not use the SYMBOLS provided in the application toolbar of the report
Thanks in AdvancePlease don't repost your questions...
Check out my answer in your other post.
How to make the ALV report in groups and caluculate the TOTALS
Regards,
Naimesh Patel -
Information button in ALV report
Information button in ALV report is not working. any suggestion
I have copied standard tool bar from standard program.During debugging, I have found that function code is defferent. Then I changed function code according to that.
-
Control User Specific button in ALV report
Hi,
Can anybody please suggest me how to control "USER SPECIFIC" button in ALV report layout using authorization object. I mean if you can tell me which authorization object is responsible to control the "USER SPECIFIC" button.additional info to what Lakshmi already said:-
normally the restrictions for saving layouts/display variants are done at 2 levels:
1) The developer of an ALV list first predetermines the authorization in the 'i_save' parameter within the code.
I_SAVE = ' ' -
layouts cannot be saved
I_SAVE = 'A' -
user-specific and cross-user layouts can be saved
I_SAVE = 'X' --- cross-user layouts can be saved
I_SAVE = 'U' --- user-specific layouts can be saved
2) The second level comes to us restriciting the S_ALV_LAYO which gives access to users to save global layouts if I_SAVE for that particular transaction is A or X.
for example, a report has I_SAVE= 'A', which means
it will allow to save User-specific layouts without any restrictions.
and if user has S_ALV_LAYO then he can save both User-Specific and Global Layouts(variants).
it would be better to keep this object separate. -
Hi All,
I want to know how to create a button in alv report .
Please respond to my query.
Thanks and Regards,
Amanhi aman,
u can try this example:
where i have a created a button:
*& Report Z_GURU_ALV_EVENT01 *
report z_guru_alv_event01 .
tables: mara, makt.
type-pools slis.
data: begin of imara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
ersda like mara-ersda,
end of imara.
data: begin of imakt occurs 0,
matnr like mara-matnr,
spras like makt-spras,
maktx like makt-maktx,
end of imakt.
data: ffc type slis_t_fieldcat_alv,
ievents type slis_t_event with header line,
iievent type slis_t_event with header line.
select-options: s_matnr for mara-matnr.
initialization.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = ievents[]
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.
read table ievents with key name = slis_ev_top_of_page.
ievents-form = 'TOPP'.
modify ievents transporting form where name = slis_ev_top_of_page.
clear ievents.
read table ievents with key name = slis_ev_user_command.
ievents-form = 'USR_COM'.
modify ievents transporting form where name = slis_ev_user_command.
clear ievents.
read table ievents with key name = slis_ev_pf_status_set.
ievents-form = 'PFSTAT'.
modify ievents transporting form where name = slis_ev_pf_status_set.
clear ievents.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = iievent[]
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.
read table iievent with key name = slis_ev_pf_status_set.
iievent-form = 'PFSTAT'.
modify iievent transporting form where name = slis_ev_pf_status_set.
clear iievent.
read table iievent with key name = slis_ev_user_command.
iievent-form = 'USERCOM'.
modify iievent transporting form where name = slis_ev_user_command.
clear iievent.
start-of-selection.
select matnr ernam ersda from mara into table imara where matnr
in s_matnr.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMARA'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ffc
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
i_callback_top_of_page = 'ALV_BACKGROUND'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
i_callback_html_end_of_list = 'ALV_BACKGROUND'
I_STRUCTURE_NAME =
i_background_id = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = ffc
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = ievents[]
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 = imara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
form topp.
data: it_top type slis_t_listheader,"having s , h ,a
wa type slis_listheader.
IT_SPEC TYPE SLIS_T_SPECIALCOL_ALV,
WA1 TYPE SLIS_SPECIALCOL_ALV.
wa-typ = 'H'.
wa-info = 'RELIANCE GLOBAL SERVICES' .
append wa to it_top.
clear wa.
wa-typ = 'S'.wa-key = 'NO:23'.
wa-info = 'TRIPLICANE HIGH ROAD'.
append wa to it_top.
clear wa.
wa-typ = 'S'.
wa-info = 'TRIPLICANE'.
append wa to it_top.
clear wa.
wa-typ = 'A'.
wa-info = 'sample'.
append wa to it_top.
clear wa.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_top
i_logo = 'ENJOYSAP_LOGO'
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform.
form usr_com using r_ucomm type sy-ucomm r_selfield type slis_selfield.
case r_ucomm.
when 'CANC'.
leave to screen 0.
endcase.
data: ff type slis_t_fieldcat_alv.
data: v_vbeln(18) type n.
v_vbeln = r_selfield-value.
select matnr spras maktx
from makt into table imakt
up to 10 rows
where matnr = v_vbeln.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMAKT'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ff
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = ff
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = iievent[]
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
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab = imakt
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. "USR_COM
form pfstat using extab type slis_t_extab.
set pf-status 'STD' excluding extab.
endform. " pfstat
form usercom using rucom type sy-ucomm rselfield type slis_selfield.
case rucom.
when 'CANC'.
leave to screen 0.
endcase.
data: ffc type slis_t_fieldcat_alv,
v_matnr(18) type n.
v_matnr = rselfield-value.
select matnr ernam ersda from mara into table imara
where matnr = v_matnr.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_internal_tabname = 'IMARA'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = sy-repid
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = ffc
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.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = ffc
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
it_events = iievent[]
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 = imara
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. -
How can we place a push button in ALV report
hi
could anybody inform me
how can we place a push button in ALV report
thanx
regards
kals.Hi kals.
please have a look at demoprogram
SALV_DEMO_TABLE_FUNCTIONS
BCALV_GRID_05
Regards
Bernd -
How to create user defined button in alv report
how to create user defined button in alv report
thnks in advance.Hi,
U can define it the the PF-STATUS ( Menu for ALV ).
For that u have to define it in the EVENTCAT.
form z_eventcat using p_i_eventcat type slis_t_event.
data: i_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_i_eventcat
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.
clear i_event.
read table p_i_eventcat with key name = slis_ev_top_of_page into
i_event.
if sy-subrc = 0.
move 'TOP_OF_PAGE' to i_event-form.
append i_event to p_i_eventcat.
endif.
read table p_i_eventcat with key name = slis_ev_pf_status_set into i_event.
if sy-subrc = 0.
move 'SET_PF_STATUS' to i_event-form.
append i_event to p_i_eventcat.
endif.
clear i_event.
read table p_i_eventcat into i_event with key name = slis_ev_user_command .
if sy-subrc = 0.
move 'USER_COMMAND' to i_event-form.
append i_event to p_i_eventcat.
endif.
And in the DISPLAY
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_progname
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = v_gridtitle
i_save = 'A'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
it_sort = i_sortinfo
it_events = i_eventcat
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.
*MENU SETTINGS.
form set_pf_status using rt_extab type slis_t_extab.
set pf-status 'ALV_MENU'.
endform. "SET_PF_STATUS
endform. " Z_EVENTCAT
Now double click on ALV MENU nad u can create a button in the application bar.
Regards,
Pritha. -
Hi experts,
I am using radio buttons in alv report by using screen painter but error occurs in alv that screen doesn't exist in module.
plz help me.Hi Ankita,
check this program.
*& Report ZALVGRID_WITH_RADIOBUTTONS
*& This program shows how to realize radiobuttons in ALV grid lists
*& using event HOTSPOT_CLICK.
*& Screen 100:
*& - Flow logic
*& PROCESS BEFORE OUTPUT.
*& MODULE PBO.
*& PROCESS AFTER INPUT.
*& MODULE PAI.
*& - Screen elements: none
*& - ok-code field -> gd_okcode
*& GUI Status MAIN100:
*& - F3 = 'BACK', Shift+F3 = 'EXIT', F12 = 'CANC'
PROGRAM zalvgrid_with_radiobuttons.
TYPE-POOLS: abap, icon. " INCLUDE . for releases < 6.20
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1 TYPE iconname.
TYPES: button2 TYPE iconname.
TYPES: button3 TYPE iconname.
TYPES: button4 TYPE iconname.
TYPES: END OF ty_s_sflight.
DATA:
gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
gs_layout TYPE lvc_s_layo,
gt_fcat TYPE lvc_t_fcat.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_grid TYPE REF TO cl_gui_alv_grid.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
define local data
FIELD-SYMBOLS:
IS ASSIGNED ).
Set all radio buttons "unselected"
IS ASSIGNED ).
Set selected radio button "selected".
= icon_wd_radio_button.
ENDIF.
Force PAI followed by refresh of table display in PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'REFRESH'
IMPORTING
RC =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
MAIN *
START-OF-SELECTION.
PERFORM select_data.
PERFORM init_controls.
PERFORM build_fieldcatalog.
PERFORM set_layout.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_sflight.
Link docking container to dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
lifetime_dynpro_dynpro_link = 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.
CALL SCREEN 100.
END-OF-SELECTION.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
SET TITLEBAR 'MAIN100'.
ENDMODULE. "PBO OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
Leave report
CASE gd_okcode.
WHEN 'BACK' OR
'EXIT' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
Refresh table display
WHEN 'REFRESH'.
PERFORM refresh_display.
WHEN OTHERS.
do nothing
ENDCASE.
CLEAR gd_okcode.
ENDMODULE. "PAI INPUT
*& Form BUILD_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM build_fieldcatalog .
ALV List with Radio Buttons
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 7
define local data
DATA:
ls_fcat TYPE lvc_s_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'ICON'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
DELETE gt_fcat WHERE ( fieldname <> 'NAME' ).
NOTE: field ICON-NAME has data element ICONNAME.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'NAME'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ls_fcat-fieldname = 'BUTTON4'.
ls_fcat-coltext = ls_fcat-fieldname.
ls_fcat-icon = 'X'.
ls_fcat-hotspot = 'X'.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON3'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON2'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
ls_fcat-fieldname = 'BUTTON1'.
ls_fcat-coltext = ls_fcat-fieldname.
INSERT ls_fcat INTO gt_fcat INDEX 5.
Renumbering of the columns
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SELECT_DATA
text
--> p1 text
<-- p2 text
FORM select_data .
define local data
DATA:
ls_sflight TYPE ty_s_sflight.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
ls_sflight-button1 = icon_wd_radio_button. " selected radiobutton
ls_sflight-button2 = icon_wd_radio_button_empty.
ls_sflight-button3 = icon_wd_radio_button_empty.
ls_sflight-button4 = icon_wd_radio_button_empty.
Alternatively: create icons using function module 'ICON_CREATE'
on SAP releases where these icons are not available.
MODIFY gt_sflight FROM ls_sflight
TRANSPORTING button1 button2 button3 button4
WHERE ( carrid IS NOT INITIAL ).
ENDFORM. " SELECT_DATA
*& Form INIT_CONTROLS
text
--> p1 text
<-- p2 text
FORM init_controls .
CHECK ( go_docking IS NOT BOUND ).
ALV List with Radio Buttons
SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com
© 2007 SAP AG 9
Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
REPID =
DYNNR =
SIDE = DOCK_AT_LEFT
EXTENSION = 50
STYLE =
LIFETIME = lifetime_default
CAPTION =
METRIC = 0
ratio = 90
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Size of container = full screen size
CALL METHOD go_docking->set_extension
EXPORTING
extension = 99999
EXCEPTIONS
cntl_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.
Create ALV grid instance
CREATE OBJECT go_grid
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = go_docking
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Set event handler for event HOTSPOT_CLICK
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR go_grid.
ENDFORM. " INIT_CONTROLS
*& Form REFRESH_DISPLAY
Refresh table display after switching the radiobuttons
--> p1 text
<-- p2 text
FORM refresh_display .
define local data
DATA:
ls_stable TYPE lvc_s_stbl.
ls_stable-row = abap_true.
ls_stable-col = abap_true.
CALL METHOD go_grid->refresh_table_display
EXPORTING
is_stable = ls_stable
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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. " REFRESH_DISPLAY
*& Form SET_LAYOUT
Set layout for ALV list
--> p1 text
<-- p2 text
FORM set_layout .
CLEAR: gs_layout.
gs_layout-cwidth_opt = abap_true. " optimize column width
gs_layout-zebra = abap_true.
ENDFORM. " SET_LAYOUT
Regards,
Prasanth
Reward if helpful -
How to create a radio button in ALV Reports
Hi all,
Best wishes to all..
Kindly reply me to this question... that is "How to create a radio button in ALV Report"
Thanks and Regards
AnjaliHI
here is an example :
PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
Based on: BCALV_GRID_DEMO.
TYPE-POOLS: icon.
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1 TYPE lvc_emphsz.
TYPES: button2 TYPE lvc_emphsz.
TYPES: button3 TYPE lvc_emphsz.
TYPES: button4 TYPE lvc_emphsz.
TYPES: END OF ty_s_sflight.
DATA:
gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
gt_fcat TYPE lvc_t_fcat.
DATA: ok_code LIKE sy-ucomm,
gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_cnt TYPE i.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
define local data
FIELD-SYMBOLS:
<ls_entry> TYPE ty_s_sflight,
<ld_fld> TYPE ANY.
READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
CHECK ( <ls_entry> IS ASSIGNED ).
Set all radio buttons "unselected"
<ls_entry>-button1 = icon_wd_radio_button_empty.
<ls_entry>-button2 = icon_wd_radio_button_empty.
<ls_entry>-button3 = icon_wd_radio_button_empty.
<ls_entry>-button4 = icon_wd_radio_button_empty.
ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
TO <ld_fld>.
IF ( <ld_fld> IS ASSIGNED ).
Set selected radio button "selected".
<ld_fld> = icon_wd_radio_button.
ENDIF.
Force PAI followed by refresh of table display in PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DUMMY'
IMPORTING
RC =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
MAIN *
PERFORM select_data.
CALL SCREEN 100.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
PERFORM build_fieldcatalog.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_sflight.
Set event handler for event TOOLBAR
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR grid1.
else.
CALL METHOD grid1->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
ENDIF.
ENDMODULE. "PBO OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
FORM EXIT_PROGRAM *
FORM exit_program.
CALL METHOD G_CUSTOM_CONTAINER->FREE.
CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*& Form BUILD_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM build_fieldcatalog .
define local data
DATA:
ls_fcat TYPE lvc_s_fcat,
ls_hype TYPE lvc_s_hype.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'LVC_S_FCAT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_BUFFER_ACTIVE =
i_structure_name = 'SFLIGHT'
I_CLIENT_NEVER_DISPLAY = 'X'
I_BYPASSING_BUFFER =
I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
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.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'EMPHASIZE'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ls_fcat-fieldname = 'BUTTON4'.
ls_fcat-icon = 'X'.
ls_fcat-hotspot = 'X'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON3'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON2'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON1'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SELECT_DATA
text
--> p1 text
<-- p2 text
FORM select_data .
define local data
DATA:
ls_sflight TYPE ty_s_sflight.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
ls_sflight-button1 = icon_wd_radio_button.
ls_sflight-button2 = icon_wd_radio_button_empty.
ls_sflight-button3 = icon_wd_radio_button_empty.
ls_sflight-button4 = icon_wd_radio_button_empty.
MODIFY gt_sflight FROM ls_sflight
TRANSPORTING button1 button2 button3 button4
WHERE ( carrid IS NOT INITIAL ).
ENDFORM. " SELECT_DATA
Regards,
Prasanth
Reward all helpful answers -
To activate total & subtotal button in ALV by class
Hi,
Kindly suggest how to activate total & subtotal button in ALV by class. I have used layout configuration by lvc_s_layo.
gs_layout type lvc_s_layo.
Ashutosh KumarDears,
Do_SUM is not available in gs_layout type lvc_s_layo.
Its working only in function module REUSE_ALV_LIST_DISPLAY.
How to use in class ALV.
FORM SUB_CREATE_FIELDCATALOG .
THIS BELOW FIELD IS EDITABLE
PERFORM APPEND_FIELDCAT USING:'MATNR'
'Material No.'
'CHAR'
'30'
PERFORM APPEND_FIELDCAT USING:'MATKL'
'DOCUMENT TYPE'
'CHAR'
'10'
PERFORM APPEND_FIELDCAT USING:''
'CHAR'
'4'
'C610'
PERFORM APPEND_FIELDCAT USING:'NTGEW'
'NET WT'
'P'
'10'
'C610'
'X'.
PERFORM APPEND_FIELDCAT USING:'VOLTO'
'VOLUME'
'P'
'10'
'C610'
'X'.
PERFORM APPEND_FIELDCAT USING:'VPREH'
'COST'
'P'
'10'
'C610'
ENDFORM. " SUB_CREATE_FIELDCATALOG
*& FORM APPEND_FIELDCAT
TEXT
-->P_0116 TEXT
-->P_0117 TEXT
-->P_0118 TEXT
-->P_0119 TEXT
-->P_0120 TEXT
-->P_10 TEXT
FORM APPEND_FIELDCAT USING P_114
P_115
P_116
P_117
P_118
P_119.
CLEAR GT_FIELDCAT_LVC.
GT_FIELDCAT_LVC-FIELDNAME = P_114.
GT_FIELDCAT_LVC-COLTEXT = P_115.
GT_FIELDCAT_LVC-DATATYPE = P_116.
GT_FIELDCAT_LVC-OUTPUTLEN = P_117.
GT_FIELDCAT_LVC-EMPHASIZE = P_118.
GT_FIELDCAT_LVC-do_sum = P_119.
append gt_fieldcat_lvc. -
Double Click on ALV Report Output, Bringing to selections creen
Hello Gurus,
Please help me When i do double click on ALV Report output , it is going back to Selection screen, actually its working as Back button. Now how to stop it.. I did debugging but i cannot trace it.PERFORM SUB_CREATE_FCAT.
DATA W_REPID LIKE SY-REPID.
W_REPID = SY-REPID.
ls_layout-colwidth_optimize = 'X'.
ls_layout-zebra = 'X'.
PERFORM SUB_SORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'C_USERCOMMAND '
* 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 = ls_layout
IT_FIELDCAT = IT_FIELDCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
I_SAVE = 'U'
* 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
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = T_FINAL
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Maybe you are looking for
-
Best way to log/notify when someone logs into ASDM
What is the best practice to get a notification and log when s omeone logs in and uses the ASDM? I have syslog server setup and smtp, and snmp traps, but not sure where to tell it to notify me when someone logs into the asdm..... any suggestions? th
-
PPro and AE not installing in CS5 Master Collection
Following the many excellent suggestions made on this thread: http://forums.adobe.com/thread/628980?tstart=0 I was able to finally installl the CS5 Master Collection on my notebook, but I am having a problem with my workstation. I can install everyth
-
Adobe Reader 5.05, for MAC 8.6
I need to download Adobe Reader 5.05 on my iMac (10.4.11) as my old Mac (8.6) is not connected to the internet. Do I need to download version 5 first and then upgrade to 5.05 or would 5.05 be the complete application on it's own? And what would be t
-
I have a class called shapeC that only creates a rectangle and then addChild(rectangle);. That class is instantiated on the main timeline. Currently, the only way you can see that rectangle is to add the instantiated class to the stage via addChild
-
Loadjava Problem (NoClassDefFoundError)
Hello, I got a problem when loading the java using Loadjava command under dos prompt the error is: Exception in thread "main" java.lang.NoClassDefFoundError: oracle/lite/loadjava/Main How can i solve it? I have checked the classpath. It includes OLIT