Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

regarding alv field catalog!

Former Member
0 Kudos

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.!!

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

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

4 REPLIES 4

former_member189059
Active Contributor
0 Kudos

Hello Padmashree,

Use the function module 'REUSE_ALV_FIELDCATALOG_MERGE'

former_member189059
Active Contributor
0 Kudos

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.

gopi_narendra
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.