‎2008 Dec 16 2:24 PM
‎2008 Dec 16 2:27 PM
hi
REUSE_ALV_GRID_DISPLAY
you will be able to display the data
Edited by: sabyasachi kar on Dec 16, 2008 3:28 PM
‎2008 Dec 16 2:34 PM
‎2008 Dec 16 2:40 PM
hi we can use "REUSE_ALV_GRID_DISPLAY"
(OR)
"REUSE_ALV_LIST_DISPLAY"
‎2008 Dec 16 3:01 PM
To build field catalog
data : t_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
t_fieldcat-tabname = <internal table>.
t_fieldcat-fieldname = <field name>.
t_fieldcat-col_pos = <Column position>.
t_fieldcat-seltext_l = <Column heading description>.
APPEND t_fieldcat.
CLEAR t_fieldcat.
Use below function module to display in grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = <report name>
i_grid_title = <title>
it_fieldcat = t_fieldcat[]
i_callback_user_command = w_user_command
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = <final internal table>
EXCEPTIONS
program_error = 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.
Or use below function module to display LIST.
CALL FUNCTION 'RESUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = <report name>
IS_LAYOUT = W_LAYOUT "of TYPE SLIS_LAYOUT_ALV
IT_FIELDCAT = t_fieldcat[]
I_SAVE = 'A'
IT_EVENTS = IN_EVENTS " of TYPE SLIS_T_EVENT
TABLES
T_OUTTAB = <final internal table>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC NE 0.
MESSAGE ENNN .
ENDIF.
‎2008 Dec 17 3:37 AM
Hi Chandra,
You can use this demo code, which includes most of the parameters used to display the data in to ALV Grid.
REPORT z_alv01 MESSAGE-ID zmsg.
*&---------------------------------------------------------------------*
* TABLES
*&---------------------------------------------------------------------*
TABLES : ekpo.
*&---------------------------------------------------------------------*
* TYPE POOLS
*&---------------------------------------------------------------------*
TYPE-POOLS : slis.
*&---------------------------------------------------------------------*
* TYPE DECLARATION
*&---------------------------------------------------------------------*
TYPES : BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
menge TYPE ekpo-menge,
END OF t_ekpo.
*&---------------------------------------------------------------------*
* PARAMETERS
*&---------------------------------------------------------------------*
PARAMETERS : s_var TYPE disvariant-variant.
*&---------------------------------------------------------------------*
* DATA DECLARATION
*&---------------------------------------------------------------------*
*VARIABLES
DATA : check(1),
rep_id TYPE sy-repid.
*INTERNAL TABLE TYPE OF ZEKPO
DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
*FIELD CATALOG
DATA : it_field TYPE slis_t_fieldcat_alv,
wa_field TYPE slis_fieldcat_alv.
*SORTING
DATA : it_sort TYPE slis_t_sortinfo_alv,
wa_sort TYPE slis_sortinfo_alv.
*FOR TOP OF THE PAGE
DATA : it_top TYPE slis_t_listheader,
wa_top TYPE slis_listheader.
*FOR END OF THE PAGE
DATA : it_end TYPE slis_t_listheader,
wa_end TYPE slis_listheader.
*TO CAPTURE EVENTS AND HANDLE
DATA : it_event TYPE slis_t_event,
wa_event TYPE slis_alv_event.
*FOR GRID TITLE
DATA : wa_title TYPE lvc_title.
*FOR LAYOUT
DATA : wa_layout TYPE slis_layout_alv.
*FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
DATA : it_exclude TYPE slis_t_extab,
wa_exclude TYPE slis_extab.
*FOR VARIANT
DATA : wa_variant TYPE disvariant.
*&---------------------------------------------------------------------*
* INITIALIZATION
*&---------------------------------------------------------------------*
INITIALIZATION.
check = 'X'.
rep_id = sy-repid.
wa_variant-report = sy-repid.
*GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = wa_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc = 0. " IF DEFAULT VARIANT FOUND
s_var = wa_variant-variant. " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
ENDIF.
*&---------------------------------------------------------------------*
* AT-SELECTION SCREEN ON VALUE REQUEST
*&---------------------------------------------------------------------*
* TO GET THE F4 HELP FOR VARIANT
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = wa_variant
* I_TABNAME_HEADER =
* I_TABNAME_ITEM =
* IT_DEFAULT_FIELDCAT =
i_save = 'A'
* I_DISPLAY_VIA_GRID = ' '
IMPORTING
* E_EXIT =
es_variant = wa_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
ENDIF.
*&---------------------------------------------------------------------*
* AT-SELECTION SCREEN
*&---------------------------------------------------------------------*
* TO CHECK THE EXISTENCE FOR VARIANT
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN.
wa_variant-variant = s_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = 'A'
CHANGING
cs_variant = wa_variant
EXCEPTIONS
wrong_input = 1
not_found = 2
program_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE w001.
ENDIF.
*&---------------------------------------------------------------------*
* START OF SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
SELECT ebeln
ebelp
matnr
werks
menge
FROM ekpo
INTO TABLE it_ekpo.
*&---------------------------------------------------------------------*
* FIELD CATALOG
*&---------------------------------------------------------------------*
wa_field-fieldname = 'EBELN'. "field name to be used from internal table in Grid
wa_field-tabname = 'IT_TAB'. "internal table from which the data is to be displayed
wa_field-outputlen = 10. "output lenght of the column in the grid display
wa_field-seltext_l = 'PO #'. "text to be printed in the column header in grid
APPEND wa_field TO it_field. "append internal table from work area
CLEAR wa_field. "clear work area
wa_field-fieldname = 'EBELP'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 10.
wa_field-seltext_l = 'Line Item'.
APPEND wa_field TO it_field.
CLEAR wa_field.
wa_field-fieldname = 'MATNR'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 15.
wa_field-seltext_l = 'Material'.
* wa_field-input = check. "to make field open for user input
* wa_field-edit = check. "to make field open for user input
APPEND wa_field TO it_field.
CLEAR wa_field.
wa_field-fieldname = 'WERKS'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 6.
wa_field-seltext_l = 'Plant'.
* wa_field-input = check.
* wa_field-edit = check.
APPEND wa_field TO it_field.
CLEAR wa_field.
wa_field-fieldname = 'MENGE'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 10.
wa_field-seltext_l = 'Qty.'.
* wa_field-input = check.
* wa_field-edit = check.
wa_field-do_sum = check.
APPEND wa_field TO it_field.
CLEAR wa_field.
*&---------------------------------------------------------------------*
* SORT W.R.T. PURCHASE ORDER NUMBER
*&---------------------------------------------------------------------*
wa_sort-spos = 1. "priority of sorting 1(then 2, 3 and so on..)
wa_sort-fieldname = 'EBELN'. "field w.r.t. to the data is to be sorted
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = check. "order of sorting (ascending/descending)
wa_sort-subtot = check. "if you want a sub total for any field based upon new PO#
APPEND wa_sort TO it_sort. "append internal table from work area
CLEAR wa_sort. "clear work area
*&---------------------------------------------------------------------*
* FOR GRID TITLE
*&---------------------------------------------------------------------*
wa_title = 'Hello'.
*&---------------------------------------------------------------------*
* FOR LAYOUT
*&---------------------------------------------------------------------*
wa_layout-zebra = check. "for line to printed in alternative colours in the grid display
*&---------------------------------------------------------------------*
* FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
*&---------------------------------------------------------------------*
wa_exclude-fcode = '&OUP'. "exclude buttons from standard ALV toolbar using std function code
APPEND wa_exclude TO it_exclude.
CLEAR wa_exclude.
wa_exclude-fcode = '&ODN'.
APPEND wa_exclude TO it_exclude.
CLEAR wa_exclude.
wa_exclude-fcode = '&OAD'.
APPEND wa_exclude TO it_exclude.
CLEAR wa_exclude.
wa_exclude-fcode = '&INFO'.
APPEND wa_exclude TO it_exclude.
CLEAR wa_exclude.
*&---------------------------------------------------------------------*
* POPULATE ALL EVENTS INTO INTERNAL TABLE
*&---------------------------------------------------------------------*
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = it_event
EXCEPTIONS
list_type_wrong = 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.
READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
wa_event-form = 'END'.
MODIFY it_event FROM wa_event INDEX sy-tabix.
CLEAR wa_event.
*&---------------------------------------------------------------------*
* DISPLAY RECORDS IN ALV GRID
*&---------------------------------------------------------------------*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = rep_id
* i_callback_pf_status_set = 'PF'
i_callback_user_command = 'COMMAND'
i_callback_top_of_page = 'TOP'
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
i_grid_title = wa_title
* I_GRID_SETTINGS =
is_layout = wa_layout
it_fieldcat = it_field
it_excluding = it_exclude
* IT_SPECIAL_GROUPS =
it_sort = it_sort
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
i_save = 'A'
is_variant = wa_variant
it_events = it_event
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*&---------------------------------------------------------------------*
*& Form top
*&---------------------------------------------------------------------*
* TO WRITE THE HEADER
*----------------------------------------------------------------------*
FORM top.
REFRESH it_top.
wa_top-typ = 'S'.
wa_top-key = text-001.
wa_top-info = rep_id.
APPEND wa_top TO it_top.
CLEAR wa_top.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_top
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM. "top
*&---------------------------------------------------------------------*
*& Form end
*&---------------------------------------------------------------------*
* TO WRITE THE FOOTER
*----------------------------------------------------------------------*
FORM end.
REFRESH it_end.
wa_end-typ = 'S'.
wa_end-key = text-001.
wa_end-info = rep_id.
APPEND wa_end TO it_end.
CLEAR wa_end.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = it_end
* I_LOGO =
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM. "end
*&---------------------------------------------------------------------*
*& Form pf
*&---------------------------------------------------------------------*
* FOR PF-STATUS WITH USER DEFINED BUTTONS
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_PF_ALV'.
ENDFORM. "pf
*&---------------------------------------------------------------------*
*& Form command
*&---------------------------------------------------------------------*
* TO HANDLE USER ACTIONS AGAINST PF-STATUS
*----------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*----------------------------------------------------------------------*
FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
DATA : ok_code TYPE sy-ucomm.
ok_code = ucomm.
CASE ok_code.
WHEN 'T_DOWN'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'HELLO'
txt1 = 'USER COMMAND'
txt2 = 'TOTAL DOWN'.
WHEN 'DOWN'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'HELLO'
txt1 = 'USER COMMAND'
txt2 = 'DOWN'.
WHEN 'UP'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'HELLO'
txt1 = 'USER COMMAND'
txt2 = 'UP'.
WHEN 'T_UP'.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'HELLO'
txt1 = 'USER COMMAND'
txt2 = 'TOTAL UP'.
ENDCASE.
ENDFORM. "command
Hope this solves your problem.
Thanks & Regards
Tarun Gambhir
‎2008 Dec 17 3:51 AM
hi
check the standard programs.
In se38 give BCALV* and press F4.you will get no of demo alv programs
thanks
‎2008 Dec 17 4:36 AM
hi,
REUSE_ALV_FIELDCATALOG_MERGE
This function module is used to populate a field catalog which is essential to display the data in ALV.
REUSE_ALV_LIST_DISPLAY
This is the function module which prints the data
REUSE_ALV_GRID_DISPLAY
A new function from 4.6 version, to display the results in grid rather than a
preview.
REUSE_ALV_COMMENTARY_WRITE
This is used in the Top-of-page event to print the headings and other
comments for the list.
thanks
Sachin
‎2008 Dec 17 4:49 AM
Hi,
I am sure that there are many threads in SDN.Please sreach and post the question.
‎2008 Dec 17 4:56 AM
Hi,
ALV are 3 type .
1.Simple ALV
2.Blocked ALV
3.Hierarchical ALV
For SIMPLE ALV
REUSE_ALV_FIELDCATALOG_MERGE
This function module is used to populate a field catalog which is essential to display the data in ALV.
REUSE_ALV_LIST_DISPLAY
This is the function module which prints the data
REUSE_ALV_GRID_DISPLAY
A new function from 4.6 version, to display the results in grid rather than a
preview.
REUSE_ALV_COMMENTARY_WRITE
This is used in the Top-of-page event to print the headings and other
comments for the list.
‎2008 Dec 17 5:02 AM
Hi
Just check it out in SDN search and you will get a lot of information over there.
Regards
sachin
‎2008 Dec 17 5:05 AM
hi,
by using this function module u can display in grid formatt
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB =
EXCEPTIONS
PROGRAM_ERROR = 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.