10-25-2006 6:29 AM
I WANT TO KNOW ALVS FORM SCRATCH I AM UNABLE TO UNDARDSTAND THE STANDARD ALV PROGRAMS OF ANY BODY HAS ANY MATERIAL PLZ FORWARD ME
10-25-2006 6:32 AM
Hi rakhee,
1. in alv using FM,
there are mainly TWO main fm.
2.
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_LIST_DISPLAY
3. This is the most simple program.
4. just copy paste.
report abc.
*----
TYPE-POOLS : slis.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvfcwa TYPE slis_fieldcat_alv.
*----
data : begin of itab occurs 0.
include structure usr02.
data : end of itab.
*----
START-OF-SELECTION.
select * from usr02
into table itab.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
IMPORTANT
LOOP AT ALVFC INTO ALVFCWA.
IF ALVFCWA-FIELDNAME = 'USTYP'.
ALVFCWA-NO_CONVEXT = 'X'.
MODIFY ALVFC FROM ALVFCWA.
ENDIF.
ENDLOOP.
*----
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
regards,
amit m.
10-25-2006 6:32 AM
Hi rakhee,
1. in alv using FM,
there are mainly TWO main fm.
2.
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_LIST_DISPLAY
3. This is the most simple program.
4. just copy paste.
report abc.
*----
TYPE-POOLS : slis.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : alvfcwa TYPE slis_fieldcat_alv.
*----
data : begin of itab occurs 0.
include structure usr02.
data : end of itab.
*----
START-OF-SELECTION.
select * from usr02
into table itab.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
IMPORTANT
LOOP AT ALVFC INTO ALVFCWA.
IF ALVFCWA-FIELDNAME = 'USTYP'.
ALVFCWA-NO_CONVEXT = 'X'.
MODIFY ALVFC FROM ALVFCWA.
ENDIF.
ENDLOOP.
*----
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
regards,
amit m.
10-25-2006 6:47 AM
Using the OOPS Concepts
Note that this example uses table ZSFLIGHT. The table is equivalent to the table SFLIGHT.
Steps:
Create an executable program (Report)
Create a screen (100) and place a custom container named ALV_CONTAINER on the screen
Create a Pushbutton. Give it the text Exit and the functioncode EXIT
REPORT sapmz_hf_alv_grid .
TABLES: zsflight.
*----
G L O B A L I N T E R N A L T A B L E S
*----
DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
*----
G L O B A L D A T A
*----
DATA: ok_code LIKE sy-ucomm,
g_wa_sflight LIKE sflight.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
*----
S T A R T - O F - S E L E C T I O N.
*----
START-OF-SELECTION.
SET SCREEN '100'.
&----
*& Module USER_COMMAND_0100 INPUT
&----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Form load_data_into_grid
&----
FORM load_data_into_grid.
Read data from table SFLIGHT
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
CHANGING it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid
Regards
- Gopi