2007 Dec 20 9:59 AM
Plz send me simple code that will display ALV grid list as an output using object oriented concept.
Plz send me simple code that will display ALV grid list as an output using object oriented concept.
2007 Dec 20 10:01 AM
Hi,
Goto SE38 give BCALV* n press F4 it will display the list of all standard ALV OOps programs Refer that.
Regards,
Prashant
2007 Dec 20 10:01 AM
Hi sandeep,
Have a look at std program BCALV_TEST_GRID. Also look at programs under package SLIS.
Hope this helps.
Thanks
Lakshman
2007 Dec 26 7:41 AM
Hi friends;
I tried one ALV Report Program.,Based on the input ,various storage location value will be dispalyed...
example : i will(statically) generate 30 output fields using filed catalog .
based on input, in 30 fields
some of the fields the value will be dispalyed..
remains the fields the value will be un filled.
i want to generate the fields dynamically, only the fields having values....
i searching the document in net ,using field symbol it may possible... but i not having idea in field symbol....
PLZ help me....
my mail id
Best regards
K.S.Kannan.
2007 Dec 20 10:04 AM
Hi Sandeep,
http://help.sap.com/saphelp_nw04/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
Check this Shortest Program to display the ALV GRID using class
BCALV_GRID_DEMO
******************************
Check these links.
Check this for basic concepts of OOPS
Tabstrip
Editable ALV
Tree
http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_usrint.htm
General Tutorial for OOPS
standard pgms
ABAP_OBJECTS_ENJOY_0 Template for Solutions of ABAP Object Enjoy Course
ABAP_OBJECTS_ENJOY_1 Model Solution 1: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_2 Model Solution 2: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_3 Model Solution 3: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_4 Model Solution 4: ABAP Objects Enjoy Course
ABAP_OBJECTS_ENJOY_5 Model Solution 5: ABAP Objects Enjoy Course
DEMO_ABAP_OBJECTS Complete Demonstration for ABAP Objects
DEMO_ABAP_OBJECTS_CONTROLS GUI Controls on Screen
DEMO_ABAP_OBJECTS_EVENTS Demonstration of Events in ABAP Objects
DEMO_ABAP_OBJECTS_GENERAL ABAP Objects Demonstration
DEMO_ABAP_OBJECTS_INTERFACES Demonstration of Interfaces in ABAP Objects
DEMO_ABAP_OBJECTS_METHODS Demonstration of Methods in ABAP Objects
DEMO_ABAP_OBJECTS_SPLIT_SCREEN Splitter Control on Screen
some helful links.
Go through the below links,
For Materials:
1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
😎 http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Kindly Reward Points If You Find The Reply Helpful.
Cheers,
Chaitanya.
2007 Dec 20 10:11 AM
hi
good
go to se38
put BCALV* and press F4,
You ll get lots of reports related to OO ALV, Pls go through them , it ll help y ou a lot .
check this link for a sample program
http://abapprogramming.blogspot.com/2007/11/alv-list-using-oo-style-sample-code.html
thanks
mrutyun^
Edited by: Mrutyunjaya Tripathy on Dec 20, 2007 3:42 PM
2007 Dec 20 11:14 AM
Hi Sandeep,
Check these code.here i am sending two programs.
If you are using the class cl_gui_alv_grid then you have to create a screen that containing the custom container.
If you are using the class cl_salv_table then don't need to define any custom container for getting the ALV grid.
Here I am copying the Example of both the classes .
Now its all depends upon you which class you prefer to use.
Example 1 : cl_gui_alv_grid
*
o
+ Global data definitions for ALV
ALV Grid instance reference
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .
*
o
+
Name of the custom control added on the screen
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV' .
*
o
+
Custom container instance reference
DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .
*
o
+
Field catalog table
DATA gt_fieldcat TYPE lvc_t_fcat .
*
o
+
Layout structure
DATA gs_layout TYPE lvc_s_layo .
*
o
+
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 .
DATA :gt_sflight like standard TABLE OF gt_list.
START-OF-SELECTION.
CALL SCREEN '0400'.
&----
*& Module STATUS_0400 OUTPUT
&----
text
-
MODULE STATUS_0400 OUTPUT.
SET PF-STATUS 'ZMNU'.
perform display_alv.
ENDMODULE. " STATUS_0400 OUTPUT
&----
*& Module USER_COMMAND_0400 INPUT
&----
text
-
MODULE USER_COMMAND_0400 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR 'EXIT' OR 'RW'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0400 INPUT
&----
*& Form display_alv
&----
text
-
form display_alv.
SELECT * FROM SFLIGHT INTO TABLE GT_SFLIGHT UP TO 30 ROWS.
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
I_STRUCTURE_NAME = 'SFLIGHT'
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
is_layout = gs_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
CHANGING
it_outtab = gt_sflight[]
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. "display_alv
&----
*& Form prepare_field_catalog
&----
text
-
-->PT_FIELDCATtext
-
FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat .
*---Preparing field catalog manually
*DATA ls_fcat type lvc_s_fcat .
*ls_fcat-fieldname = 'CARRID' .
*ls_fcat-inttype = 'C' .
*ls_fcat-outputlen = '3' .
*ls_fcat-coltext = 'Carrier ID' .
*ls_fcat-seltext = 'Carrier ID' .
*ls_fcat-drdn_hndl = '1' .
*APPEND ls_fcat to pt_fieldcat .
*CLEAR ls_fcat .
*ls_fcat-fieldname = 'CONNID' .
*ls_fcat-ref_table = 'SFLIGHT' .
*ls_fcat-ref_table = 'CONNID' .
*ls_fcat-outputlen = '3' .
*ls_fcat-coltext = 'Connection ID' .
*ls_fcat-seltext = 'Connection ID' .
*APPEND ls_fcat to pt_fieldcat .
*---Preparing field catalog semi-automatically
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.
LOOP AT pt_fieldcat INTO ls_fcat .
CASE ls_fcat-fieldname .
WHEN 'CARRID' .
ls_fcat-outputlen = '10' .
ls_fcat-coltext = 'Airline Carrier ID' .
ls_fcat-drdn_hndl = '1' .
MODIFY pt_fieldcat FROM ls_fcat .
WHEN 'PAYMENTSUM' .
ls_fcat-no_out = 'X' .
MODIFY pt_fieldcat FROM ls_fcat .
ENDCASE .
ENDLOOP .
ENDFORM . "prepare_field_catalog
&----
*& 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
Example 2: cl_salv_table
data: gt_outtab type table of sflight.
data: toolbar type ref to cl_salv_functions_list .
data: gr_table type ref to cl_salv_table.
data: lr_aggregations type ref to cl_salv_aggregations.
data: lr_groups type ref to cl_salv_sorts .
select * from sflight into corresponding fields of table gt_outtab.
call method cl_salv_table=>factory
importing
r_salv_table = gr_table
changing
t_table = gt_outtab.
lr_aggregations = gr_table->get_aggregations( ).
toolbar = gr_table->get_functions( ) .
toolbar->set_all(
value = if_salv_c_bool_sap=>true
).
lr_aggregations->clear( ).
lr_groups = gr_table->get_sorts( ) .
lr_groups->clear( ).
try.
lr_groups->add_sort(
columnname = 'CARRID'
position = 8
subtotal = abap_true
sequence = if_salv_c_sort=>sort_up ).
catch cx_salv_not_found cx_salv_data_error cx_salv_existing.
endtry.
try.
lr_aggregations->add_aggregation( columnname = 'SEATSMAX' ).
catch cx_salv_not_found cx_salv_data_error cx_salv_existing.
endtry.
gr_table->display( ).
Reward points, if useful.
Regards,
Manoj Kumar
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |