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 Member
0 Likes
626

what are the basic steps to follow for generating ALV REPORT

6 REPLIES 6
Read only

Former Member
0 Likes
581

Hi,

ALV is Application List viewer.

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

How to Upload Logo for ALV?

Upload Logo for REUSE_ALV_COMMENTARY_WRITE

Get help for your ABAP problems

Do you have a ABAP Question?

ABAP Books

ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

ABAP Tips

ABAP Forum for Discussion and Samples Program Codes for Abapers

Best regards,

SAP Basis, ABAP Programming and Other IMG Stuff

http://www.sap-img.com

All the site contents are Copyright © www.sap-img.com and the content authors. All rights reserved.

All product names are trademarks of their respective companies. The site www.sap-img.com is in no way affiliated with SAP AG.

Every effort is made to ensure the content integrity. Information used on this site is at your own risk.

The content on this site may not be reproduced or redistributed without the express written permission of

www.sap-img.com or the content authors.

**ALV EXAMPLE

*&----


*

*& Report ZJE_ALV_EXAMPLE

*&

*&----


*

*&

*&

*&----


*

REPORT zje_alv_example.

TYPE-POOLS: slis.

*type declaration for values from ekko

TYPES: BEGIN OF i_ekko,

ebeln LIKE ekko-ebeln,

aedat LIKE ekko-aedat,

bukrs LIKE ekko-bukrs,

bsart LIKE ekko-bsart,

lifnr LIKE ekko-lifnr,

END OF i_ekko.

*type declaration for values from ekpo

TYPES: BEGIN OF i_ekpo,

ebeln LIKE ekpo-ebeln,

ebelp LIKE ekpo-ebelp,

matnr LIKE ekpo-matnr,

menge LIKE ekpo-menge,

meins LIKE ekpo-meins,

netpr LIKE ekpo-netpr,

END OF i_ekpo.

DATA: it_ekko TYPE STANDARD TABLE OF i_ekko INITIAL SIZE 0,

wa_ekko TYPE i_ekko.

DATA: it_ekpo TYPE STANDARD TABLE OF i_ekpo INITIAL SIZE 0,

wa_ekpo TYPE i_ekpo .

*variable for Report ID

DATA: v_repid LIKE sy-repid .

*declaration for fieldcatalog

DATA: i_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv.

DATA: it_listheader TYPE slis_t_listheader.

  • declaration for events table where user comand or set PF status will

  • be defined

DATA: v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event.

  • declartion for layout

DATA: alv_layout TYPE slis_layout_alv.

  • declaration for variant(type of display we want)

DATA: i_variant TYPE disvariant,

i_variant1 TYPE disvariant,

i_save(1) TYPE c.

*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed

DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.

DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.

INITIALIZATION.

v_repid = sy-repid.

PERFORM build_fieldcatlog.

PERFORM event_call.

PERFORM populate_event.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM build_listheader USING it_listheader.

PERFORM display_alv_report.

*&----


*

*& Form BUILD_FIELDCATLOG

*&----


*

  • Fieldcatalog has all the field details from ekko

*----


*

FORM build_fieldcatlog.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-seltext_m = 'DATE.'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'COMPANY CODE'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-seltext_m = 'DOCMENT TYPE'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKKO'.

wa_fieldcat-fieldname = 'LIFNR'.

wa_fieldcat-no_out = 'X'.

wa_fieldcat-seltext_m = 'VENDOR CODE'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. "BUILD_FIELDCATLOG

*&----


*

*& Form EVENT_CALL

*&----


*

  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


*

FORM event_call.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events

  • 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. "EVENT_CALL

*&----


*

*& Form POPULATE_EVENT

*&----


*

  • Events populated for TOP OF PAGE & USER COMAND

*----


*

FORM populate_event.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.

IF sy-subrc EQ 0.

wa_event-form = 'USER_COMMAND'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-name.

ENDIF.

ENDFORM. "POPULATE_EVENT

*&----


*

*& Form data_retrieval

*&----


*

  • retreiving values from the database table ekko

*----


*

FORM data_retrieval.

SELECT ebeln aedat bukrs bsart lifnr

FROM ekko

INTO TABLE it_ekko.

ENDFORM. "data_retrieval

*&----


*

*& Form bUild_listheader

*&----


*

  • text

*----


*

  • -->I_LISTHEADEtext

*----


*

FORM build_listheader USING i_listheader TYPE slis_t_listheader.

DATA hline TYPE slis_listheader.

hline-info = 'this is my first alv pgm'.

hline-typ = 'H'.

ENDFORM. "build_listheader

*&----


*

*& Form display_alv_report

*&----


*

  • text

*----


*

FORM display_alv_report.

v_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP_OF_PAGE'

i_grid_title = i_title_ekko

  • I_GRID_SETTINGS =

  • IS_LAYOUT = ALV_LAYOUT

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default = 'ZLAY1'

i_save = 'A'

  • is_variant = i_variant

it_events = v_events

TABLES

t_outtab = it_ekko

  • 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. "display_alv_report

*&----


*

*& Form TOP_OF_PAGE

*&----


*

  • text

*----


*

FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

*&----


*

*& Form USER_COMMAND

*&----


*

  • text

*----


*

  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


*

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.

PERFORM build_fieldcatlog_ekpo.

PERFORM event_call_ekpo.

PERFORM populate_event_ekpo.

PERFORM data_retrieval_ekpo.

PERFORM build_listheader_ekpo USING it_listheader.

PERFORM display_alv_ekpo.

ENDCASE.

ENDFORM. "user_command

*&----


*

*& Form BUILD_FIELDCATLOG_EKPO

*&----


*

  • text

*----


*

FORM build_fieldcatlog_ekpo.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-seltext_m = 'PO NO.'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'IT_EKPO'.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-seltext_m = 'LINE NO'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-seltext_m = 'MATERIAL NO.'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-seltext_m = 'QUANTITY'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-seltext_m = 'UOM'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-tabname = 'I_EKPO'.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-seltext_m = 'PRICE'.

APPEND wa_fieldcat TO i_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. "BUILD_FIELDCATLOG_EKPO

*&----


*

*& Form event_call_ekpo

*&----


*

  • we get all events - TOP OF PAGE or USER COMMAND in table v_events

*----


*

FORM event_call_ekpo.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events

  • 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. "event_call_ekpo

*&----


*

*& Form POPULATE_EVENT

*&----


*

  • Events populated for TOP OF PAGE & USER COMAND

*----


*

FORM populate_event_ekpo.

READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.

IF sy-subrc EQ 0.

wa_event-form = 'TOP_OF_PAGE'.

MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =

wa_event-form.

ENDIF.

ENDFORM. "POPULATE_EVENT

*&----


*

*& Form TOP_OF_PAGE

*&----


*

  • text

*----


*

FORM f_top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

  • i_logo =

  • I_END_OF_LIST_GRID =

.

ENDFORM. "TOP_OF_PAGE

*&----


*

*& Form USER_COMMAND

*&----


*

  • text

*----


*

  • -->R_UCOMM text

  • -->, text

  • -->RS_SLEFIELDtext

*----


*

*retreiving values from the database table ekko

FORM data_retrieval_ekpo.

SELECT ebeln ebelp matnr menge meins netpr

FROM ekpo

INTO TABLE it_ekpo.

ENDFORM. "DATA_RETRIEVAL_EKPO

*&----


*

*& Form BUILD_LISTHEADER_EKPO

*&----


*

  • text

*----


*

  • -->I_LISTHEADER text

*----


*

FORM build_listheader_ekpo USING i_listheader TYPE slis_t_listheader.

DATA: hline1 TYPE slis_listheader.

hline1-typ = 'H'.

hline1-info = 'CHECKING PGM'.

ENDFORM. "BUILD_LISTHEADER_EKPO

*&----


*

*& Form DISPLAY_ALV_EKPO

*&----


*

  • text

*----


*

FORM display_alv_ekpo.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = v_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

i_callback_top_of_page = '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_title_ekpo

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

i_save = 'A'

  • IS_VARIANT =

it_events = v_events

TABLES

t_outtab = it_ekpo

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. "DISPLAY_ALV_EKPO

Read only

Former Member
0 Likes
581

hi,

the alv function modules are used to enhance the output of the report.

While preparing a list to be displayed we have some basic components to prepare. These are;

1. List data

2.Field Catalog

3. Layout Structure

4.events

1.list data: this is the data in an internal table to be listed.

2.field catalog: We use another internal table to define specifications on how the fields of our list will be displayed. This internal table is called the u201Cfield catalogu201D.

3.layout structure: We fill a structure to specify general layout options for the grid. With this structure we can set general display options, grid customizing, totals options, color adjustments etc

4. events: handles the events like top_of_page, end_of_page,

user_command.

the internal tables used are

for fieldcat: SLIS_T_FIELDCAT_ALV

for layout: SLIS_LAYOUT_ALV

for events: SLIS_T_EVENT

thanks and regards.

Read only

0 Likes
581

Find some more info below:

ABAP List Viewer

The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).

Using ALV, we can have three types of reports:

1. Simple Report

2. Block Report

3. Hierarchical Sequential Report

There are some function modules which will enable to produce the above reports without much effort.

