2009 Jan 27 1:49 PM
Hi Abaper's
I have data that is stored in an internal table and I want to display it in an ALV report, How can I achieve this?
Thanx in advance
Thandie
2009 Jan 27 1:54 PM
Hi,
Try to run the following code you will find the Ans.
*&---------------------------------------------------------------------*
TABLES : ekpo.
*&---------------------------------------------------------------------*
TYPE-POOLS : slis.
*&---------------------------------------------------------------------*
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.
*&---------------------------------------------------------------------*
*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.
*&---------------------------------------------------------------------*
INITIALIZATION.
check = 'X'.
rep_id = sy-repid.
*&---------------------------------------------------------------------*
START-OF-SELECTION.
SELECT ebeln
ebelp
matnr
werks
menge
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekpo.
*&---------------------------------------------------------------------*
* FIELD CATALOG
*&---------------------------------------------------------------------*
wa_field-fieldname = 'EBELN'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 10.
wa_field-seltext_l = 'PO #'.
APPEND wa_field TO it_field.
CLEAR wa_field.
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'.
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'.
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-outputlen = 17.
* wa_field-edit = 'X'.
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.
wa_sort-fieldname = 'EBELN'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = check.
wa_sort-subtot = check.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
*&---------------------------------------------------------------------*
* DISPLAY RECORDS IN ALV GRID
*&---------------------------------------------------------------------*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = rep_id
it_fieldcat = it_field
it_sort = it_sort
TABLES
t_outtab = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
ENDIF.
Kind Regards,
Faisal
2009 Jan 27 1:51 PM
Hi,
You can use class cl_salv_table to display the ALV. Refer to SALV Demo programs. eg. SALV_DEMO_TABLE_*
Regards,
Kritesh Shah
2009 Jan 27 1:51 PM
Hi,
Use this link, simple steps to learn to display data in ALV Grid.
Hope this solves your problem.
Thanks & Regards,
Tarun Gambhir
2009 Jan 27 1:53 PM
Hi,
Declare itab for Field catalog and then for this all itab out put fields should be populated in itab of Filed catalog.
then call FM REUSE_ALV_LIST_DISPLAY
Regards,
Sunil
2009 Jan 27 1:54 PM
Hi,
Try to run the following code you will find the Ans.
*&---------------------------------------------------------------------*
TABLES : ekpo.
*&---------------------------------------------------------------------*
TYPE-POOLS : slis.
*&---------------------------------------------------------------------*
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.
*&---------------------------------------------------------------------*
*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.
*&---------------------------------------------------------------------*
INITIALIZATION.
check = 'X'.
rep_id = sy-repid.
*&---------------------------------------------------------------------*
START-OF-SELECTION.
SELECT ebeln
ebelp
matnr
werks
menge
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekpo.
*&---------------------------------------------------------------------*
* FIELD CATALOG
*&---------------------------------------------------------------------*
wa_field-fieldname = 'EBELN'.
wa_field-tabname = 'IT_TAB'.
wa_field-outputlen = 10.
wa_field-seltext_l = 'PO #'.
APPEND wa_field TO it_field.
CLEAR wa_field.
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'.
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'.
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-outputlen = 17.
* wa_field-edit = 'X'.
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.
wa_sort-fieldname = 'EBELN'.
wa_sort-tabname = 'IT_EKPO'.
wa_sort-up = check.
wa_sort-subtot = check.
APPEND wa_sort TO it_sort.
CLEAR wa_sort.
*&---------------------------------------------------------------------*
* DISPLAY RECORDS IN ALV GRID
*&---------------------------------------------------------------------*
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = rep_id
it_fieldcat = it_field
it_sort = it_sort
TABLES
t_outtab = it_ekpo
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
ENDIF.
Kind Regards,
Faisal
2009 Jan 27 2:13 PM
Hi,
Refer this link, which gives various way can be done with ALV along with demo programs.
You can display your data whichever way you required.
www . saptechnical. com/ Tutorials/ ALV/ ALVMainPage.htm
Edited by: ABAPer on Jan 27, 2009 3:13 PM
Edited by: ABAPer on Jan 27, 2009 3:14 PM
Edited by: ABAPer on Jan 27, 2009 3:14 PM