Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Table Control: Disabling editing for a column

Former Member
0 Likes
2,361

Hi everyone. Greetings from Buenos Aires, Argentina.

First of all, I want to apologize for this question in case of it has already been made. The forum is too large to read it completely and I really need the answer, if any, to my trouble.

I have a table control inside a screen. In it's PBO, I coded a module to change the table control attributes. I declared a work area like the line of the table control's control in order to loop it. I mean this:

In the TOP of Table Control (I made it by using the wizard) I have this:

CONTROLS: TC_1 TYPE TABLE VIEW USING SCREEN dynpro_number)

And in the PBO module I have typed the following:



MODULE control_change_attrs OUTPUT.

DATA: wa_tc_1 LIKE LINE OF TC_1-COLS.

LOOP AT TC_1-COLS INTO wa_tc_1.
(...)
ENDLOOP.

ENDMODULE.

In the (...), I have put code with such a logic that, depending of the contents of certain fields in the dynpro, it will hide (or not) some columns of the Table Control. This part is made correctly.

This logic, also makes (or should make) the table control to disable the input of a column, depending wether a flag is active or not. This flag is activated in other screen's PAI, which is called depending on the contents of the sy-ucomm field of this screen (the one with the table control).

The (...) is something like this (I'll omit some parts):


IF wa_tc_1-screen-name = 'COLUMN_TO_HIDE'.
   IF gv_flag = 'X'.
      wa_tc_1-screen-input = 0.
   ENDIF.
   MODIFY TC_1-COLS FROM wa_tc_1.
ENDIF.

In a PAI module of this screen, I have coded the following:


MODULE user_command INPUT.

CASE gv_ok_code.
   WHEN 'RUN'.
      PERFORM RUN.
    WHEN ...
 ENDCASE.

END MODULE.

And in the RUN subroutine, obviusly among other things, I have this:


CALL SCREEN 0150 STARTING AT XX YY.

In a module in the PBO of the screen 0150, I clear gv_ok_code. In a PAI module, this is what I have put:


CASE gv_ok_code.
   WHEN 'ACCEPT'.
      gv_flag = 'X'.
      CLEAR gv_ok_code.
      LEAVE TO SCREEN 0.
  WHEN ...
  WHEN ...
ENDCASE

The thing is, when the contents of gv_ok_code is 'ACCEPT' and therefore the flag is activated, then the 0150 screen's PAI finishes and the previous screen's PBO is processed, I know for sure (by the mean of the debugging mode) that the table controls's atrributes are correctly modified, and the most important thing, they stay like that... But, the column desired does not gets disabled, at least not until the NEXT PBO (I mean, it gets disabled when I press the Enter key).

Why is happening this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,327

Thanks a lot for the response, Max.

I' ve been testing your answer. When I implemented the code that you suggested, after the first PAI, the table control's columns appear as I want.

The thing is, in order to test if the changes in the columns are reflected in the screen after the call of the dynpro no. 0150 (and the obvious return to the first one), I need to be able to select one or more table control's rows (since when I followed the table control wizard, I made it with selection column, and with multiple selection). But, after implementing your code, I'm not able any longer to select any rows.

I click on them, but they don't turn yellow. I commented the call of the module inside the LOOP AT itab... of the PBO and I was able to select them once again, so we're sure the problem is caused because of the call to this new module. But why?

Note: you should know, since the table control is with multilpe selection, the LOOP sentence in the PBO is like this:


LOOP AT itable
       INTO work_area
       CONTROL tc_1
       WITH CURSOR tc_1-current_line.

MODULE change_attribs.

ENDLOOP.

Does that give a hint to you?

Thanks a lot for the response, Max.

I' ve been testing your answer. When I implemented the code that you suggested, after the first PAI, the table control's columns appear as I want.

The thing is, in order to test if the changes in the columns are reflected in the screen after the call of the dynpro no. 0150 (and the obvious return to the first one), I need to be able to select one or more table control's rows (since when I followed the table control wizard, I made it with selection column, and with multiple selection). But, after implementing your code, I'm not able any longer to select any rows.

I click on them, but they don't turn yellow. I commented the call of the module inside the LOOP AT itab... of the PBO and I was able to select them once again, so we're sure the problem is caused because of the call to this new module. But why?

Note: you should know, since the table control is with multilpe selection, the LOOP sentence in the PBO is like this:


LOOP AT itable
       INTO work_area
       CONTROL tc_1
       WITH CURSOR tc_1-current_line.

MODULE change_attribs.

ENDLOOP.

Does that give a hint to you?

4 REPLIES 4
Read only

Former Member
0 Likes
1,327

Hi

U should try to change the INPUT/OUTPUT attribute directly in the LOOP of the table control by statament LOOP AT SCREEN without to change the value of table control workarea:

PROCESS PBO.
   LOOP AT ITAB WITH CONTROL TC_1....
      MODULE LOOP_SCREEN.
  ENDLOOP.

MODULE LOOP_SCREEN.
  IF gv_flag = 'X'.
    LOOP AT SCREEN.
      IF SCREEN-NAME = <......>
        SCREEN-INPUT = 0.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.
 ENDIF.
ENDMODULE.

Max

Read only

Former Member
0 Likes
1,328

Thanks a lot for the response, Max.

I' ve been testing your answer. When I implemented the code that you suggested, after the first PAI, the table control's columns appear as I want.

The thing is, in order to test if the changes in the columns are reflected in the screen after the call of the dynpro no. 0150 (and the obvious return to the first one), I need to be able to select one or more table control's rows (since when I followed the table control wizard, I made it with selection column, and with multiple selection). But, after implementing your code, I'm not able any longer to select any rows.

I click on them, but they don't turn yellow. I commented the call of the module inside the LOOP AT itab... of the PBO and I was able to select them once again, so we're sure the problem is caused because of the call to this new module. But why?

Note: you should know, since the table control is with multilpe selection, the LOOP sentence in the PBO is like this:


LOOP AT itable
       INTO work_area
       CONTROL tc_1
       WITH CURSOR tc_1-current_line.

MODULE change_attribs.

ENDLOOP.

Does that give a hint to you?

Read only

0 Likes
1,326

Hi

The pushbutton to select the row is a normal input/output field, so when u disable the row u need to indicate which fields (i.e. columns) of the row has to be disabled: I suppose u need to exclude the pushbutton.

If MARK is the name of field to select the row:

LOOP AT SCREEN.
   IF SCREEN-NAME <> 'MARK'.
      SCREEN-INPUT = 0.
      MODIFY SCREEN.
   ENDIF.
ENDLOOP.

U can also set a group ID in order to group the fields having the same attributes:

LOOP AT SCREEN.
   IF SCREEN-GROUP1 = 'AAA'.
      SCREEN-INPUT = 0.
      MODIFY SCREEN.
   ENDIF.
ENDLOOP.

Max

Read only

Former Member
0 Likes
1,326

It's worked perfect. Thanks!