All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.

SIMPLE REPORT:

The important function modules are:

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_FIELDCATALOG_MERGE

REUSE_ALV_EVENTS_GET

REUSE_ALV_COMMENTARY_WRITE

REUSE_ALV_GRID_DISPLAY

A. REUSE_ALV_LIST_DISPLAY: This is the function module which prints the data.

The important parameters are:

1. Export:

a. I_callback_program : report id

b. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf -status.

c. I_callback_user_command : routine where the function codes are handled.

d. I_structure_name: name of the dictionary table

e. Is_Layout : structure to set the layout of the report

f. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE)

g. It_events : internal table with a list of all possible events of ALVand their corresponding routine names.

2. Tables:

a. t_outtab: internal table with the data to be output

B. REUSE_ALV_FIELDCATALOG_MERGE:

This function module is used to populate a field catalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Itu2019s enough to mention the table name as a parameter (I_structure_name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The important parameters are:

1. Export:

a. I_program_name : report id

b. I_internal_tabname : the internal output table

c. I_inclname : include or the report name where all the dynamic forms are handled.

2. Changing

ct_fieldcat: an internal table with the type SLIS_T_FIELDCAT_ALV which is declared in the type pool SLIS.

C. REUSE_ALV_EVENTS_GET: Returns table of possible events for a list type

1. Import:

Et_Events : The event table is returned with all possible CALLBACK events for the specified list type (column u2018NAMEu2019). For events to be processed by the callback, their u2018FORMu2019 field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field u2018FORMu2019 filled and the entry modified using constants from the type pool SLIS.

2. Export:

I_list_type:

0 = simple list

1 = hierarchical-sequential list

2 = simple block list

3 = hierarchical-sequential block list

D. REUSE_ALV_COMMENTARY_WRITE: This is used in the TOP-OF-PAGE event to print the headings and other comments for the list.

1. It_list_commentary : Internal table with the headings of the type slis_t_listheader.

This internal table has three fields:

Typ : u2018Hu2019 - header, u2018Su2019 - selection, u2018Au2019 - action

Key : only when typ is u2018Su2019.

Info : the text to be printed

E. REUSE_ALV_GRID_DISPLAY: A new function in 4.6 versions, to display the results in grid rather than as a list.

Parameters: same as REUSE_ALV_LIST_DISPLAY

HIERARCHICAL REPORTS

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

1. Export:

a. I_CALLBACK_PROGRAM

b. I_CALLBACK_PF_STATUS_SET

c. I_CALLBACK_USER_COMMAND

d. IS_LAYOUT

e. IT_FIELDCAT

f. IT_EVENTS

g. I_TABNAME_HEADER: Name of the internal table in the program containing the output data of the highest hierarchy level.

h. I_TABNAME_ITEM: Name of the internal table in the program containing the output data of the lowest hierarchy level.

i. IS_KEYINFO: This structure contains the header and item table field names which link the two tables (shared key).

2. Tables

a. T_OUTTAB_HEADER: Header table with data to be output

b. T_OUTTAB_ITEM: Name of the internal table in the program containing the output data of the lowest hierarchy level.

BLOCK REPORT:

This is used to display multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_DISPLAY

D. REUSE_ALV_BLOCK_HS_LIST_APPEND

A. REUSE_ALV_BLOCK_LIST_INIT

Parameters:

a. I_CALLBACK_PROGRAM

b. I_CALLBACK_PF_STATUS_SET

c. I_CALLBACK_USER_COMMAND

This function module is used to set the default GUI status etc.

B. REUSE_ALV_BLOCK_LIST_APPEND

Export :

a. IS_LAYOUT : layout settings for block

b. IT_FIELDCAT : field catalog

c. I_TABNAME : Internal table name of the output data

d. IT_EVENTS : internal table name with all possible events

Tables :

a. T_OUTTAB : internal table with output data.

This function module adds the data to the block.

INTERNAL TABLES IN SLIS

SLIS_T_FIELDCAT_ALV:

This internal table contains the field attributes. This internal table can be populated automatically by using u2018REUSE_ALV_FIELDCATALOG_MERGEu2019.

Important Attributes:

a. col_pos : position of the column

b. fieldname : internal fieldname

c. tabname : internal table name

d. ref_fieldname : fieldname (dictionary)

e. ref_tabname : table (dictionary)

f. key(1) : column with key-color

g. icon(1) : icon

h. hotspot(1) : hotspot

i. Symbol(1) : symbol

j. Checkbox(1) : checkbox

k. just(1) : (R)ight (L)eft (C)ent

l. do_sum(1) : sum up

m. no_out(1) : (O)blig. (X)no out

n. outputlen : output length

o. seltext-l : long key word

p. seltext_m : middle key word

q. seltext_s : short key word

r. reptext_ddic : heading(ddic)

s. ddictxt(1) : (S)hort (M)iddle (L)ong

t. datatype : datatype

SLIS_T_EVENT:

Internal table for storing all the possible events of the ALV. This can be populated by the function module REUSE_ALV_EVENTS_GET

The columns are:

Name: name of the event

Form: name of the routine

SYNTAXES FOR THE ROUTINES

I_CALLBACK_PF_STATUS_SET

Syntax:

FORM set_pf_status USING rt_extab TYPE slis_t_extab

The table RT_EXTAB contains the function codes which are hidden in the standard interface.

I_CALLBACK_USER_COMMAND

Syntax :

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

The parameter r_ucomm contains the function code.

The structure rs_selfield has the details about the current cursor position.

Regards,

Shrini

Read only

Former Member
0 Likes
581

Hi,

To generate the simple ALV Grid display report, follow the steps.

1.Define internal table of dictionary table.

2.Retrieve the data from dictionary table into internal table

3.Call the ALV function module to display the data

Ex:-

data: itab type table of mara.

select * from mara into table itab.

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 = 'MARA'

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • 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 = ITAB

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

Reward,if useful.

Thanks,

Chandu

Read only

Former Member
0 Likes
581

hi check this..

this is a simple alv report with subtotal sign...

&----


*& Report ZTEST_ALV_PERC_13317

*&

&----


*&

*&

&----


REPORT ztest_alv_perc_13317.

TYPE-POOLS: slis.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

it_events TYPE slis_t_event,

wa_events TYPE slis_alv_event,

it_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv,

l_layout TYPE slis_layout_alv.

TYPES: BEGIN OF ty_itab,

field1(10),

qty1 TYPE i,

qty2 TYPE i,

qty3 TYPE i,

dummy TYPE c,

END OF ty_itab.

DATA: itab TYPE STANDARD TABLE OF ty_itab WITH HEADER LINE,

itab1 TYPE ty_itab.

START-OF-SELECTION.

itab-field1 = 'FIRST'.

itab-qty1 = 2.

itab-qty2 = 1.

itab-qty3 = 5.

itab-dummy = 10.

APPEND itab.

itab-field1 = 'FIRST'.

itab-qty1 = 2.

itab-qty2 = 1.

itab-qty3 = 5.

itab-dummy = 10.

APPEND itab.

itab-field1 = 'FIRST'.

itab-qty1 = 2.

itab-qty2 = 1.

itab-qty3 = 5.

itab-dummy = 10.

APPEND itab.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'FIELD1'.

wa_fieldcat-tabname = 'ITAB'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'QTY1'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'QTY2'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'QTY3'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

wa_fieldcat-col_pos = 5.

wa_fieldcat-fieldname = 'DUMMY'.

wa_fieldcat-tabname = 'ITAB'.

wa_fieldcat-do_sum = 'X'.

wa_fieldcat-no_out = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

REFRESH it_sort. CLEAR it_sort.

wa_sort-spos = 1.

wa_sort-fieldname = 'FIELD1'.

wa_sort-tabname = 'ITAB'.

wa_sort-up = 'X'.

APPEND wa_sort TO it_sort.

CLEAR wa_sort.

wa_sort-spos = 2.

wa_sort-fieldname = 'DUMMY'.

wa_sort-tabname = 'ITAB'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO it_sort.

CLEAR wa_sort.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = it_events

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 it_events WITH KEY name = slis_ev_subtotal_text INTO wa_events.

IF sy-subrc = 0.

MOVE 'CHANGE_SUBTOTAL_TEXT' TO wa_events-form.

MODIFY it_events FROM wa_events INDEX sy-tabix.

ENDIF.

l_layout-subtotals_text = 'Subtotal'.

l_layout-totals_text = 'total text'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = sy-repid

it_fieldcat = it_fieldcat

it_sort = it_sort

it_events = it_events

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2

.

IF sy-subrc <> 0.

ENDIF.

&----


*& Form CHANGE_SUBTOTAL_TEXT

&----


  • text

----


FORM change_subtotal_text USING i_listhead STRUCTURE itab1

i_subtotal TYPE slis_subtot_text.

IF i_subtotal-criteria = 'DUMMY'.

i_subtotal-display_text_for_subtotal = 'Sub total'.

i_listhead-qty3 = ( i_listhead-qty1 - i_listhead-qty2 ) / i_listhead-qty2 .

ELSE.

i_listhead-field1 = 'Total'.

ENDIF.

ENDFORM. "CHANGE_SUBTOTAL_TEXT

regards,

venkat