‎2006 Feb 06 5:37 PM
Hello guys,
I want to display 2 ALV grids on the same screen one below another with headings. Can some1 throw light how to do that??
Thanks,
‎2006 Feb 06 5:39 PM
‎2006 Feb 06 5:39 PM
‎2006 Feb 06 5:42 PM
For example, implement this sample program. Create the screen 100, put two containers on the screen. Call the first one 'ALV_CONTAINER' and the second 'ALV_CONTAINER2'. Create the gui status with the BACK button. Now click on a record of the first grid, the second grid will be populated.
report zrich_0006.
tables: mara.
type-pools: slis.
* Internal Tables
data: begin of ialv occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of ialv .
* Internal Tables
data: begin of ialv2 occurs 0,
matnr type mard-matnr,
werks type mard-werks,
lgort type mard-lgort,
end of ialv2 .
***********************************************************************
* CLASS lcl_event_receiver DEFINITION Handles Double Click
***********************************************************************
class lcl_event_receiver definition.
public section.
methods handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing e_row_id.
private section.
endclass.
***********************************************************************
* CLASS lCL_EVENT_RECEIVER IMPLEMENTATION Handles Double Click
***********************************************************************
class lcl_event_receiver implementation.
method handle_hotspot_click.
perform get_details using e_row_id-index.
endmethod.
endclass.
data: alv_container type ref to cl_gui_custom_container,
event_receiver type ref to lcl_event_receiver,
alv_grid type ref to cl_gui_alv_grid,
alv_container2 type ref to cl_gui_custom_container,
alv_grid2 type ref to cl_gui_alv_grid,
ok_code like sy-ucomm,
fieldcat type lvc_t_fcat,
fieldcat2 type lvc_t_fcat.
select-options: s_matnr for mara-matnr.
start-of-selection.
perform get_data.
call screen 100.
************************************************************************
* Module status_0100 OUTPUT
************************************************************************
module status_0100 output.
data: variant type disvariant.
data: lt_exclude type ui_functions.
data: ls_fcat type lvc_s_fcat.
set pf-status '0100'.
set titlebar '0100'.
check alv_container is initial.
*** Code for first ALV Grid
* Create Controls
create object alv_container
exporting container_name = 'ALV_CONTAINER'.
create object alv_grid
exporting i_parent = alv_container.
* create Event Receiver
create object event_receiver.
clear fieldcat. refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'IALV'.
ls_fcat-hotspot = 'X'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-coltext = 'Material Description'.
ls_fcat-fieldname = 'MATKX'.
ls_fcat-ref_table = 'IALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat.
call method alv_grid->set_table_for_first_display
changing
it_outtab = ialv[]
it_fieldcatalog = fieldcat[].
* handler for ALV grid
set handler event_receiver->handle_hotspot_click for alv_grid.
*** Code for second ALV Grid
* Create Controls
create object alv_container2
exporting container_name = 'ALV_CONTAINER2'.
* create Event Receiver
create object alv_grid2
exporting i_parent = alv_container2.
clear fieldcat. refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'IALV2'.
ls_fcat-outputlen = '18'.
append ls_fcat to fieldcat2.
clear: ls_fcat.
ls_fcat-reptext = 'Plant'.
ls_fcat-coltext = 'Plant'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'IALV2'.
ls_fcat-outputlen = '4'.
append ls_fcat to fieldcat2.
clear: ls_fcat.
ls_fcat-reptext = 'Store Loc'.
ls_fcat-coltext = 'Store Loc'.
ls_fcat-fieldname = 'LGORT'.
ls_fcat-ref_table = 'IALV2'.
ls_fcat-outputlen = '4'.
append ls_fcat to fieldcat2.
call method alv_grid2->set_table_for_first_display
changing
it_outtab = ialv2[]
it_fieldcatalog = fieldcat2[].
endmodule.
************************************************************************
* Module USER_COMMAND_0100 INPUT
************************************************************************
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
if not alv_container2 is initial.
call method alv_container2->free.
clear: alv_container2.
free : alv_container2.
endif.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
endcase.
endmodule.
*********************************************************************
* FORM GET_DATA.
*********************************************************************
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table ialv
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
sort ialv ascending by matnr.
endform.
*********************************************************************
* FORM GET_MORE_DATA.
*********************************************************************
form get_more_data.
select matnr werks lgort
into corresponding fields of table ialv2
from mard
where matnr = ialv-matnr.
sort ialv2 ascending by matnr.
endform.
************************************************************************
* GET_DETAILS
************************************************************************
form get_details using index.
read table ialv index index.
if sy-subrc = 0.
perform get_more_data.
call method alv_grid2->refresh_table_display.
endif.
endform.
REgards,
Rich Heilman
‎2006 Feb 06 5:59 PM
Hi,
Check this Demo program <b>BCALV_TEST_GRID_DRAG_DROP</b>
regards
vijay
‎2006 Feb 07 5:45 AM
Hi,
You can check with demo program BALVBT01 for multiple ALV display.
regards,
sunil.
‎2006 Feb 07 5:50 AM
Hi naren,
1. ALV LIST
or
ALV Grid ?
2. If list is required, then
its quite simple.
U have to use the concept of
BLOCK ALV (there are 2 FMS for it - thats all)
3. If grid is required,
then ofcourse,
two containers are required.
4. If u require alv list,
then pls clarify so that
the FMS details can be provided.
regards,
amit m.
‎2006 Feb 07 5:52 AM
use block alv ...
if u want to display one alv grid bellow another......
example code....
REPORT zanid_test MESSAGE-ID zz.
*
----
Declarations for BLOCK ALV DISPLAY
----
*--type pools
TYPE-POOLS:slis.
DATA:x_layout TYPE slis_layout_alv,
t_field TYPE slis_t_fieldcat_alv,
*--field catalog
x_fldcat LIKE LINE OF t_field,
*--to hold all the events
t_events TYPE slis_t_event,
x_events TYPE slis_alv_event,
t_sort TYPE slis_t_sortinfo_alv,
x_sort LIKE LINE OF t_sort ,
*--Print Layout
x_print_layout TYPE slis_print_alv.
*----Macro to add field catalog.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
DEFINE add_catalog.
clear x_fldcat.
x_fldcat-fieldname = &1.
x_fldcat-seltext_m = &2.
x_fldcat-outputlen = &3.
x_fldcat-tech = &4.
x_fldcat-col_pos = &5.
x_fldcat-no_zero = 'X'.
x_fldcat-ddictxt = 'M'.
x_fldcat-datatype = &6.
x_fldcat-ddic_outputlen = &7.
if &6 = 'N'.
x_fldcat-lzero = 'X'.
endif.
*--build field catalog
append x_fldcat to t_field.
END-OF-DEFINITION.
*----- data declerations.
data: v_repid like sy-repid.
data: begin of itab occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
meins like mara-meins,
end of itab.
data: begin of jtab occurs 0,
matnr like makt-matnr,
maktx like makt-maktx,
end of jtab.
select matnr ernam meins
up to 20 rows
from mara
into table itab.
select matnr maktx
up to 20 rows
from makt
into table jtab.
v_repid = sy-repid.
*DISPLAY alv
Initialize Block
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = v_repid.
*Block 1:
*INITIALIZE
refresh t_field. clear t_field.
refresh t_events.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
add_catalog:
'MATNR' 'Material' '18' '' '1' 'C' '18',
'ERNAM' 'Created By' '12' '' '2' 'C' '12',
'MEINS' 'Unit' '5' '' '3' 'C' '3'.
*--build table for events.
x_events-form = 'TOP_OF_LIST1'.
x_events-name = slis_ev_top_of_list.
append x_events to t_events.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'ITAB'
it_events = t_events
it_sort = t_sort
tables
t_outtab = itab
exceptions
program_error = 1
maximum_of_appends_reached = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*--BLOCK 2(SUMMARY REPORT)
*INITIALIZE
refresh t_field. clear t_field.
refresh t_events.
*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN
add_catalog:
'MATNR' 'Material' '20' '' '1' 'C' '18',
'MAKTX' 'Description' '40' '' '2' 'C' '40'.
*--build table for events.
x_events-form = 'TOP_OF_LIST2'.
x_events-name = slis_ev_top_of_list.
append x_events to t_events.
Append table block.
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = x_layout
it_fieldcat = t_field
i_tabname = 'JTAB'
it_events = t_events
tables
t_outtab = jtab
exceptions
program_error = 1
maximum_of_appends_reached = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*--CALL FM TO DISPLAY THE BLOCK REPORT.
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
exporting
is_print = x_print_layout
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.
form top_of_list1.
skip 1.
write: 10 'List 1',
/5 '----
'.
skip 1.
format reset.
endform.
form top_of_list2.
skip 1.
write: 10 'List 2',
/5 '----
'.
skip 1.
format reset.
endform.
Message was edited by: kishan negi
‎2006 Feb 07 6:07 AM
Multiple ALV list display
The SAP program BALVBT01 provides an example of displying multiple ALV LIST reports on one page.
U can also place two containers on the screen if u want a grid display. First try to display data in one grid and then repeat the same code for the other too.
Hope this helps.
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
Kindly reward points for those who helped to solve ur problem and close the thread.