Application Development 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: 

Make cells of Table control grayed out(input disabled) based on condition

former_member288488
Participant
0 Kudos

Hello Experts,

I have a requirement where the data is getting populated in table control from my custom tables.

Now in three columns of the table control if the data is coming as blank from z table then I have to show the cell as editable so that user can put the data and it can be saved back in custom table but If some data is coming from custom table and it is shown in the table control then the cell should be grayed out(Non Editable).

To achive this I'm using the Following piece of code but it is not working still.

In PBO

loop at gi_actual_tc

into gw_actual_tc

with control tc_actual

cursor tc_actual-current_line.

module tc_get_lines.

endloop.

MODULE tc_get_lines OUTPUT.

data : lv_index TYPE sy-index,

lv_index1 TYPE sy-index.

lv_index = sy-tabix.

CHECK gw_actual_tc-zlc_subcon IS NOT INITIAL.

LOOP AT SCREEN.

IF screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON'.

lv_index1 = sy-tabix.

IF lv_index = lv_index1.

screen-active = 0.

exit.

ENDIF.

  • screen-intensified = 1.

ENDIF.

MODIFY SCREEN.

ENDLOOP.

ENDMODULE.

Please let me know where I'm missing the trick here.

Thanks,

Jai

19 REPLIES 19

Former Member
0 Kudos

Hi,

I think that EXIT is not required in that query..


LOOP AT SCREEN.

IF screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON'.
lv_index1 = sy-tabix.
IF lv_index = lv_index1.
screen-active = 0.
exit.                               "comming out without modifying the screen
ENDIF.
* screen-intensified = 1.

ENDIF.
MODIFY SCREEN.
ENDLOOP.

0 Kudos

Hi ,

It can be done .

pls check

IN PBO . CALL Module "

module edit .

and in module add code accordingly .

LOOP AT SCREEN.
    IF ( screen-name = 'IT_QTY-QTY1' AND it_qty-qty1 = 0 ) OR ( screen-name = 'IT_QTY-QTY2' AND it_qty-qty2 = 0 )
      OR ( screen-name = 'IT_QTY-QTY3' AND it_qty-qty3 = 0 )  OR ( screen-name = 'IT_QTY-QTY4' AND it_qty-qty4 = 0 )
      OR ( screen-name = 'IT_QTY-QTY5' AND it_qty-qty5 = 0 )  OR  ( screen-name = 'IT_QTY-QTY6' AND it_qty-qty6 = 0 )
      OR ( screen-name = 'IT_QTY-QTY7' AND it_qty-qty7 = 0 ) OR ( screen-name = 'IT_QTY-QTY8' AND it_qty-qty8 = 0 ).

      screen-input = 1.

      MODIFY SCREEN.
    ENDIF.

  ENDLOOP.

regards

Deepak.

0 Kudos

Hi,

After Excluding the exit command also it is not working.

Thanks,

Jai

0 Kudos

Hi Jai ,

LOOP AT SCREEN.

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' and gi_actual_tc-fieldname = some value ) .

screen-input = 1.

modify screen .

endif.

endloop.

This should work for you ..

Regards

Deepak.

.

0 Kudos

Hi Deepak,

The code you have given works for the entire column but not the one cell of the table control as I need.

Thanks,

Jai

0 Kudos

hi jai ,

it should work

i am using this code in my table control program

where in this code only fields having value 0 is editable where as others are non editable .

Please check your screen-field name it should be in CAPITAL .

Regards

Deepak.

0 Kudos

Hi Deepak,

Below is the code I'm using

LOOP AT SCREEN.

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' AND

gw_actual_tc-zlc_subcon IS NOT INITIAL )

OR ( screen-name = ' GW_ACTUAL_TC-ZLC_SCWORK' AND

gw_actual_tc-zlc_scwork IS NOT INITIAL )

OR ( screen-name = 'GW_ACTUAL_TC-ZLC_VALJOB' AND

gw_actual_tc-zlc_valjob IS NOT INITIAL ) .

screen-input = 0.

MODIFY SCREEN .

ENDIF.

ENDLOOP.

here all the three columns of the three fields are getting non editable wether it has value or it does not have value.

Thanks,

Jai

0 Kudos

Think screen-input = 1 is the right bit of code. Not sure if your program is that way or you had an SDN typo

Regards

Naveen Vajja

0 Kudos

HI ,

Please tell me which fields you want to edit and which Not out of three

and also the fields type

also screen-input = 1 .

regards

Deepak.

Edited by: Deepak Dhamat on Apr 5, 2011 12:55 PM

0 Kudos

hi change your code according to Data type

LOOP AT SCREEN.

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' AND

gw_actual_tc-zlc_subcon IS INITIAL )

