some definitions:
TYPE-POOLS: slis.
eg: C_PO_DATE TYPE slis_fieldname VALUE 'PO_DATE'.
DATA: WA_LAYOUT TYPE SLIS_LAYOUT_ALV
*-------------------------------------------------------------------------*
form F_CREATE_FIELD_CATALOGUE .
v_rcount = 1. " Record count in field catalogue table
REFRESH: i_fieldcat.
* Insert records in field catalogue table
PERFORM f_insert_row
USING: C_PO_DATE text-002,
C_PO_NO text-003,
......
endform. " F_CREATE_FIELD_CATALOGUE
*&---------------------------------------------------------------------*
*& Form f_insert_row
*&---------------------------------------------------------------------*
* Insert records in field catalogue table
*----------------------------------------------------------------------*
* -->fp_name Name of the field in field catalogue
* -->fp_desc Description of the field in field catalogue
*----------------------------------------------------------------------*
FORM f_insert_row USING fp_name TYPE slis_fieldname
fp_desc TYPE reptext.
DATA: wa_fieldcat TYPE slis_fieldcat_alv. " Work area for i_fieldcat
CONSTANTS : l_c_tab TYPE slis_tabname VALUE 'I_OUTDATA'.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = v_rcount. " position of the column
wa_fieldcat-fieldname = fp_name. " fieldname
wa_fieldcat-tabname = l_c_tab. " tabname
wa_fieldcat-reptext_ddic = fp_desc. " heading
* wa_fieldcat-just = 'C'.
IF fp_name = c_material.
wa_fieldcat-no_zero = c_x.
ENDIF.
APPEND wa_fieldcat TO i_fieldcat.
v_rcount = v_rcount + 1.
ENDFORM. " f_insert_row
*&---------------------------------------------------------------------*
*& Form F_DISPLAY_REPORT
*&---------------------------------------------------------------------*
* Map internal table data into ALV list
*----------------------------------------------------------------------*
* -->fp_i_sort Internal table for sorting description of report
* -->fp_fieldcat Internal table for FIELD CATALOGUE
* -->FP_I_OUTDATA Output table
* <--fp_wa_layout Work area containing report layout
*----------------------------------------------------------------------*
form F_DISPLAY_REPORT using fp_i_fieldcat TYPE slis_t_fieldcat_alv
fp_i_outdata TYPE ty_t_outdata
changing fp_wa_layout TYPE slis_layout_alv.
* Set column width inclined with the field width.
fp_wa_layout-colwidth_optimize = C_X.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
is_layout = fp_wa_layout
it_fieldcat = fp_i_fieldcat
* IT_SORT = FP_I_SORT
* I_SAVE = 'A'
* IS_VARIANT = V_VARIANT
TABLES
t_outtab = fp_i_outdata
EXCEPTIONS
program_error = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE i052. " System prevents the report to display.
ENDIF.
endform. " F_DISPLAY_REPORT
-----------------------------------------------------------------------------
阅读(500) | 评论(0) | 转发(0) |