2007 Apr 22 6:57 AM
Hello Friends,
Can anybody help me in finding out the difference between ALV Function Modules and ALV methods?
Thanks & Regards
Sathish Kumar
Hello Friends,
Can anybody help me in finding out the difference between ALV Function Modules and ALV methods?
Thanks & Regards
Sathish Kumar
2007 Apr 22 9:07 AM
Do you want to say boject oriented ALV by alv methods???
In that case,
1. OO ALv uses classes and its methods where as function module alv uses several function module.
2. In OO ALV you have to create a screen and a container on thet screen. In
function module alv, you can create without screen.
3. There are several function ( such add a button ) is possible in OO ALV very easity. That can not be created in functional module alv.
Ex of object oriented ALV :
REPORT zdemoab.
************************************
*DATA DECLARATION
*************************************
*---Global data deckaration for alv
*--ALV Grid instance referance
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
*--Name of the custom control added to the screen
gc_custom_control_name TYPE scrfname VALUE 'CUSTOM_CONTROL',
*--Custom container instance referance
gr_container TYPE REF TO cl_gui_custom_container,
*--Field catalog table
gt_fieldcat TYPE lvc_t_fcat,
*--Layout structure
gs_layout TYPE lvc_s_layo.
DATA: ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm.
*---Input table
TYPES: BEGIN OF t_mara,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
meins TYPE mara-meins,
END OF t_mara.
TYPES: t_mara_table TYPE STANDARD TABLE OF t_mara.
DATA: gt_mara TYPE STANDARD TABLE OF t_mara.
************************************
*MAIN
*************************************
CALL SCREEN 101.
*&---------------------------------------------------------------------*
*& Module STATUS_0101 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0101 OUTPUT.
SET PF-STATUS 'STATUS-0101'.
SET TITLEBAR 'TITLE'.
ENDMODULE. " STATUS_0101 OUTPUT
*&---------------------------------------------------------------------*
*& Module display_alv OUTPUT
*&---------------------------------------------------------------------*
MODULE display_alv OUTPUT.
IF gr_alvgrid IS INITIAL.
*----Create custom container instance
CREATE OBJECT gr_container
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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*----Create ALV grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_container
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.
* select the material data from database
PERFORM get_input CHANGING gt_mara..
* prepare field catalog
PERFORM prepare_fieldcatalog CHANGING gt_fieldcat.
* prepare layout
PERFORM prepare_layout CHANGING gs_layout.
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gt_mara[]
it_fieldcatalog = gt_fieldcat
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.
ELSE.
CALL METHOD gr_alvgrid->refresh_table_display
EXCEPTIONS
finished = 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.
ENDIF.
ENDMODULE. " display_alv OUTPUT
*&---------------------------------------------------------------------*
*& Form get_input
*&---------------------------------------------------------------------*
FORM get_input CHANGING gt_mara_table TYPE t_mara_table.
SELECT matnr mtart matkl meins INTO TABLE gt_mara_table
FROM mara UP TO 10 ROWS.
ENDFORM. " get_input
*&---------------------------------------------------------------------*
*& Form prepare_fieldcatalog
*&---------------------------------------------------------------------*
FORM prepare_fieldcatalog CHANGING gt_fieldcat_table TYPE lvc_t_fcat.
DATA: ls_fcat TYPE lvc_s_fcat,
l_col_no TYPE i.
CLEAR: ls_fcat,
l_col_no .
l_col_no = l_col_no + 1.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'MARA'.
ls_fcat-col_pos = l_col_no.
ls_fcat-outputlen = 18.
ls_fcat-coltext = 'Material No'.
ls_fcat-seltext = 'Material No'.
APPEND ls_fcat TO gt_fieldcat_table.
l_col_no = l_col_no + 1.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'MARA'.
ls_fcat-col_pos = l_col_no.
ls_fcat-outputlen = 4.
ls_fcat-coltext = 'Material type'.
ls_fcat-seltext = 'Material type'.
APPEND ls_fcat TO gt_fieldcat_table.
l_col_no = l_col_no + 1.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'MARA'.
ls_fcat-col_pos = l_col_no.
ls_fcat-outputlen = 9.
ls_fcat-coltext = 'Material group'.
ls_fcat-seltext = 'Material group'.
APPEND ls_fcat TO gt_fieldcat_table.
l_col_no = l_col_no + 1.
ls_fcat-fieldname = 'MEINS'.
ls_fcat-ref_table = 'MARA'.
ls_fcat-col_pos = l_col_no.
ls_fcat-outputlen = 3.
ls_fcat-coltext = 'Unit'.
ls_fcat-seltext = 'Unit'.
APPEND ls_fcat TO gt_fieldcat_table.
CLEAR: ls_fcat,
l_col_no .
ENDFORM. " prepare_fieldcatalog
*&---------------------------------------------------------------------*
*& Form prepare_layout
*&---------------------------------------------------------------------*
FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo.
p_gs_layout-zebra = 'X'.
p_gs_layout-grid_title = 'Material'.
p_gs_layout-smalltitle = 'X'.
ENDFORM. " prepare_layout
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0101 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0101 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'EXIT'.
PERFORM exit_program.
ENDCASE.
ENDMODULE. " USER_COMMAND_0101 INPUT
*&---------------------------------------------------------------------*
*& Form exit_program
*&---------------------------------------------------------------------*
FORM exit_program .
LEAVE PROGRAM.
ENDFORM. " exit_program<b>Steps :</b>
1. Call a screen.
2. Go to the screen layout and add a custom control .
3. Go to attribute and give a name to the custom control (Ex: 'CUSTOM_CONTROL').
4. Give a name to the ok_code ( Ex: ok_code) in the attribute of the screen.
5. Data Declaration section:
I. Data declaration for ALV
a. Declare a object type cl_gui_alv_grid for ALV Grid instance referance
b. Declare a object type cl_gui_custom_container for Custom container instance referance
c. Declare Name of the custom control added to the screen
d. Declare field catalog table of type lvc_t_fcat.
e. Declare layout of type lvc_s_layo.
II. Data declaration for fetching data as input
III. Declare variables for ok_code.
6. Set pf-status and titlebar for the screen.
7. Write PBO. IN PBO do the following:
i. Check whether gr_alvgrid is initial.
a. If yes do the following.
Create instance for custom container (gr_container) by passing the container name.
Create instance for ALV grid by passing the custom control instance reference.
select the material data from database
Build field ctalog
Build layout
Call method set_table_for_first_display for the object gr_alvgrid(alv grid instance reference) with passing layout, input table and field catalog.
b. If NO do the following.
Call method refresh_table_display for the object gr_alvgrid(alv grid instance reference).
ii.
8. Write PAI. IN PAI do the following:
Check the ok_code, if Exit then leave from program.
All the user commands where user do any actions in the screen will be code here . For this purpose check the value of ok_code and according that ok_code, code the functionality for the particular user actions.
2007 Apr 23 7:00 AM
ALV using FM generates a window by itself and displays data in it.
As the name says ..it uses FM approach.
OO ALV works on methods. A container object has to be created and needs to associated with ALV instance in OO Approach.
Refer to the following link for more details.
2007 Apr 23 7:06 AM
Hi Sathish,
Plz go through this info. It is very useful.
hi,
chk these excellent links.
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Go thru these programs they may help u to try on some hands on
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
OOPs:
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
Rewords some points if it is helpful.
Rgds,
P.Naganjana Reddy
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |