Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

REUSE_ALV_HIERSEQ_LIST_DISPLAY with dynamic table

hi guys.

in a custom report, I'm using with success a ALV GRID with dynamic table (a mix with defined structure and value from customizing table), like this:

FORM build_dyn_itab.

DATA: new_table TYPE REF TO data,

new_line TYPE REF TO data,

wa_fldcat TYPE lvc_s_fcat,

wa_alv_fldcat TYPE slis_fieldcat_alv,

w_pos TYPE int4.

CLEAR: it_fldcat, it_alv_fldcat.

*----


  • field for row select:

*----


w_pos = 1.

CLEAR wa_alv_fldcat.

wa_alv_fldcat-edit = 'X'.

wa_alv_fldcat-input = 'X'.

wa_alv_fldcat-fieldname = 'CHK'.

wa_alv_fldcat-checkbox = 'X'.

wa_alv_fldcat-datatype = 'CHAR'.

wa_alv_fldcat-intlen = 1.

wa_alv_fldcat-outputlen = 1.

wa_alv_fldcat-col_pos = w_pos.

wa_alv_fldcat-seltext_l = 'Sel'.

wa_alv_fldcat-seltext_m = 'Sel'.

wa_alv_fldcat-seltext_s = 'Sel'.

APPEND wa_alv_fldcat TO it_alv_fldcat .

*----


  • base data from structure ZTOA_PLAN_GRID

*----


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_structure_name = 'ZTOA_PLAN_GRID'

CHANGING

  • ct_fieldcat = it_fldcat.

ct_fieldcat = it_alv_fldcat.

LOOP AT it_alv_fldcat INTO wa_alv_fldcat.

CLEAR wa_fldcat.

MOVE-CORRESPONDING wa_alv_fldcat TO wa_fldcat.

APPEND wa_fldcat TO it_fldcat .

w_pos = wa_alv_fldcat-col_pos.

ENDLOOP.

*----


  • dynamic data:

*----


LOOP AT it_stati.

w_pos = w_pos + 1.

CLEAR wa_fldcat.

wa_fldcat-fieldname = it_stati-dscbr.

wa_fldcat-datatype = 'SCAL-WEEK'.

wa_fldcat-intlen = 7.

wa_fldcat-col_pos = w_pos.

APPEND wa_fldcat TO it_fldcat .

CLEAR wa_alv_fldcat.

wa_alv_fldcat-fieldname = it_stati-dscbr.

wa_alv_fldcat-datatype = 'SCAL-WEEK'.

wa_alv_fldcat-intlen = 7.

wa_alv_fldcat-outputlen = 7.

wa_alv_fldcat-col_pos = w_pos.

wa_alv_fldcat-seltext_s = it_stati-dscbr.

wa_alv_fldcat-seltext_m = it_stati-dscbr.

wa_alv_fldcat-seltext_l = it_stati-descr.

APPEND wa_alv_fldcat TO it_alv_fldcat .

ENDLOOP.

*Create dynamic internal table and assign to FS

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat

IMPORTING

ep_table = new_table.

ASSIGN new_table->* TO <dyn_table>.

*Create dynamic work area and assign to FS

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

ENDFORM. "build_dyn_itab

************************************************************************

*CALL_ALV

************************************************************************

FORM call_alv.

CLEAR wa_layout.

wa_layout-edit = 'X'.

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

*Call ABAP List Viewer (ALV)

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

it_fieldcat = it_alv_fldcat

i_callback_program = sy-repid

i_callback_user_command = 'USER_COMMAND_ALV'

i_callback_pf_status_set = 'ZTOA_PLAN_STATUS'

is_layout = wa_layout

TABLES

t_outtab = <dyn_table>.

ENDFORM. "call_alv

************************************************

NOW, i want use 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' but i have difficult to understand which is table name for dynamic table ??!?

call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

exporting

i_tabname_header = ?????? <-here i want <dyn_table>

i_tabname_item = 'ITAB_DETT' <-here i have no dubt

it_fieldcat = it_alv_fldcat[]

is_layout = wa_layout

is_keyinfo = keyinfo

tables

t_outtab_header = <dyn_table>

t_outtab_item = itab_dett

exceptions

program_error = 1

others = 2.

TNX

Tags:
replied

the table names can be what you want, provided that it corresponds to TABNAME field in field catalog

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question