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

input field in Table Control

Former Member
0 Likes
2,653

Hi Experts,

i have a table control, i want to toggle one of the row in a particular columns in my table control from input to output and vice versa. is it possible?

Thank you.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,530

Hi John,

i've done that already but nothing happened. maybe because i am trying to alter a Table Control and not one of the screen elements.

thanks

14 REPLIES 14
Read only

Former Member
0 Likes
1,530

Hi Jesus,

Yes you can, in PBO loop over the SCREEN table and switch the relevant field from in- to output.

Regards,

John.

Read only

Former Member
Read only

Former Member
0 Likes
1,530

Hi

Ye it is!

U have to change the attribute INPUT into loop of table control of PBO and drive the process by a pushbutton (in the user-commad of PAI)

PROCESS PBO

  LOOP AT
     MODULE CHANGE_SCREEN.
  ENDLOOP.

PROCESS PAI.
  
  MODULE USER_COMMAND.


  MODULE CHANGE_SCREEN.
     LOOP AT SCREEN.
         IF SCREEN-NAME = <Colunm name>.
            SCREEN-INPUT = _INPUT.
            MODIFY SCREEN.
         ENDIF.
     ENDLOOP.
  ENDMODULE.

  MODULE USER_COMMAND.
   
      CASE OK_CODE.
          WHEN 'MODI'. _INPUT = 1.
          WHEN 'DISP'.  _INPUT = 0.
      ENDCASE.
  ENDMODULE.

Max

Read only

Former Member
0 Likes
1,531

Hi John,

i've done that already but nothing happened. maybe because i am trying to alter a Table Control and not one of the screen elements.

thanks

Read only

0 Likes
1,530

Can you show your coding?

Regards,

Ravi

Read only

0 Likes
1,530

Hi

See my answer, because u don't need to alter the Table Control, but only the INPUT attribute of the field.

U should change the attribute of table control only if you need to hide a colunm.

Max

Read only

0 Likes
1,530

Hi Max,

i've tried it but it doesnt work.

thanks anyway. 😃

Read only

0 Likes
1,530

Hi

Give me your code...because it's impossible, I've used that trick many many times and it always worked fine:

PROCESS PBO
 
  LOOP AT
     MODULE CHANGE_SCREEN.
  ENDLOOP.
 
PROCESS PAI.
  LOOP AT

  ENDLOOP
  
  MODULE USER_COMMAND.
 
 
  MODULE CHANGE_SCREEN.
     CHECK ITAB-MARK = 'X'.
     LOOP AT SCREEN.
         IF SCREEN-NAME = 'IT_TC200-MENGE'.
            SCREEN-INPUT = _INPUT.
            MODIFY SCREEN.
         ENDIF.
     ENDLOOP.
  ENDMODULE.
 
  MODULE USER_COMMAND.   
      CASE OK_CODE.
          WHEN 'F_EDIT'.
           IF _INPUT = 1. 
             _INPUT = 0.
           ELSE
             _INPUT = 1.
           ENDIF.
      ENDCASE.
  ENDMODULE.

Max

Read only

0 Likes
1,530

Really?

wow that's estranged, anyway here's my code.

MODULE init_screen_200 OUTPUT.

LOOP AT SCREEN.

IF screen-name EQ 'IT_TC200-MENGE'.

screen-input = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDMODULE.

where 'IT_TC200-MENGE' is the field in my TC that i want to change.

thanks a lot.

Read only

0 Likes
1,530

ooops,

i mean strange.

Read only

0 Likes
1,530

Hi

In this way you're always setting as editable the colunm IT_TC200-MENGE for every row, because you're only transfering 1 to SCREEN-INPUT.

The first thing you should do is to check the INPUT attribute by screen painter: it doesn't has to be ONLY OUTPUT: it can't change this value at run time, set it as INPUT/OUTPUT.

So you can use a module like this

MODULE CHANGE_SCREEN.

LOOP AT SCREEN.

IF SCREEN-NAME = 'IT_TC200-MENGE'.

SCREEN-INPUT = _INPUT.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDMODULE.

The variable _INPUT is setted in the USER-COMMAD:

MODULE USER_COMMAND.

CASE OK_CODE.

WHEN 'F_EDIT'.

IF _INPUT = 1.

_INPUT = 0.

ELSE.

_INPUT = 1.

ENDIF.

ENDCASE.

ENDMODULE.

If you need to change only a certain row, that depends on how you manange the SELECTION, if you have a MARK colunm:

MODULE CHANGE_SCREEN.

CHECK IT_TC200-MARK = 'X'.

LOOP AT SCREEN.

IF SCREEN-NAME = 'IT_TC200-MENGE'.

SCREEN-INPUT = _INPUT.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDMODULE.

Else you can use a module to get the line with the cursor:

PROCESS PAI.

LOOP

MODULE GET_CURSOR.

ENDLOOP.

MODULE GET_CURSOR.

GET CURSOR LINE VN_LINE

ENDMODULE.

and so

MODULE CHANGE_SCREEN.

CHECK SY-STEPL = VN_LINE.

LOOP AT SCREEN.

IF SCREEN-NAME = 'IT_TC200-MENGE'.

SCREEN-INPUT = _INPUT.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDMODULE

Max

Read only

0 Likes
1,530

got it max,

i just missed this one.

LOOP AT

MODULE CHANGE_SCREEN.

ENDLOOP.

thanks a lot max, it is really a big help.

Read only

Former Member
0 Likes
1,530

Ravi,

here's my code.

CONTROLS tc200 TYPE TABLEVIEW USING SCREEN 200.

DATA: cols LIKE LINE OF tc200-cols,

v_input TYPE i.

WHEN 'F_EDIT'.

IF v_input EQ 0.

v_input = 1.

ELSE.

v_input = 0.

ENDIF.

LOOP AT tc200-cols INTO cols.

IF cols-screen-name EQ 'IT_TC200-MENGE'.

cols-screen-input = v_input.

MODIFY tc200-cols FROM cols INDEX sy-tabix.

ENDIF.

ENDLOOP.

this one works, but all of the rows on the column 'IT_TC200-MENGE' is changed

from output to input. what i want is to change just one row or whatever the user selected in my Table Control.

Thanks Ravi.

Read only

0 Likes
1,530

Hi Jesus

See my answer, there's a possible solution.

Just as I said you don't need to change the table control attribute, but the field attribute just as I explained before.

PROCESS PBO
LOOP AT

  MODULE CHANGE_SCREEN.

ENDLOOP.

  MODULE CHANGE_SCREEN.
* If it needs to change only the selected rows
     IF ITAB-MARK = 'X'.
       LOOP AT SCREEN.
           SCREEN-INPUT = _INPUT.
           MODIFY SCREEN.
       ENDLOOP.
     ENDIF.
  ENDMODULE.

If you change the attributes of tc you'll change them for all rows.

Max