2007 Aug 08 12:34 PM
hi
i have this program, i dont know how to do with variant, when i click in parameter variant i am not get anything , then what is the use of this variant.
report ztest_0002
no standard page heading
message-id zmm.
Tables.
tables: mara.
Global ALV Data Declarations
type-pools: slis.
Internal Tables
data: begin of itab occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of itab.
data: fieldcat type slis_t_fieldcat_alv.
data: variant type disvariant.
Selection Screen
selection-screen begin of block b1 with frame title text-002 .
select-options: s_matnr for mara-matnr.
parameters: p_var(30) type c.
selection-screen end of block b1.
initialization.
variant-report = sy-repid.
variant-username = sy-uname.
at selection-screen on value-request for p_var.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = variant
i_save = 'U'
importing
es_variant = variant
exceptions
not_found = 1
program_error = 2
others = 3.
p_var = variant-variant.
start-of-selection.
perform get_data.
perform call_alv.
*********************************************************************
Form GET_DATA
*********************************************************************
form get_data.
select maramatnr maktmaktx
into corresponding fields of table itab
from mara
inner join makt
on maramatnr = maktmatnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
************************************************************************
CALL_ALV
************************************************************************
form call_alv.
perform build_field_catalog.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
is_variant = variant
i_save = 'U'
tables
t_outtab = itab.
endform.
************************************************************************
BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
data: label(30) type c.
clear: fieldcat. refresh: fieldcat.
perform update_catalog using 'Material Number'
'ITAB'
'MATNR'
'18'
space
space
'L'.
perform update_catalog using 'Material Description'
'ITAB'
'MAKTX'
'40'
space
space
'L'.
endform.
************************************************************************
UPDATE_CATALOG
************************************************************************
form update_catalog using col_head
table
field
outputlen
do_sum
no_out
just.
data: tmp_fc type slis_t_fieldcat_alv with header line.
tmp_fc-reptext_ddic = col_head.
tmp_fc-fieldname = field.
tmp_fc-tabname = table.
tmp_fc-outputlen = outputlen.
tmp_fc-just = just.
tmp_fc-decimals_out = 0.
tmp_fc-do_sum = do_sum.
tmp_fc-no_out = no_out.
append tmp_fc to fieldcat.
endform.
hi
i have this program, i dont know how to do with variant, when i click in parameter variant i am not get anything , then what is the use of this variant.
report ztest_0002
no standard page heading
message-id zmm.
Tables.
tables: mara.
Global ALV Data Declarations
type-pools: slis.
Internal Tables
data: begin of itab occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of itab.
data: fieldcat type slis_t_fieldcat_alv.
data: variant type disvariant.
Selection Screen
selection-screen begin of block b1 with frame title text-002 .
select-options: s_matnr for mara-matnr.
parameters: p_var(30) type c.
selection-screen end of block b1.
initialization.
variant-report = sy-repid.
variant-username = sy-uname.
at selection-screen on value-request for p_var.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = variant
i_save = 'U'
importing
es_variant = variant
exceptions
not_found = 1
program_error = 2
others = 3.
p_var = variant-variant.
start-of-selection.
perform get_data.
perform call_alv.
*********************************************************************
Form GET_DATA
*********************************************************************
form get_data.
select maramatnr maktmaktx
into corresponding fields of table itab
from mara
inner join makt
on maramatnr = maktmatnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
************************************************************************
CALL_ALV
************************************************************************
form call_alv.
perform build_field_catalog.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
is_variant = variant
i_save = 'U'
tables
t_outtab = itab.
endform.
************************************************************************
BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
data: label(30) type c.
clear: fieldcat. refresh: fieldcat.
perform update_catalog using 'Material Number'
'ITAB'
'MATNR'
'18'
space
space
'L'.
perform update_catalog using 'Material Description'
'ITAB'
'MAKTX'
'40'
space
space
'L'.
endform.
************************************************************************
UPDATE_CATALOG
************************************************************************
form update_catalog using col_head
table
field
outputlen
do_sum
no_out
just.
data: tmp_fc type slis_t_fieldcat_alv with header line.
tmp_fc-reptext_ddic = col_head.
tmp_fc-fieldname = field.
tmp_fc-tabname = table.
tmp_fc-outputlen = outputlen.
tmp_fc-just = just.
tmp_fc-decimals_out = 0.
tmp_fc-do_sum = do_sum.
tmp_fc-no_out = no_out.
append tmp_fc to fieldcat.
endform.
2007 Aug 08 12:40 PM
Hi,
i do it in this way:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARIAN.
*
DATA: I_VARIANT LIKE DISVARIANT.
DATA: E_VARIANT LIKE DISVARIANT.
*
<b> I_VARIANT-REPORT = SY-REPID.</b>
*
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
IS_VARIANT = I_VARIANT
I_SAVE = 'A'
IMPORTING
ES_VARIANT = E_VARIANT
EXCEPTIONS
NOT_FOUND = 1
PROGRAM_ERROR = 2
OTHERS = 3.
*
IF SY-SUBRC <> 0.
MESSAGE I010 WITH 'Es sind keine Varianten angelegt'.
CLEAR: P_VARIAN.
ELSE.
P_VARIAN = E_VARIANT-VARIANT.
ENDIF.
*
2007 Aug 08 12:49 PM
HI
The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
standardized format. The list data is displayed as a table on the screen.
The ALV Grid Control offers a range of interactive standard list functions that users need
frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
export list (in different formats), and so on. These functions are implemented in the
proxy object class. You as the programmer have the possibility to turn off functions not
needed. In most cases the implementations of the standard functions provided by the
control are sufficient. However, if required, you can adjust these implementations to
meet application-specific needs.
You can add self-defined functions to the toolbar, if necessary.
The ALV Grid Control allows users to adjust the layout of lists to meet their individual
requirements (for example, they can swap columns, hide columns, set filters for the
data to be displayed, calculate totals, and so on). The settings (list customizing) made
by a specific user are called a display variant. Display variants can be saved on a userspecific
or on a global basis. If such display variants exist for a list, they can be offered
to the user for selection. If a display variant is set as the default variant, the associated
list is always displayed based on the settings of this variant.
2. REUSE_ALV_LIST_DISPLAY
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_COMMENTARY_WRITE
3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
7.fieldcat-fieldname
fieldcat-ref_fieldname
fieldcat-tabname
fieldcat-seltext_m
5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
But either no.7 or No.8 is there in the Program.
How you call this function in your report?
After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
Then use follwing function module.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Prog.name'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA
The object F_IT_ALV has a field, the activity ACTVT, which can
contain four permitted values: 01, 02, 03 and 70. Each of the
activities 01, 02 and 70 controls the availability of particular
functions (in the menu and the toolbar) of the ALV line item list:
a) 01: "Settings -> Display variant -> Save..."
b) 02: "Settings -> Display variant -> Current..." and
"Settings -> Display variant -> Current header rows "
c) 70: "Settings -> Display variant -> Administration..."
Activity 03 corresponds to the minimum authorization, which is the
most restricted one: The user can only select layouts which have
been configured already. In particular, all of the other functions
named above are inactive with activity 03.
Now if you want to permit a user to change the column selection and
the headers as well as to save the layout thus created, for example,
but if you do not want to permit the user to administrate the
layouts, you grant him or her the authorization for activities 01
and 02.
Check this link it will be mosty usefull for u
http://www.sap-img.com/fu017.htm
DATA: VARIANT TYPE DISVARIANT.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = VARIANT
I_SAVE = 'A'
CHANGING
IT_OUTTAB = IALV[]
IT_FIELDCATALOG = FIELDCAT[].
Reward all helpfull answers
Regards
Pavan
2007 Aug 08 12:48 PM
2007 Aug 08 12:56 PM
2007 Aug 08 1:32 PM
Execute the program and then go to Menu Settings / Layout / change or click on change or Save layout Icons
=> There a popup appears where you can manage your display variants (fields, sort, etc.)
In your program (with "U") you will notice that the User-specific box is checked and the system don't propose a "/" to begin the variant name as it does with public variants. (replace "U" with "A" to see the difference)
Regards
2007 Aug 08 1:02 PM
Hi
variant means its a constant
after clicking the execute button , enter some values in the selection screen and click on save button it will ask for variant name so enter any name and save
come back from next time on words when u execute the program that variant will exist there by clicking that variant name , what ever the values in that that will display
you can maintain any number of variants
beside execute button on the selection screen the variant option will exist
rewrad if usefull
2007 Aug 08 1:06 PM
hi naresh,
then what is the use of alv variant?
we can direcly create the variant with calling funciton module?
2007 Aug 08 1:16 PM
pls check this code, here variant is not working ,pls tell me how to make it work.
Tables.
tables: mara.
Global ALV Data Declarations
type-pools: slis.
Internal Tables
data: begin of itab occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of itab.
data: fieldcat type slis_t_fieldcat_alv.
data: variant type disvariant.
Selection Screen
selection-screen begin of block b1 with frame title text-002 .
select-options: s_matnr for mara-matnr.
parameters: p_var(30) type c.
selection-screen end of block b1.
initialization.
variant-report = sy-repid.
variant-username = sy-uname.
at selection-screen on value-request for p_var.
call function 'REUSE_ALV_VARIANT_F4'
exporting
is_variant = variant
i_save = 'A'
importing
es_variant = variant
exceptions
not_found = 1
program_error = 2
others = 3.
IF SY-SUBRC <> 0.
MESSAGE i000(AT) with 'error'..
CLEAR: P_VAR.
ELSE.
p_var = variant-variant..
ENDIF.
*p_var = variant-variant.
*
start-of-selection.
perform get_data.
perform call_alv.
*********************************************************************
Form GET_DATA
*********************************************************************
form get_data.
select maramatnr maktmaktx
into corresponding fields of table itab
from mara
inner join makt
on maramatnr = maktmatnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
************************************************************************
CALL_ALV
************************************************************************
form call_alv.
perform build_field_catalog.
Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
is_variant = variant
i_save = 'U'
tables
t_outtab = itab.
endform.
************************************************************************
BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
data: label(30) type c.
clear: fieldcat. refresh: fieldcat.
perform update_catalog using 'Material Number'
'ITAB'
'MATNR'
'18'
space
space
'L'.
perform update_catalog using 'Material Description'
'ITAB'
'MAKTX'
'40'
space
space
'L'.
endform.
************************************************************************
UPDATE_CATALOG
************************************************************************
form update_catalog using col_head
table
field
outputlen
do_sum
no_out
just.
data: tmp_fc type slis_t_fieldcat_alv with header line.
tmp_fc-reptext_ddic = col_head.
tmp_fc-fieldname = field.
tmp_fc-tabname = table.
tmp_fc-outputlen = outputlen.
tmp_fc-just = just.
tmp_fc-decimals_out = 0.
tmp_fc-do_sum = do_sum.
tmp_fc-no_out = no_out.
append tmp_fc to fieldcat.
endform.
2007 Aug 08 1:26 PM
Hi Jamshad
Plz Read out my answer where u can get all details of variant using in report and variant used manually
Regards
Pavan
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |