以下是纯顾问群~
QQ群 :SAP干货铺,  群号:775662808
所有群管理严格,严格禁止一切外来链接、招聘、广告等垃圾信息!

如果您觉得这篇干货文章有用,请帮忙转载、分享给更多人,谢谢~


直接上干货了:

ALV DMEO 04:REUSE_ALV_GRID_DISPLAY 固定列_左对齐

ALV DMEO 04:REUSE_ALV_GRID_DISPLAY 固定列_字段_02


如果字段比较多,当左右拖动滚动条的时候,某列一直显示,跟着滚动。


demo代码;

DATA:GT_DATA                TYPE TABLE OF  SPFLI.

DATA:GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:GT_FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV .

DATA:LV_ALV_STRUCTURE TYPE DD02L-TABNAME VALUE 'ZLMS_ALV'.


START-OF-SELECTION.


SELECT * FROM SPFLI INTO TABLE GT_DATA.


CLEAR GT_FIELDCATALOG[].

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = LV_ALV_STRUCTURE
CHANGING
CT_FIELDCAT = GT_FIELDCATALOG
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.

ENDIF.

FIELD-SYMBOLS <LS_FILEDCAT> LIKE LINE OF GT_FIELDCATALOG.

LOOP AT GT_FIELDCATALOG ASSIGNING <LS_FILEDCAT>.
<LS_FILEDCAT>-DDICTXT ='L'.

IF <LS_FILEDCAT>-FIELDNAME = 'CITYFROM' .
<LS_FILEDCAT>-FIX_COLUMN = 'X'.
<LS_FILEDCAT>-KEY = 'X'.
ENDIF.
ENDLOOP.
*

GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GS_LAYOUT-ZEBRA = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_GRID_TITLE = 'SAP干货铺测试'
IS_LAYOUT = GS_LAYOUT
IT_FIELDCAT = GT_FIELDCATALOG
* I_STRUCTURE_NAME = 'SPFLI'
TABLES
T_OUTTAB = GT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.

IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

其他具体参数,自己查看下就行,比如左对齐,右对齐,合计,key颜色,长短文本,金额数量 参考字段参考表等等等的,自己去一个一个参数验证即可。

ALV DMEO 04:REUSE_ALV_GRID_DISPLAY 固定列_字段_03