動態隱藏ALV的行和列
阿新 • • 發佈:2019-01-09
本例和行列例程轉換不同,內表結構是固定的,僅僅是通過ALV的fieldcat和Filter來隱藏/顯示ALV的行和列
列:
FORM changefield .
LOOP AT gt_fieldcat INTO gs_fieldcat .
gs_fieldcat-no_out = ''.
IF gs_fieldcat-fieldname = 'KOSTL' .
gs_fieldcat-no_out = 'X'.
ENDIF.
MODIFY gt_fieldcat FROM gs_fieldcat .
ENDLOOP.
CALL METHOD go_grid->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = gt_fieldcat.
CALL METHOD go_grid->refresh_table_display .
ENDFORM. " changefield 這樣處理後,可以在ChangeLayout裡面更改列是否顯示,如果不想在Changelayout裡面看到隱藏的列,可以設定gs_fieldcat-tech = 'X'. 行:
LOOP AT gt_fieldcat INTO gs_fieldcat .
gs_fieldcat-no_out = ''.
IF gs_fieldcat-fieldname = 'KOSTL' .
gs_fieldcat-no_out = 'X'.
ENDIF.
MODIFY gt_fieldcat FROM gs_fieldcat .
ENDLOOP.
CALL METHOD go_grid->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = gt_fieldcat.
CALL METHOD go_grid->refresh_table_display .
ENDFORM. " changefield 這樣處理後,可以在ChangeLayout裡面更改列是否顯示,如果不想在Changelayout裡面看到隱藏的列,可以設定gs_fieldcat-tech = 'X'. 行: