您的位置:首页 > 其它

ABAP:运行中修改Table Control控件状态

2011-02-18 18:02 567 查看
Dialog程序中,经常需要根据数据的不同,动态修改屏幕上控件的状态为只显示,隐藏,或者可编辑状态,以下为部分示例一、修改屏幕上控件状态(不包含TableControl内的子控件)对于此中情况,在Screen PBO事件下,

Manipulating individual abap dynpro table control field attributes

If you place the following ABAP into the ‘populate_screen’ PBO module (the PBO module within flow logic the table control loop) it will set the ‘EBELN’ field on the 2nd row to display only. The first bit of the code calculates which row is currently being processed, based on the current top viewable table control row. Once the desired row has been reached it performs ‘LOOP AT SCREEN’ to find the correct field and sets its attributes.

Using the example of a basic table control as your starting point please implement the following ABAP code changes:
MODULE populate_screen OUTPUT.
    DATA: ld_line TYPE i.

*   Set which line of itab is at the top of the table control
    IF sy-stepl = 1.
tc100-lines =
tc100-top_line + sy-loopc - 1.
ENDIF.

*   move fields from work area to scrren fields
MOVE-CORRESPONDING wa_ekko TO ztc_ekko.

    ld_line =  sy-stepl + tc100-top_line - 1.

*   Changes individual field attributes of table control,
*   Sets EBELN field on 3rd row of TC to not be an input field!
   LOOP AT SCREEN.
IF ld_line EQ 3.
IF screen-name EQ 'ZTC_EKKO-EBELN'.  "一般用Group1-Group4组条件进行控制,一次可以对一批控件进行状态修改
screen-input = 0.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.
ENDMODULE.                 " populate_screen  OUTPUT
二、修改Table Control内部子控件状态
controls: TC_ITEM type tableview using screen 0100.
field-symbols <FS_COLUMN> type CXTAB_COLUMN.
loop at TC_ITEM-COLS assigning <FS_COLUMN>.

if <FS_COLUMN>-SCREEN-GROUP1 = 'G01'.

<FS_COLUMN>-SCREEN-INPUT = '1'.

endif.

endloop .

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: