2007 Sep 11 4:03 AM
hi. iam new to ALV. my query is,
iam building the fieldcatalog manualy by populating the internal table fields individually and then appending the rows. This method is most time consuming.
Can anyone suggest alternate method with an example? points will be rewarded.!!
2007 Sep 11 4:24 AM
Check this simple code, just execute in your system
TYPE-POOLS: slis.
DATA : BEGIN OF xmara,
matnr LIKE makt-matnr,
spras LIKE makt-spras,
maktx LIKE makt-maktx,
END OF xmara.
DATA: imara LIKE STANDARD TABLE OF xmara WITH HEADER LINE.
DATA: fieldcat TYPE slis_t_fieldcat_alv.
DATA: repid TYPE syrepid.
repid = sy-repid.
SELECT matnr spras maktx
FROM makt
INTO TABLE imara
UP TO 100 ROWS
WHERE spras = sy-langu.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = repid
i_internal_tabname = 'XMARA'
i_inclname = repid
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcat
TABLES
t_outtab = imara.
Regards
Gopi
2007 Sep 11 4:14 AM
Hello Padmashree,
Use the function module 'REUSE_ALV_FIELDCATALOG_MERGE'
2007 Sep 11 4:22 AM
Also try this function - GET_COMPONENT_LIST
data: begin of myitab occurs 0,
number type i,
name(30),
end of myitab.
data: int_tabname(40).
int_tabname = 'MYITAB'.
data : irstrucinfo like rstrucinfo occurs 0 with header line.
call function 'GET_COMPONENT_LIST'
exporting
program = sy-repid
fieldname = int_tabname
tables
components = irstrucinfo.
2007 Sep 11 4:24 AM
Check this simple code, just execute in your system
TYPE-POOLS: slis.
DATA : BEGIN OF xmara,
matnr LIKE makt-matnr,
spras LIKE makt-spras,
maktx LIKE makt-maktx,
END OF xmara.
DATA: imara LIKE STANDARD TABLE OF xmara WITH HEADER LINE.
DATA: fieldcat TYPE slis_t_fieldcat_alv.
DATA: repid TYPE syrepid.
repid = sy-repid.
SELECT matnr spras maktx
FROM makt
INTO TABLE imara
UP TO 100 ROWS
WHERE spras = sy-langu.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = repid
i_internal_tabname = 'XMARA'
i_inclname = repid
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcat
TABLES
t_outtab = imara.
Regards
Gopi
2007 Sep 11 4:26 AM
Hi Padamshree,
you can use MACRO to build field catalog.
like i used here for building and
then call FM "'REUSE_ALV_GRID_DISPLAY' for ALV grid.
DEFINE m_fieldcat.
add 1 to ls_fieldcat-col_pos.
ls_fieldcat-fieldname = &1.
ls_fieldcat-ref_tabname = 'BSIK'.
ls_fieldcat-do_sum = &2.
ls_fieldcat-cfieldname = &3.
append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
ls_sort-subtot = &2.
append ls_sort to lt_sort.
END-OF-DEFINITION.
DATA:
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv,
lt_sort TYPE slis_t_sortinfo_alv,
ls_sort TYPE slis_sortinfo_alv,
ls_layout TYPE slis_layout_alv.
m_fieldcat 'BUKRS' '' ''.
m_fieldcat 'LIFNR' '' ''.
m_fieldcat 'GJAHR' '' ''.
m_fieldcat 'BELNR' '' ''.
m_fieldcat 'HKONT' '' ''.
m_fieldcat 'WRBTR' '' ''.
m_fieldcat 'WAERS' '' ''.
m_fieldcat 'SHKZG' '' ''.
m_sort 'BUKRS' 'X'.
m_sort 'LIFNR' 'X'.
m_sort 'GJAHR' ''.
m_sort 'BELNR' ''.
m_sort 'BUDAT' ''.
ls_layout-cell_merge = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = ITAB1.
ENDFORM. " DISPLAY_DATA
Regards,
Sachin.