本文主要是介绍alv简单例子,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
注意点:1,定义一个表头结构,类型为SLIS_T_FIELDCAT_ALV
2,需要赋值的参数,col_ps,fieldname seltext_s(列位置,字段名称,字段文本)
REPORT ztest.
TYPE-POOLS: slis.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_outtab LIKE TABLE OF lfa1 WITH HEADER LINE.
INITIALIZATION.
PERFORM fieldcat_init USING gt_fieldcat[].
START-OF-SELECTION.
PERFORM select_data TABLES gt_outtab.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = gt_fieldcat[]
TABLES
t_outtab = gt_outtab.
*&---------------------------------------------------------------------*
*& Form fieldcat_init
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_FIELDCAT text
*----------------------------------------------------------------------*
FORM fieldcat_init USING rt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv,
pos TYPE i VALUE 1.
CLEAR ls_fieldcat.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'LIFNR'.
ls_fieldcat-seltext_s = '供应商代码'.
APPEND ls_fieldcat TO rt_fieldcat.
CLEAR ls_fieldcat.
pos = pos + 1.
ls_fieldcat-col_pos = pos.
ls_fieldcat-fieldname = 'NAME1'.
ls_fieldcat-seltext_s = '供应商名称'.
APPEND ls_fieldcat TO rt_fieldcat.
ENDFORM. "fieldcat_init
*&---------------------------------------------------------------------*
*& Form select_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_OUTTAB text
*----------------------------------------------------------------------*
FORM select_data TABLES rt_outtab LIKE gt_outtab[].
SELECT *
INTO TABLE gt_outtab
UP TO 10 ROWS
FROM lfa1 .
ENDFORM. " select_data
这篇关于alv简单例子的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!