2006 Aug 18 6:17 PM
Hello All,
I have set a default variant for a report. When users run the report with this default variant and if they like to change the layout, they should not be able to overwrite this default variant. How to accomplish this. I am using the Reuse ALV GRID DISPLAY.
I have also provided the display variant box on the selection screen.
2006 Aug 18 6:20 PM
Hello All,
I have set a default variant for a report. When users run the report with this default variant and if they like to change the layout, they should not be able to overwrite this default variant. How to accomplish this. I am using the Reuse ALV GRID DISPLAY.
I have also provided the display variant box on the selection screen.
2006 Aug 18 6:20 PM
2006 Aug 18 6:32 PM
Thanks Rich, thats an idea. But what happens if the user wants to create another variant and wants to save it?
2006 Aug 18 6:38 PM
Well, if you are building the default variant which will be the default way the ALV grid is viewed, it will not show up as a "Default" variant anyway, so you can allow I_SAVE to be marked. This way the user can create a new layout.
The idea here is that you will build the layout they way you want it to be display by default(not using variant), just when you add the fields to the field cat, make sure they are in the order that you want, you can also use the sort parameter to setup sorting and subtotaling here is a simple example.
report zrich_0004
no standard page heading.
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: sort type slis_t_sortinfo_alv.
data: begin of ivbap occurs 0,
vbeln type vbap-vbeln,
kunnr type vbak-kunnr,
vkorg type vbak-vkorg,
netwr type vbap-netwr,
end of ivbap.
* Selection Screen
start-of-selection.
perform get_data.
perform write_report.
************************************************************************
* Get_Data
************************************************************************
form get_data.
select vbak~vbeln vbak~kunnr vbak~vkorg vbap~netpr
into table ivbap
from vbak
inner join vbap
on vbak~vbeln = vbap~vbeln
up to 100 rows.
endform.
************************************************************************
* WRITE_REPORT
************************************************************************
form write_report.
data: layout type slis_layout_alv.
data: variant type disvariant.
layout-totals_only = 'X'.
variant-report = sy-repid.
variant-username = sy-uname.
perform build_field_catalog.
perform build_sort.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_sort = sort
is_layout = layout
it_fieldcat = fieldcat
is_variant = variant
i_save = 'X'
tables
t_outtab = ivbap.
endform.
************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_fieldcat_alv .
clear fieldcat. refresh fieldcat.
clear fc_tmp.
fc_tmp-reptext_ddic = 'Sales Org'.
fc_tmp-fieldname = 'VKORG'.
fc_tmp-tabname = 'IVBAP'.
fc_tmp-outputlen = '4'.
append fc_tmp to fieldcat.
clear fc_tmp.
fc_tmp-reptext_ddic = 'Customer'.
fc_tmp-fieldname = 'KUNNR'.
fc_tmp-tabname = 'IVBAP'.
fc_tmp-outputlen = '10'.
append fc_tmp to fieldcat.
clear fc_tmp.
fc_tmp-reptext_ddic = 'SD DOC'.
fc_tmp-fieldname = 'VBELN'.
fc_tmp-tabname = 'IVBAP'.
fc_tmp-outputlen = '10'.
append fc_tmp to fieldcat.
clear fc_tmp.
fc_tmp-reptext_ddic = 'Net'.
fc_tmp-fieldname = 'NETWR'.
fc_tmp-tabname = 'IVBAP'.
fc_tmp-outputlen = '15'.
fc_tmp-do_sum = 'X'.
fc_tmp-datatype = 'QUAN'.
append fc_tmp to fieldcat.
endform.
************************************************************************
* FORM build_sort *
************************************************************************
form build_sort.
data: tmp_sort type line of slis_t_sortinfo_alv.
clear sort. refresh sort.
clear tmp_sort.
tmp_sort-fieldname = 'VKORG'.
tmp_sort-tabname = 'IALV'.
tmp_sort-up = 'X'.
tmp_sort-subtot = 'X'.
tmp_sort-group = 'X'.
* tmp_sort-expa = 'X'.
append tmp_sort to sort.
clear tmp_sort.
tmp_sort-fieldname = 'KUNNR'.
tmp_sort-tabname = 'IALV'.
tmp_sort-up = 'X'.
tmp_sort-subtot = 'X'.
tmp_sort-group = 'X'.
tmp_sort-expa = 'X'.
append tmp_sort to sort.
clear tmp_sort.
tmp_sort-fieldname = 'VBELN'.
tmp_sort-tabname = 'IALV'.
tmp_sort-up = 'X'.
tmp_sort-subtot = 'X'.
tmp_sort-group = 'X'.
tmp_sort-expa = 'X'.
append tmp_sort to sort.
endform.
Regards,
Rich Heilman
2006 Aug 18 7:08 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |