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 with interactive

Former Member
0 Likes
516

Hi All,

I have two internal tables , I am displaying these in single screen using containers(OOPS) and getting the basic list of grid display. Now the qustion is how to display interactive list

can any one send me the sample code.

here I am using GRID->SET_TABLE_FOR_FIRST_DISPLAY

method to display the basic list.

Thanks in advance,

Vijaya

4 REPLIES 4
Read only

Former Member
0 Likes
490

Hi,

Sample Code but for 1 internal table:

&----


*& Report ZSB_EDIT_ALV_OOPS

*&----


REPORT zsb_edit_alv_oops.

INCLUDE zsb_edit_alv_oops_display_po01.

*-- Global data definitions for ALV

*--- ALV Grid instance reference

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

*--- Name of the custom control added on the screen

DATA gc_custom_control_name TYPE scrfname VALUE 'cc_alv'.

*--- Custom container instance reference

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .

*--- Field catalog table

DATA gt_fieldcat TYPE lvc_t_fcat .

*--- Layout structure

DATA gs_layout TYPE lvc_s_layo .

*--- Internal table holding list data

DATA BEGIN OF gt_list OCCURS 0 .

INCLUDE STRUCTURE sflight .

*--In further sections, some additional fields will added here

*--for some functionality

DATA END OF gt_list .

START-OF-SELECTION.

CALL SCREEN 400.

&----


*& Form display_alv

&----


  • Display ALV Grid in container

----


FORM display_alv .

IF gr_alvgrid IS INITIAL .

*----Creating custom container instance

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

OTHERS = 6 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

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

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

*----Preparing field catalog.

PERFORM prepare_field_catalog CHANGING gt_fieldcat .

*----Preparing layout structure

PERFORM prepare_layout CHANGING gs_layout .

*----Here will be additional preparations

*--e.g. initial sorting criteria, initial filtering criteria, excluding

*--functions

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 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ELSE .

CALL METHOD gr_alvgrid->refresh_table_display

  • EXPORTING

  • IS_STABLE =

  • I_SOFT_REFRESH =

EXCEPTIONS

finished = 1

OTHERS = 2 .

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

ENDIF .

ENDFORM . "exclude_tb_functions

&----


*& Form prepare_layout

&----


  • text

----


  • -->PS_LAYOUT text

----


FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.

ps_layout-zebra = 'X' .

ps_layout-grid_title = 'Flights' .

ps_layout-smalltitle = 'X' .

ENDFORM. " prepare_layout

&----


*& Form exclude_tb_functions

&----


  • text

----


  • -->PT_EXCLUDE text

----


FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions .

DATA ls_exclude TYPE ui_func.

ls_exclude = cl_gui_alv_grid=>mc_fc_maximum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_minimum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_subtot .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_sum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_fc_average .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_sum .

APPEND ls_exclude TO pt_exclude.

ls_exclude = cl_gui_alv_grid=>mc_mb_subtot .

ENDFORM . "exclude_tb_functions

*code part 9 – filling the table to exclude unwanted s

&----


*& Form prepare_field_catalog

&----


  • text

----


  • <--P_GT_FIELDCAT text

----


form prepare_field_catalog changing pt_fieldcat TYPE lvc_t_fcat.

DATA ls_fcat TYPE lvc_s_fcat .

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = pt_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

endform. " prepare_field_catalog

Regards,

Sachin Bhatnagar.

Read only

Kanagaraja_L
Active Contributor
0 Likes
490

Hi Vijaya,

Pls check the Standard Program BCALV_GRID_02

Kanagaraja L

Read only

Former Member
0 Likes
490

Hi Thanks,

getting interactive grid display using containers, but at the top of the grid display I need to print heading. how to Print headings at the top of each grid display. Is it possible to print headings? Plz send me some sample code.

vijaya.

Read only

0 Likes
490

Hi

Use the below code extract for printing the header when using ALV with container,

Create a method

top_of_page

FOR EVENT top_of_page OF cl_gui_alv_grid

IMPORTING e_dyndoc_id.

Implement the method

METHOD top_of_page.

  • Top-of-page event

PERFORM event_top_of_page USING gv_dyndoc_id.

ENDMETHOD. "top_of_page

DATA gv_dyndoc_id TYPE REF TO cl_dd_document,

gv_html_cntrl TYPE REF TO cl_gui_html_viewer.

FORM event_top_of_page USING dg_dyndoc_id TYPE REF TO cl_dd_document.

DATA : lv_text(255) TYPE c,

lv_date(10),

lv_width TYPE i.

  • Report Text

IF p_resp = gc_x.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = text-043.

ELSE.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = text-044.

ENDIF.

CALL METHOD dg_dyndoc_id->new_line.

CONCATENATE text-045 p_perio INTO lv_text SEPARATED BY space.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Fiscal Year

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 40.

CONCATENATE text-046 p_gjahr INTO lv_text SEPARATED BY space.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Plan Version

CALL METHOD dg_dyndoc_id->new_line.

lv_text = text-047.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 37.

lv_text = p_versn.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Displaying cost center group

CALL METHOD dg_dyndoc_id->new_line.

lv_text = text-007.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 26.

lv_text = p_kostv.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Displaying cost center

CALL METHOD dg_dyndoc_id->new_line.

lv_text = text-006.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 38.

IF NOT s_kostv-low IS INITIAL AND NOT s_kostv-high IS INITIAL.

CONCATENATE s_kostv-low 'To' s_kostv-high INTO lv_text SEPARATED BY space.

ELSEIF NOT s_kostv-low IS INITIAL AND s_kostv-high IS INITIAL.

lv_text = s_kostv-low.

ELSE.

lv_text = space.

ENDIF.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Displaying Cost element group

CALL METHOD dg_dyndoc_id->new_line.

lv_text = text-009.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 23.

lv_text = p_kstar.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • Displaying Cost element

CALL METHOD dg_dyndoc_id->new_line.

lv_text = text-015.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

IF NOT s_kstar-low IS INITIAL AND NOT s_kstar-high IS INITIAL.

CONCATENATE s_kstar-low 'To' s_kstar-high INTO lv_text SEPARATED BY space.

ELSEIF NOT s_kstar-low IS INITIAL AND s_kstar-high IS INITIAL.

lv_text = s_kstar-low.

ELSE.

lv_text = space.

ENDIF.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 35.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

  • User Name

CALL METHOD dg_dyndoc_id->new_line.

CONCATENATE text-014 sy-uname INTO lv_text SEPARATED BY space.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR lv_text.

CALL METHOD dg_dyndoc_id->add_gap

EXPORTING

width = 33.

  • Report run date

WRITE sy-datum TO lv_date.

CONCATENATE text-013 lv_date INTO lv_text SEPARATED BY space.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text = lv_text.

CLEAR: lv_text, lv_date.

  • Creating html control

CLEAR gv_html_cntrl.

IF gv_html_cntrl IS INITIAL.

CREATE OBJECT gv_html_cntrl EXPORTING parent = gv_parent_top.

ENDIF.

CALL METHOD gv_dyndoc_id->merge_document.

gv_dyndoc_id->html_control = gv_html_cntrl.

  • Display document

CALL METHOD gv_dyndoc_id->display_document

EXPORTING

reuse_control = 'X'

parent = gv_parent_top

EXCEPTIONS

html_display_error = 1.

  • Reward points if helpfull