2

PBO 中的以下代码无法完全隐藏该列。

LOOP AT SCREEN.

    IF SCREEN-NAME EQ 'GT_SO-POSNR'
      SCREEN-INPUT = 0.
      SCREEN-ACTIVE = 0.
      SCREEN-INVISIBLE = 1.
      MODIFY SCREEN.
    ENDIF.
ENDLOOP.

但上面是禁用列,而不是隐藏它。任何帮助如何隐藏列?

4

4 回答 4

2

我们在我们的项目中遇到了同样的问题,我们想出了如何去做。

请参见下面的示例:

PROCESS BEFORE OUTPUT.
MODULE STATUS.
LOOP WITH CONTROL TABCTRL.
  MODULE MODIFY_100.
ENDLOOP.


MODULE MODIFY_100 OUTPUT.
  DATA wa_tabctrl TYPE cxtab_column .

* loop at the table control
  LOOP AT TABCTRL-COLS INTO WA_TABCTRL.
    IF WA_TABCTRL-NAME =  'POSNR'.  
*     once you get to the desired screen, flag the INVISIBLE field for the table control, not the SCREEN table.             
      WA_TABCTRL-INVISIBLE =  'X'. 
*     Modify the table for table control
      MODIFY TABCTRL-COLS FROM WA_TABCTRL.
     ENDIF.
  ENDLOOP.

ENDMODULE.
于 2014-09-12T10:55:37.373 回答
2

在语句定义的结构中INVISIBLE使用表的字段。此处记录了整个结构。您的系统中应该有一个示例程序,可以让您修改表格控件的属性并在您这样做时检查结果。COLSCONTROLSRSDEMO02

于 2013-06-28T06:10:07.197 回答
1

Check the way you are trying to hide the particular column. Whenever you have a Table control on the screen there is CXTAB structure that is created against it. So disabling a field is not as simple as writing the name of the Internal table followed by the name of the column.

Your code should be something like this

PROCESS BEFORE OUTPUT.
MODULE STATUS.
LOOP WITH CONTROL TABCTRL.
  MODULE MODIFY_100.
ENDLOOP.


MODULE MODIFY_100 OUTPUT.
  DATA wa_tabctrl TYPE cxtab_column .

  LOOP AT TABCTRL-COLS INTO WA_TABCTRL.
    IF WA_TABCTRL-NAME =  'POSNR'.                    
      WA_TABCTRL-SCREEN-INVISIBLE =  '1'. 
      MODIFY TABCTRL-COLS FROM WA_TABCTRL.
    ENDIF.
  ENDLOOP.

ENDMODULE.
于 2013-12-10T09:42:45.380 回答
0

不必遍历表格控件内容来分别隐藏每一行的列,因为列定义是表格视图的中心。

一个更清洁、更高效的解决方案可能如下所示:

*********************************
* PBO include
*********************************
PROCESS BEFORE OUTPUT.
  MODULE hide_column_0100.

*********************************
MODULE hide_column_0100 OUTPUT.
  PERFORM hide_column.
ENDMODULE.

*********************************
* form include
*********************************
FORM hide_column.
  FIELD-SYMBOL <col> TYPE cxtab_column.
  LOOP AT table_control_0100-cols ASSIGNING <col>.
    IF <col>-screen-name = 'HIDE'.
      <col>-invisible = 1.
    ENDIF.
  ENDLOOP.
ENDFORM.

最好将代码放入自己的子例程(FORM)中,以避免不必要的全局变量(如 LOOP 的工作区)。人们经常忘记 MODULE 代码属于全局范围。

于 2020-07-21T11:31:25.397 回答