2007 Dec 27 6:11 AM
Hi All
In case of ALV reports we can develop using Functions and Classes which is preferred method in Industry.....if i know only using Functions will it fine for the interview.....as i know these functions are built by classes only i am exploring the same ...also suggest some good material on OOPS ABAP
thanx
Puru
Hi All
In case of ALV reports we can develop using Functions and Classes which is preferred method in Industry.....if i know only using Functions will it fine for the interview.....as i know these functions are built by classes only i am exploring the same ...also suggest some good material on OOPS ABAP
thanx
Puru
2007 Dec 27 6:15 AM
most of the companies which are implementing ECC 5.0 and up are trying to put there code in OO... do follow this link
2007 Dec 27 6:18 AM
General Tutorial for OOPS
check all the below links
http://www.sapgenie.com/abap/OO/index.htm
http://www.geocities.com/victorav15/sapr3/abap_ood.html
http://www.brabandt.de/html/abap_oo.html
Check this cool weblog:
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
/people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
http://www.sapgenie.com/abap/OO/
http://www.sapgenie.com/abap/OO/index.htm
http://www.sapgenie.com/abap/controls/index.htm
http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
http://www.sapgenie.com/abap/OO/index.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
http://www.sapgenie.com/abap/OO/
these links
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
For funtion module to class
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
for classes
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
for methods
http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
for inheritance
http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
for interfaces
http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
Check these links.
http://www.henrikfrank.dk/abapuk.html
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
OO ABAP links:
1) http://www.erpgenie.com/sap/abap/OO/index.htm
2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
go through these links
http://www.erpgenie.com/abap/index.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
Please give me reward point If it is useful
2007 Dec 27 6:18 AM
Hi Sir ,
Please have a look below .Hope it is suitable and simpler solution for your question.
Please do reward if useful.
Thankx.
A simpler example for ALV using OOPS concept.Just copy paste and run on ur system.----->
report zakalv_oops.
data: it_mara type standard table of mara.
data : container type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
data: ok_code like sy-ucomm,
g_repid like sy-repid.
data: x_save, "for Parameter I_SAVE
gs_layout type disvariant. "for parameter IS_VARIANT
parameters: p_def default 'X' as checkbox. "set: default layout allowed
selection-screen begin of block vari with frame title text-002.
parameters: save_u radiobutton group save,
save_x radiobutton group save,
save_a radiobutton group save,
save_n radiobutton group save.
selection-screen end of block vari.
start-of-selection.
select * from mara into table it_mara up to 10 rows.
end-of-selection.
clear gs_layout.
'gs_layout' must at least contain the report-id to allow
saving a layout.
g_repid = sy-repid.
§ 2.At least field REPORT of this structure has to be filled!
gs_layout-report = g_repid.
§ 3.Determine saving options.
if save_a = 'X'.
x_save = 'A'. "The user may save all types of a layout
endif.
if save_x = 'X'.
x_save = 'X'. "a layout can only be saved as spanned one ('global')
endif.
if save_n = 'X'.
x_save = space. "no saving of a layout possible!
endif.
if save_u = 'X'.
x_save = 'U'. "a layout can only be saved as user specific one
endif.
call screen 100.
*----
*
MODULE pbo_100 OUTPUT
*----
*
*
*----
*
module pbo_100 output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
if container is initial.
create object container
exporting
PARENT =
container_name = 'CONTAINER'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(510).
endif.
create object grid
exporting
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = container
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
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 method grid->set_table_for_first_display
exporting
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
i_structure_name = 'MARA'
is_variant = gs_layout
i_save = x_save
i_default = p_def
IS_LAYOUT =
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
changing
it_outtab = it_mara
IT_FIELDCATALOG =
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endif.
endmodule. "pbo_100 OUTPUT
*----
*
MODULE user_command_0100 INPUT
*----
*
*
*----
*
module pai_100 input.
case ok_code.
when 'TO_EXIT'.
perform exit_program.
endcase.
clear ok_code.
endmodule. "PAI_100 INPUT
*&----
*
*& Form exit_program
*&----
*
text
*----
*
form exit_program.
call method container->free.
leave program.
leave to screen 0.
endform. "exit_program
LINKS----
-
Check this for basic concepts of OOPS
General Tutorial for OOPS
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
http://www.sap-img.com/abap/what-is-alv-programming.htm
http://www.sap-img.com/abap-function.htm
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sapdevelopment.co.uk/reporting/alv/alvtree%5Calvtree_basic.htm
http://esnips.com/doc/ad20dca9-6182-4903-8d8f-96a66dc8590c/ALV.pdf
2007 Dec 27 6:19 AM
Hi Purushottam,
It helps to some extent as You know how to call a method just like a function module in the ALV reports.
Regards,
Hk
2007 Dec 27 6:24 AM
Hi,
OOABAP is more poweful in sap. Most of them are asking about this topic. so we should aware of this one. and also it is better to use in reports, y because it has more advanced options than normal function modules.
by using this classes we can resue it any where.
badi, reports, and all related with ooabap.
please reward points, if this information needed to u.
regards
pandu
2007 Dec 27 6:24 AM
Hi Puru,
We can develop ALV reports using both the Functions Module and classes.Nows a days more focus is going on the use of classes as now it increase the reusability of code and many more features.
Check this [http://www.geocities.com/mpioud/Abap_programs.html]
It will give you an idea of developing the ALV report using Function Module.
For using the Classes I am posting to sample example .
Please check it..
it all depends on the class you are using .
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 |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |