08-21-2007 6:17 AM
Hi friends,
If i want to create a simple report in alv through objects i have to create a screen and gui status to show the output utilizing the class cl_gui_alv_grid.
Is there any alternative i can avoid creating screen and gui status and show the output in selection screen.
Regards,
Praveen Lobo
08-21-2007 6:35 AM
hi praveen
jut go through these sample programs
ALV related Sample programs:
BCALV_GRID_01
BCALV_GRID_02
BCALV_GRID_03
BCALV_GRID_04
BCALV_GRID_05
BCALV_GRID_06
BCALV_GRID_07
BCALV_GRID_08
BCALV_GRID_09
BCALV_GRID_10
BCALV_GRID_11
BCALV_GRID_AND_POPUP
BCALV_GRID_DEMO
regards
nagaraju.m
08-21-2007 10:49 AM
mr nagaraju this is nageswarrao from AP i need ur mail id my id is pnr_sap@yahoo.co.in
08-23-2007 9:54 AM
08-21-2007 6:38 AM
Hi Praveen
chk these pro's in sap
BCALV*
reward points to all helpful answers
kiran.M
08-21-2007 11:31 AM
Hello Praveen
In order to display OO-based ALV lists (class CL_GUI_ALV_GRID) you <u>must </u>have a screen (<> selection screen) in your report. For simplified examples search the <i>ABAP Objects</i> forum for <b>ZUS_SDN</b>.
Alternatively, if you have already the new ALV object model (<b>CL_SALV_TABLE</b>) available in your SAP system then you do not need a screen. For an example see report <b>ZUS_SDN_CL_SALV_TABLE_COLUMN</b> in thread
Regards
Uwe
08-21-2007 9:16 PM
Praveen,
Try this code that I found previously on this forum. I don't remember who posted it.
*
selection-screen begin of screen 1001.
selection-screen end of screen 1001.
*
data: l_alv type ref to cl_gui_alv_grid.
*
Creation of the ALV object, when we use cl_gui_container=>screen0 as
parent, the ALVGrid control will automatically use the full screen to
display the grid, NO CONTAINER DEFINITION IS REQUIRED !
*
create object l_alv exporting i_parent = cl_gui_container=>screen0.
*
calling the display of the grid, the system will automatically create
the fieldcatalog based on the (table/structure) passed in parameter
*
call method l_alv->set_table_for_first_display
exporting
i_structure_name = 'ZALV_ZFAPI014' " ALV structure for this program
i_bypassing_buffer = 'X'
changing
it_outtab = i_alv. " table of type ZALV_ZFAPI014
*
You have to create an EMPTY screen, put NOTHING in the layout
*
call selection-screen 1001.
Bruce
08-21-2007 9:23 PM
Not sure if Bruces example is complete or not, but here is another which I found in my bag of tricks.
report zrich_0001.
* Used to limit user commands on selection-screen
include rsdbc1xx.
data: begin of i_alv occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of i_alv.
data: alv_grid type ref to cl_gui_alv_grid.
data: fieldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for i_alv-matnr.
selection-screen end of block b1.
selection-screen begin of screen 1010.
selection-screen end of screen 1010.
* Events
at selection-screen output.
if sy-dynnr = '1010'.
current_scr-mode = 'S'.
append 'SPOS' to current_scr-excl.
append 'SCRH' to current_scr-excl.
append 'ONLI' to current_scr-excl.
endif.
start-of-selection.
perform get_data.
create object alv_grid
exporting
i_parent = cl_gui_container=>screen0.
* Populate Field Catalog
perform get_fieldcatalog.
call method alv_grid->set_table_for_first_display
changing
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
call selection-screen 1010.
************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.
select * into corresponding fields of table i_alv
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
sort i_alv ascending by matnr.
endform.
************************************************************************
* Form Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.
data: ls_fcat type lvc_s_fcat.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
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 = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat.
endform.
Of course, I must recommend that you use the new ALV Object Model as Uwe has suggested. If you are on a NetWeaver release, then it is available to you.
Regards,
RIch Heilman
08-23-2007 5:53 AM
Thanks for the valuable answers.
Points awarded.
Regards,
Praveen Lobo