OR ( screen-name = ' GW_ACTUAL_TC-ZLC_SCWORK' AND

gw_actual_tc-zlc_scwork IS INITIAL )

OR ( screen-name = 'GW_ACTUAL_TC-ZLC_VALJOB' AND

gw_actual_tc-zlc_valjob IS INITIAL ) .

screen-input = 1.

MODIFY SCREEN .

ENDIF.

ENDLOOP.

Regards

Deepak.

0 Kudos

Hi,

It was a typo I Have

Screen-Input = 1 , Actually

thanks,

jai

0 Kudos

hi ,

LOOP AT SCREEN.

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' AND

gw_actual_tc-zlc_subcon IS NOT INITIAL )

OR ( screen-name = ' GW_ACTUAL_TC-ZLC_SCWORK' AND

gw_actual_tc-zlc_scwork IS NOT INITIAL )

OR ( screen-name = 'GW_ACTUAL_TC-ZLC_VALJOB' AND

gw_actual_tc-zlc_valjob IS NOT INITIAL ) .

change code to below code if it is character field

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' AND
gw_actual_tc-zlc_subcon IS  INITIAL )
OR ( screen-name = ' GW_ACTUAL_TC-ZLC_SCWORK' AND
gw_actual_tc-zlc_scwork IS  INITIAL )
OR ( screen-name = 'GW_ACTUAL_TC-ZLC_VALJOB' AND
gw_actual_tc-zlc_valjob IS  INITIAL ) .

IF field is type P or I

then

IF ( screen-name = 'GW_ACTUAL_TC-ZLC_SUBCON' AND
gw_actual_tc-zlc_subcon =0 )
OR ( screen-name = ' GW_ACTUAL_TC-ZLC_SCWORK' AND
gw_actual_tc-zlc_scwork =0 )
OR ( screen-name = 'GW_ACTUAL_TC-ZLC_VALJOB' AND
gw_actual_tc-zlc_valjob =0 ) .

screen-input = 1.

MODIFY SCREEN .

ENDIF.

ENDLOOP.

regards

Deepak.

raymond_giuseppi
Active Contributor
0 Kudos

Define fields as ready for input in screen painter, then in PBO module try something like

MODULE tc_get_lines OUTPUT.
* gw_actual_tc_lines = sy-loopc
  LOOP AT SCREEN.
    CASE screen-name.
      WHEN 'GW_ACTUAL_TC-ZLC_SUBCON'.
        IF gw_actual_tc-zlc_subcon IS INITIAL.
          screen-input = 1.
        ELSE.
          screen-input = 0.
        ENDIF.
* other fields here
    ENDCASE.
    MODIFY SCREEN.
  ENDLOOP.
ENDMODULE.

Notice that this will disable input as soon as user has input some data (and press any key) If you want to follow the rules given, you should store the database data in another internal table (read this old table before LOOP AT SCREEN) or in hidden fields of the work internal table, and use those "old" values in the check.

Regards,

Raymond

0 Kudos

Hi Raymond,

I have made my three fields input enabled in the layout of the screen as you have suggested.

The logic you have given works fine when user enters values in the second row of the cloumn for which we want the value coming in first row to be non editable and it becomes non editable as desired.

But what my requirement is if the value is coming in any of the row of the table control in these particular three cloulmns, it should become non editable as soon as we give the t-code and see the table control after giving the po no. in header field above the table control based on which this table control is popuplated actually.

Thanks,

Jai

0 Kudos

I'm not sure to understand the logic of your program. When do you fill the internal table to be displayed in the table control, before displaying it or input in an other area of the screen ?

Regards,

Raymond

0 Kudos

Hi Raymond,

I give the PO no. in one field of screen in header and based on this PO no. i populate the internal table to diaplay the line item details in Table Control.

Thanks,

Jai

Former Member
0 Kudos

Hi,

For hinding or disabling the particular row and column in table control we do like this


PROCESS BEFORE OUTPUT.

LOOP WITH CONTROL <tab>.
  MODULE  DIS_DATA.
ENDLOOP.

In program


MODULE DIS_DATA OUTPUT.
*** if cond is satisfied.......
LOOP AT SCREEN.
IF SCREEN-NAME = <fld>.
  SCREEN-INPUT = 0.
* SCREEN-ACTIVE = 0.  "if want to hide
ENDIF.
MODIFY SCREEN.
ENDLOOP.
ENDMODULE.

if still it is not working then please check the screen field name is correct or not.

Thanks,

Anmol.

0 Kudos

Hi Anmol,

I already tried this.....it makes the entire column non editable not the single cell of the table control.

Thanks,

Jai

0 Kudos

Hi Anmol,

I already tried this.....it makes the entire column non editable not the single cell of the table control.

Thanks,

Jai