ABAP中的Table Control程式設計 2

2021-06-08 22:10:27 字數 1549 閱讀 4484

上篇講了table control的基本功能,現在繼續討論它在其他方面的一些設定。

4,滾動到某行某列

如果我們希望,螢幕顯示後展示在使用者面前的最上端或者左端是表內容中的某行某列,則應該修改變數top_line和left_col的值。一般可在pbo的tc_0100_change_tc_attr裡設定:

tc_0100-top_line = 3.

tc_0100-left_col = 3.

後面left_col語句起作用的前提是,內錶的字段較多,導致表控制項寬度不夠,確有左右滾動的必要。

5,獲取滑鼠所在位置

這裡要用get cursor語句,比如

data: l_line type i,

l_field type screen-name.

get cursor field l_field line l_line.

這樣就取得了滑鼠在內表的所在行以及欄位名。不過要注意的是,如果希望對映到itab,那可別忘了top_line。正確讀取滑鼠所在條目對應於內錶哪行資料的語句是:

get cursor line l_line.

l_line = l_line + tc_0100-top_line - 1.

read table itab into wa index l_line.

與此類似,希望滑鼠定位於內錶中某單元格的語句是set cursor field l_field line l_line.

6,設定固定列,設定行選擇

有時我們希望table control的左邊幾列(一般是關鍵字段),它們在螢幕上是固定的,可以方便使用者的閱讀。要怎麼設定呢?首先我們肯定會想到欄位的屬性中去找,可惜沒找到。

其實這是table control本身的乙個屬性,我們只能定義最左邊的某些列不可滾動。在screen layout中,雙擊table control的右上角,彈出「表控制」屬性,即可設定:

這裡也可以看到我們對錶控制項的行選擇進行了設定,允許多重選擇,同時選中與否的資訊將更新到wa的mark欄位,mark一般定義成c(1)。

7,如何隱藏某列

隱藏螢幕字段,我們首先想到的肯定是loop at screen,設定active或invisible的字段值。可惜測試後,發現行不通。正確的做法是,通過程式設計修改tabctrl-cols下的某欄位可見長度。

data: l_hide type c,

ls_col like line of tc_0100-cols.

loop at tc_0100-cols into ls_col where screen-name = 'wa-field2'.

if l_hide is initial.

ls_col-vislength = 6.

else.

ls_col-vislength = 0.

endif.

modify tc_0100-cols from ls_col.

endloop.

ABAP 中的巨集

report zcp saptest2 data result type i,int1 type i value 1,int2 type i value 2.define operation.result 1 2 3.output 1 2 3 result.end of definition.def...

ABAP程式中的事件

事件流 6個 initialization 初始化 at selection screen 螢幕跳出前 start of selection 取資料 end of selection 展示資料 top of page 普通報表輸出頁頭 end of page 普通報表輸出頁尾 1.load of p...

ABAP中Collect的用法

簡單來說 collect在非數值字段相同的情況下,起到了數值字段彙總作用。語法 collect w table into i table 舉個簡單的栗子 如下 report ztest no standard page heading.types begin of ty test,id 3 type...