首页 > 其他分享 >DEMO: ALV显示明细

DEMO: ALV显示明细

时间:2022-10-14 20:03:29浏览次数:43  
标签:fcat fieldcat DEMO detail 明细 lt ls ALV DATA

本来需求是ALV双击某个字段的时候,弹出一个新ALV显示对应的明细,

但是明细字段太多了,弹出来以后也挺难看的。

就想起来SE11进去,查看数据

DEMO: ALV显示明细_sed

点明细的时候

DEMO: ALV显示明细_字段_02

于是就debug了下这个按钮

DEMO: ALV显示明细_数据_03

DEMO: ALV显示明细_数据_04

大概扫了一下上下文,也就几行代码比较重要,copy下改改,然后写了个简单demo


REPORT ZLM_ALV_DETAIL .
DATA:ls_spfli TYPE spfli.

DATA:ct_fieldcat TYPE slis_t_fieldcat_alv.
DATA:cs_fieldcat LIKE LINE OF ct_fieldcat.
DATA:lt_fieldcat TYPE lvc_t_fcat.
DATA:is_layout TYPE lvc_s_layo.
DATA:lt_fcat TYPE lvc_t_fcat.
DATA:ls_fcat LIKE LINE OF lt_fcat.
DATA:lt_detail_tab TYPE lvc_t_deta,
ls_detail_tab TYPE lvc_s_deta.
DATA:lt_detail TYPE lvc_t_detm .
DATA:ls_detail LIKE LINE OF lt_detail .FIELD-SYMBOLS: <l_f1> TYPE any.
SELECT SINGLE * FROM spfli INTO ls_spfli.

CLEAR ls_fcat.
CLEAR lt_fcat[].
ls_fcat-fieldname = 'COLUMNTEXT'.
ls_fcat-ref_table = 'LVC_S_DETA'. "Y6DK043061
ls_fcat-key = 'X'.
ls_fcat-seltext = 'Spalte'(102).
ls_fcat-scrtext_s = 'Spalte'(102).
ls_fcat-outputlen = 30.
APPEND ls_fcat TO lt_fcat.

CLEAR ls_fcat.
ls_fcat-fieldname = 'VALUE'.
ls_fcat-ref_table = 'LVC_S_DETA'. "Y6DK043061
ls_fcat-seltext = 'Inhalt'(103).
ls_fcat-scrtext_s = 'Inhalt'(103).
ls_fcat-outputlen = 20.
APPEND ls_fcat TO lt_fcat.


CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SPFLI'
CHANGING
ct_fieldcat = ct_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.


LOOP AT ct_fieldcat INTO cs_fieldcat.
MOVE-CORRESPONDING cs_fieldcat TO ls_fcat.

ls_fcat-seltext = cs_fieldcat-seltext_l.
APPEND ls_fcat TO lt_fieldcat.
ENDLOOP.


LOOP AT lt_fieldcat INTO ls_fcat.

* CHECK ls_fcat-tech = space.
MOVE ls_fcat-seltext TO ls_detail_tab-columntext.

ASSIGN COMPONENT ls_fcat-fieldname
OF STRUCTURE ls_spfli TO <l_f1>.

MOVE <l_f1> TO ls_detail_tab-value.
APPEND ls_detail_tab TO lt_detail_tab.
ENDLOOP.

ls_detail-blockindex = 1.
ls_detail-detailtab = lt_detail_tab[].

APPEND ls_detail to lt_detail.

CALL FUNCTION 'LVC_ITEM_DETAIL'
EXPORTING
* I_TITLE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
it_fieldcatalog = lt_fcat
is_layout = is_layout
* IMPORTING
* E_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = lt_detail.


效果图:

DEMO: ALV显示明细_字段_05

觉得在ALV双击某行弹出新ALV明细的时候还算实用一些。




标签:fcat,fieldcat,DEMO,detail,明细,lt,ls,ALV,DATA
From: https://blog.51cto.com/u_15680210/5757857

相关文章