Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

hw to varients for alv layout varients

Former Member
0 Kudos
171

i want to create varient for alv layout (not for selection screen) and hw to use them

plz help its urgent

1 ACCEPTED SOLUTION

Former Member
0 Kudos
121

Reward if helpful

report zrich_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.

7 REPLIES 7

Former Member
0 Kudos
122

Reward if helpful

report zrich_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.

0 Kudos
121

hi jain tanks for ur reply can u say hw to save the varient for layout iits urgent plz

0 Kudos
121

Hi visu,

in the alv-output, there's a butto cange layout. do your changes and save this.

now you can start your report with this variant (for alv-layout).

Regards, Dieter

Important:

in grid call you have to set this parameter:

I_SAVE = 'A'

Regards, Dieter

Message was edited by:

Dieter Gröhn

0 Kudos
121

thanks Dieter

i hav excuted the report and in the i changed the order of one row and saved the layout using settings-----layout (varient)

now i came back and excuted with that varient i m not getting the chaged row as i want

plz help its urgent

0 Kudos
121

Hi

1. 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.

<u><b>Check this link it will be mosty usefull for u</b></u>

http://www.sap-img.com/fu017.htm

Reward all helpfull answers

Regards

Pavan

Message was edited by:

Pavan praveen

0 Kudos
121

thanks praveen problem solved

Former Member
0 Kudos
121

Hi visu,

try this in your report:

...

SELECTION-SCREEN: BEGIN OF LINE.

SELECTION-SCREEN: COMMENT 01(33) T_VARIAN.

PARAMETERS: P_VARIAN LIKE DISVARIANT-VARIANT.

SELECTION-SCREEN: END OF LINE.

*

DATA: VARIANT LIKE DISVARIANT.

*

************************************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARIAN.

*

DATA: I_VARIANT LIKE DISVARIANT.

DATA: E_VARIANT LIKE DISVARIANT.

*

I_VARIANT-REPORT = SY-REPID.

*

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.

CLEAR: P_VARIAN.

ELSE.

P_VARIAN = E_VARIANT-VARIANT.

ENDIF.

*

************************************************************************

INITIALIZATION.

*

T_VARIAN = 'Anzeigevariante'.

*

************************************************************************

START-OF-SELECTION.

*

  • Selektierte Variante zuordnen

VARIANT-VARIANT = P_VARIAN.

*

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

...

IS_VARIANT = VARIANT

...

Regards, Dieter