2006 Dec 11 5:02 PM
hi,
can any one help me to understand with a sample code of ALV grid in ABAP OBJECTS.
i would appreciate all ur answers.
thanks,
ganesh
hi,
can any one help me to understand with a sample code of ALV grid in ABAP OBJECTS.
i would appreciate all ur answers.
thanks,
ganesh
2006 Dec 11 5:04 PM
2006 Dec 11 5:04 PM
2006 Dec 11 5:06 PM
2006 Dec 11 5:08 PM
2006 Dec 11 7:30 PM
Hi,
The general procedure is as explained below...
SAP has provided different controls catering needs of various applications. One such control is ALV Grid Control.
A control as such cannot be called directly for output display. A control should be attached to a Container. SAP provided different types of containers namely CUstom Container, Split Container, Dialog COntainer etc....
The attributes of the container can be accessed by instantiating the Container class. For our purpose consider the CUSTOM CONTAINER. The custom container class is CL_GUI_CUSTOM_CONTAINER
The attributes and methods of ALV Grid can be accessed by instantiating the Grid Class CL_GUI_ALV_GRID.
After assigning the grid to the container, Field catalog for the output is prepared. Display method of Gird Control is called to display the output.
Check the below code... This is SAP standard program
<b>start-of-selection.</b>
select * from sflight into table gt_sflight up to g_max rows.
*
<b>end-of-selection.</b>
g_repid = sy-repid.
call screen 100.
----
MODULE PBO OUTPUT *
----
module pbo output.
<b>* Set the PF Status</b>
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
<b>* Create a Custom Area in SAP Screen. If the Custom container is initial then instantiate the Container class</b>
if custom_container is initial.
<b>* create a custom container control for our ALV Control</b>
create object custom_container
exporting
container_name = mycontainer
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
<b>* add your handling, for example</b>
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(010).
endif.
<b>* Instantiate the GRid Class. create an instance of alv control</b>
create object grid1
exporting i_parent = custom_container.
*
Set a titlebar for the grid control
*
gs_layout-grid_title = 'Flights'(100).
<b>* Build the field catalog for output display</b>
call method grid1->set_table_for_first_display
exporting i_structure_name = 'SFLIGHT'
changing IT_FIELDCATALOG = gt_fldcat
it_outtab = gt_sflight.
endif.
<b>* Controls are not integrated into the TAB-Order
Call "set_focus" if you want to make sure that 'the cursor'
is active in your control.</b>
call method cl_gui_control=>set_focus exporting control = grid1.
Control Framework flushes at the end of PBO automatically!
endmodule.
----
MODULE PAI INPUT *
----
module pai input.
case ok_code.
when 'EXIT'.
perform exit_program.
endcase.
clear ok_code.
endmodule.
----
FORM EXIT_PROGRAM *
----
form exit_program.
call method custom_container->free.
call method cl_gui_cfw=>flush.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(009).
endif.
leave program.
endform.
For other examples,
check these 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
Regards,
Vara
2006 Dec 12 9:56 AM
If you are on at least WAS 640 you can use class CL_SALV_TABLE.
It is very very simple.
For example, this few lines creates an ALV output:
data: gt_outtab type table of SFLIGHT.
data: gr_table type ref to cl_salv_table.
*... Select data
select * from SFLIGHT into corresponding fields of table gt_outtab.
*... Create Instance
call method cl_salv_table=>factory
IMPORTING
R_SALV_TABLE = gr_table
changing
t_table = gt_outtab.
*... Display table
gr_table->display( ).
However, check programs that starts with SALV_*
Hope this helps,
Roby.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |