cancel
Showing results for 
Search instead for 
Did you mean: 

regarding alv

Former Member
0 Kudos

hi experts,

i hav never used alv. how can i use alv ?what is the purpose of alv?if possible give related examples.

regards.

Prakash

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Prakash,

ALV (ABAP List Viewer) is one of the fascinating tools provided by SAP for displaying reports. This tool has the merit of reducing the development time of reports by providing standard interfaces (Function Modules). These standard interfaces provide GUI and formatting options for the on screen display.

<u><b>Check out following Link for ALV using OO concepts</b></u>

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

Check the following program also.

&----


  • Global data definitions for ALV

&----


&----


  • Object reference

&----


  • ALV Grid instance reference

DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,

  • Custom container instance reference

gr_ccontainer TYPE REF TO cl_gui_custom_container.

&----


  • Internal Table

&----


  • Field catalog table

DATA: gt_fieldcat TYPE lvc_t_fcat,

  • Internal table holding list data

gt_list TYPE STANDARD TABLE OF sflight.

&----


  • Work area

&----


  • Layout structure

DATA: gs_layout TYPE lvc_s_layo,

  • Field catalog structure

gs_fcat TYPE lvc_s_fcat.

&----


  • Variables

&----


DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm,

  • Name of the custom control added on the screen

gv_custom_control_name TYPE scrfname VALUE 'CC_ALV'.

&----


  • Calling the screen where ALV output is displayed

&----


CALL SCREEN 100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • PBO

----


MODULE status_0100 OUTPUT.

  • PF Status

SET PF-STATUS 'MENU'.

  • ALV display

PERFORM display_alv.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • PAI

----


MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

IF save_ok EQ 'EXIT'.

LEAVE PROGRAM.

ENDIF.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form display_alv

&----


  • ALV display

----


FORM display_alv.

PERFORM get_data.

PERFORM create_alv.

ENDFORM. " display_alv

&----


*& Form get_data

&----


  • Fetch data to be displayed in the list

----


FORM get_data.

SELECT * FROM sflight

INTO TABLE gt_list.

ENDFORM. " get_data

&----


*& Form create_alv

&----


  • Create and set or Refresh ALV

----


FORM create_alv.

  • Checking whether an instance of the container (or ALV Grid) exists.

IF gr_alvgrid IS INITIAL.

  • If not, creating and setting ALV for the first display.

  • Creating custom container instance

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gv_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6.

  • Creating ALV Grid instance

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

EXCEPTIONS

error_cntl_create = 1

error_cntl_init = 2

error_cntl_link = 3

error_dp_create = 4

OTHERS = 5.

  • Preparing field catalog.

PERFORM prepare_field_catalog CHANGING gt_fieldcat.

  • Preparing layout structure

PERFORM prepare_layout CHANGING gs_layout.

  • Method to display ALV grid

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = gt_list

it_fieldcatalog = gt_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

ELSE.

  • If an instance of the container (or ALV Grid) exists, refreshing it.

CALL METHOD gr_alvgrid->refresh_table_display

EXCEPTIONS

finished = 1

OTHERS = 2.

ENDIF.

ENDFORM. " create_alv

&----


*& Form prepare_field_catalog

&----


  • Subroutine to populate field catalog

----


  • <--P_GT_FIELDCAT Table to describe the field catalog

----


FORM prepare_field_catalog CHANGING p_gt_fieldcat TYPE lvc_t_fcat.

  • Generating the field catalog semi automatically

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = p_gt_fieldcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

LOOP AT p_gt_fieldcat INTO gs_fcat.

CASE gs_fcat-fieldname.

WHEN 'CARRID'.

gs_fcat-outputlen = '10'.

gs_fcat-coltext = 'Airline Carrier ID'.

MODIFY p_gt_fieldcat FROM gs_fcat.

WHEN 'FLDATE'.

gs_fcat-just = 'C'.

gs_fcat-hotspot = 'X'.

MODIFY p_gt_fieldcat FROM gs_fcat.

ENDCASE.

ENDLOOP.

ENDFORM. " prepare_field_catalog

&----


*& Form prepare_layout

&----


  • Preparing layout structure

----


  • <--P_GS_LAYOUT Layout structure

----


FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo.

p_gs_layout-zebra = 'X' .

p_gs_layout-grid_title = 'Flight Info System'.

p_gs_layout-smalltitle = 'X'.

ENDFORM. " prepare_layout

__________________________________________________________________

<b>Award points if found useful.</b>

Regards

Indrajit

Former Member
0 Kudos

Hi

Refer this

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/4544e790-0201-0010-c29c-e46c389f...

Also, you can use search function in SDN to know the postings related to ALV.

Regards

Raj

Former Member
0 Kudos

hi,

Check these threads..

Hope this helps.

Regards

Alfred

Former Member
0 Kudos

go through alv robot........

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b09ac4d5-e3ad-2910-6a81-96d1b861...

Actually there is no transaction for this.

There is a link wherein u can go, fill in the detials and get the ready ABAP code.

Just copy paste it in SE38 and the program is ready 4 u.

The link is www.ALVROBOT.com.ar.

Former Member
0 Kudos

Hi Prakash,

goto SE80

give the package as SLIS

and expand the <b>Programs</b>

you will get lot many examples on alv