Application Development and Automation 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: 
Read only

ALV

former_member630092
Participant
0 Likes
727

Hi all

i want to learn ALV's.

Can any one tell me

1) why we need ALV's ?( Already heaving Repoerts )

2) And tell me step by step procedures :

How many types of ALV's are ?

And just give the material/links from where ,i can get the material.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
661

ALV (Abap List Viewer)

We can easily implement basic features of reports like Sort, Allign, Filtering, Totals-Subtotals etc... by using ALV. Three types of reports we can do by ALV as 1. Simple Report, 2. Block Reprot and 3. Hierarchical Sequential Report.

alv grid types

1) list/ grid

these are having rows and columns

function modules for this type are

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_GRID_DISPLAY2)

2) HIERARCHY

this will have header and line items

function module for this type

REUSE_ALV_HIERSEQ_LIST_DISPLAY

3) tree

this will nodes and child type structure

function module for this type

REUSE_ALV_TREE_DISPLAY

4) APPEND

this can append all the different types of lists where each list has different number of columns

events associated with alvs

1) top of page

2) end of page

3) top of list

4) end of list

5) on double click

6) on link click

7) on user command

some useful links:

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

http://help.sap.com/saphelp_nw04/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm

Examples:

REPORT Z_ALV__ITEM .

TYPE-POOLS : slis.

*----

-


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : flag tyPE c,

END OF itab.

*

*DATA: itab like t001 occurs 0 with header line.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

data v_repid like sy-repid.

*----

-


Select Data

v_repid = sy-repid.

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = alvfc[] .

*----

-


Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc[]

i_callback_program = v_repid

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

In very detail it's not easy, i believe it's better for you to test the function modules to work with ALV :

REUSE_ALV_FIELDCATALOG_MERGE to create the fieldcatalogue

REUSE_ALV_GRID_DISPLAY - to display the ALV in grid format

REUSE_ALV_LIST_DISPLAY - to display the ALV in list format

Anyone, here's one exemple of creating ALV reports :

REPORT ZALV_SLAS_GDF .

  • Declaração de Dados

TABLES: ZSLA_NIV_SAT.

selection-screen begin of block b1 with frame title text-001.

select-options DATA for ZSLA_NIV_SAT-DATA. " Data

select-options LIFNR for ZSLA_NIV_SAT-LIFNR. " Nº de conta fornecedor

select-options WERKS for ZSLA_NIV_SAT-WERKS. " Centro

select-options EBELN for ZSLA_NIV_SAT-EBELN. " Nº contrato

selection-screen end of block b1.

DATA: BEGIN OF itab1 OCCURS 100.

include structure ZSLA_NIV_SAT.

data: END OF itab1.

*----


*

  • Outros dados necessários:

  • Campo para guardar o nome do report

DATA: i_repid LIKE sy-repid.

  • Campo para verificar o tamanho da tabela

DATA: i_lines LIKE sy-tabix.

*----


*

  • Dados para mostrar o ALV

TYPE-POOLS: SLIS.

*DATA: int_fcat type SLIS_T_FIELDCAT_ALV with header line.

DATA: int_fcat type SLIS_T_FIELDCAT_ALV.

DATA: l_key TYPE slis_keyinfo_alv.

START-OF-SELECTION.

  • Ler dados para dentro da tabela imat

SELECT * FROM ZSLA_NIV_SAT

INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE data in data

and lifnr in lifnr

and ebeln in ebeln

and werks in werks.

CLEAR: i_lines.

DESCRIBE TABLE itab1 LINES i_lines.

IF i_lines lt 1.

WRITE: / 'Não foram seleccionadas entradas.'.

EXIT.

ENDIF.

END-OF-SELECTION.

*----


*

  • Agora, começa-se o ALV

*

*----


*

  • Para usar o ALV, nós precisamos de uma estrutura do dicionário de

*dados DDIC ou de uma coisa chamada “Fieldcatalogue”.

  • Existe 2 maneiras de preencher a coisa referida acima:

*Automaticamente e Manualmente

  • Como preencher Automaticamente?

  • O fieldcatalouge pode ser gerado pela Função

*'REUSE_ALV_FIELDCATALOG_MERGE' a partir de uma tabela de qualquer fonte

  • Para que se possa utilizar esta função tabela tem que ter campos do

*dicionário de dados, como é o caso da tabela ITAB1

*----


*

  • Guardar o nome do programa

i_repid = sy-repid.

  • Create Fieldcatalogue from internal table

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME =

i_repid

I_INTERNAL_TABNAME =

'ITAB1' "LETRAS GRANDES

I_INCLNAME =

i_repid

CHANGING

CT_FIELDCAT =

int_fcat[]

EXCEPTIONS

INCONSISTENT_INTERFACE =

1

PROGRAM_ERROR =

2

OTHERS =

3.

IF SY-SUBRC <> 0.

WRITE: / 'Returncode', sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

*Isto era o Fieldcatalogue

*----


*

  • E agora estamos preparados para executar o ALV

  • Chama o ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = int_fcat[]

I_DEFAULT = ' '

I_SAVE = ' ' "'A'

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.
WRITE: /
'Returncode', sy-subrc, 'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
ENDIF.


Please reward the helpful entries.

Regards,

Raman.

Hi all

i want to learn ALV's.

Can any one tell me

1) why we need ALV's ?( Already heaving Repoerts )

2) And tell me step by step procedures :

How many types of ALV's are ?

And just give the material/links from where ,i can get the material.

thanks

4 REPLIES 4
Read only

Former Member
0 Likes
662

ALV (Abap List Viewer)

We can easily implement basic features of reports like Sort, Allign, Filtering, Totals-Subtotals etc... by using ALV. Three types of reports we can do by ALV as 1. Simple Report, 2. Block Reprot and 3. Hierarchical Sequential Report.

alv grid types

1) list/ grid

these are having rows and columns

function modules for this type are

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_GRID_DISPLAY2)

2) HIERARCHY

this will have header and line items

function module for this type

REUSE_ALV_HIERSEQ_LIST_DISPLAY

3) tree

this will nodes and child type structure

function module for this type

REUSE_ALV_TREE_DISPLAY

4) APPEND

this can append all the different types of lists where each list has different number of columns

events associated with alvs

1) top of page

2) end of page

3) top of list

4) end of list

5) on double click

6) on link click

7) on user command

some useful links:

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

http://help.sap.com/saphelp_nw04/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm

Examples:

REPORT Z_ALV__ITEM .

TYPE-POOLS : slis.

*----

-


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : flag tyPE c,

END OF itab.

*

*DATA: itab like t001 occurs 0 with header line.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

data v_repid like sy-repid.

*----

-


Select Data

v_repid = sy-repid.

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = v_repid

i_internal_tabname = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

i_inclname = v_repid

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

changing

ct_fieldcat = alvfc[] .

*----

-


Display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = alvfc[]

i_callback_program = v_repid

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

In very detail it's not easy, i believe it's better for you to test the function modules to work with ALV :

REUSE_ALV_FIELDCATALOG_MERGE to create the fieldcatalogue

REUSE_ALV_GRID_DISPLAY - to display the ALV in grid format

REUSE_ALV_LIST_DISPLAY - to display the ALV in list format

Anyone, here's one exemple of creating ALV reports :

REPORT ZALV_SLAS_GDF .

  • Declaração de Dados

TABLES: ZSLA_NIV_SAT.

selection-screen begin of block b1 with frame title text-001.

select-options DATA for ZSLA_NIV_SAT-DATA. " Data

select-options LIFNR for ZSLA_NIV_SAT-LIFNR. " Nº de conta fornecedor

select-options WERKS for ZSLA_NIV_SAT-WERKS. " Centro

select-options EBELN for ZSLA_NIV_SAT-EBELN. " Nº contrato

selection-screen end of block b1.

DATA: BEGIN OF itab1 OCCURS 100.

include structure ZSLA_NIV_SAT.

data: END OF itab1.

*----


*

  • Outros dados necessários:

  • Campo para guardar o nome do report

DATA: i_repid LIKE sy-repid.

  • Campo para verificar o tamanho da tabela

DATA: i_lines LIKE sy-tabix.

*----


*

  • Dados para mostrar o ALV

TYPE-POOLS: SLIS.

*DATA: int_fcat type SLIS_T_FIELDCAT_ALV with header line.

DATA: int_fcat type SLIS_T_FIELDCAT_ALV.

DATA: l_key TYPE slis_keyinfo_alv.

START-OF-SELECTION.

  • Ler dados para dentro da tabela imat

SELECT * FROM ZSLA_NIV_SAT

INTO CORRESPONDING FIELDS OF TABLE itab1

WHERE data in data

and lifnr in lifnr

and ebeln in ebeln

and werks in werks.

CLEAR: i_lines.

DESCRIBE TABLE itab1 LINES i_lines.

IF i_lines lt 1.

WRITE: / 'Não foram seleccionadas entradas.'.

EXIT.

ENDIF.

END-OF-SELECTION.

*----


*

  • Agora, começa-se o ALV

*

*----


*

  • Para usar o ALV, nós precisamos de uma estrutura do dicionário de

*dados DDIC ou de uma coisa chamada “Fieldcatalogue”.

  • Existe 2 maneiras de preencher a coisa referida acima:

*Automaticamente e Manualmente

  • Como preencher Automaticamente?

  • O fieldcatalouge pode ser gerado pela Função

*'REUSE_ALV_FIELDCATALOG_MERGE' a partir de uma tabela de qualquer fonte

  • Para que se possa utilizar esta função tabela tem que ter campos do

*dicionário de dados, como é o caso da tabela ITAB1

*----


*

  • Guardar o nome do programa

i_repid = sy-repid.

  • Create Fieldcatalogue from internal table

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME =

i_repid

I_INTERNAL_TABNAME =

'ITAB1' "LETRAS GRANDES

I_INCLNAME =

i_repid

CHANGING

CT_FIELDCAT =

int_fcat[]

EXCEPTIONS

INCONSISTENT_INTERFACE =

1

PROGRAM_ERROR =

2

OTHERS =

3.

IF SY-SUBRC <> 0.

WRITE: / 'Returncode', sy-subrc,

'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

ENDIF.

*Isto era o Fieldcatalogue

*----


*

  • E agora estamos preparados para executar o ALV

  • Chama o ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = i_repid

IT_FIELDCAT = int_fcat[]

I_DEFAULT = ' '

I_SAVE = ' ' "'A'

TABLES

T_OUTTAB = itab1

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

IF SY-SUBRC <> 0.
WRITE: /
'Returncode', sy-subrc, 'from FUNCTION REUSE_ALV_GRID_DISPLAY'.
ENDIF.


Please reward the helpful entries.

Regards,

Raman.

Read only

Former Member
0 Likes
661

Hi,

1.I agree Report is there, but it doesnt suffice all your requirement. ALV provides so many facilities to enable user to sort list, sum - subtotal, Variant saving,hide columns, freeze it, colors, emphasize, Layout formattig and so many such thigs easisly and very quickly.

It supports GRID.

It has several functionalitied to enchance view, Also it supports OOPS also.

2. Lets take your material example. like from MARA you will get all lists of material and then you collect it into the internal table and then give it to the ALV function using Layout sets.

like,

collect material in it_mara and

build ALV catlog and

use REUSE_ALV_LIST or GRID

give both tables to it.

Thats it!

check this example:

http://www.erpgenie.com/abap/controls/alvgrid.htm

Reward if useful!

Read only

Former Member
0 Likes
661

please download this pdf detail expl.

http://www.abap4.it/download/ALV.pdf

Read only

former_member630092
Participant
0 Likes
661

Answered