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: 

How to change a TEXT FIELD to be Disabled when I select a Radio Button

SurendarT
Explorer
0 Kudos
1,757

Moderator message: Duplicate deleted in General forum

Hi Folks,

I have 2 RadioButtons in a Screen (Module Pool Program).

and 1 Text Field.

My Problem is :

When I select RadioButton 1.... the TEXT FIELD should get DISABLED.... Mode

then If I select RadioButton 2.... the TEXT FIELD should be in ENABLED....Mode

Can anyone give me a solution for this....

Edited by: Matt on Jan 22, 2009 11:49 AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
286

Hi,

Say the radiobuttons on the screen are rad1 and rad2 and the textbox is txt1. Assign a FCTcode to the radiobutton group. Now when ever you click on the radio button the PAI is called and in turn if the screen is calling itself the PBO is called. I the PBO double click on the module and write the following code

loop at screen.

if rad1 = 'X'.

if screen-name = 'TXT1'.

screen-input = 0.

else.

screen-input = 1.

endif.

modify screen.

elseif rad2 = 'X'.

if screen-name = 'TXT1'.

screen-input = 0.

else,

screen-input = 1.

endif.

modify screen.

endif.

endloop.

Hope this helps.

Regards,

Sachin.

7 REPLIES 7

JozsefSzikszai
Active Contributor
0 Kudos
286
PARAMETERS : rb1 RADIOBUTTON GROUP 1 DEFAULT 'X' USER-COMMAND uc01,
                         rb2 RADIOBUTTON GROUP 1.

PARAMETERS text TYPE ... MODIF ID 001.

AT SELECTION-SCREEN.

LOOP AT screen.
CHECK screen-group1 EQ '001'.
CASE 'X'.
WHEN rb1.
screen-input = '1'.
WHEN rb2.
screen-input = '0'.
ENDCASE.
MODIFY screen.
ENDLOOP.

Former Member
0 Kudos
286

Hi,

Check out this link.

[Setting attributes dynamically|http://help.sap.com/saphelp_nw04/helpdata/EN/9f/dbacf735c111d1829f0000e829fbfe/frameset.htm]

Hope this helps.

Regards,

Deepthi.

Former Member
0 Kudos
286

Hi,

Here is an example,

*----------------------------------------------------------------------*
*                     SELECTION SCREEN                                 *
*----------------------------------------------------------------------*
*-- Input Details - Block
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_cust FOR t606z-kunnr.
PARAMETERS     : p_bukrs  TYPE rf02d-bukrs,
                 p_lictyp TYPE t606-geart,
                 p_legreg TYPE t606g-gegru.
SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
PARAMETERS : p_rb1 RADIOBUTTON GROUP grp1
                   MODIF ID id1 DEFAULT 'X'
                   USER-COMMAND sel ,
             p_dpath TYPE rlgrap-filename MODIF ID id2,
             p_rb2 RADIOBUTTON GROUP grp1
                   MODIF ID id1.



SELECTION-SCREEN : BEGIN OF LINE.
SELECTION-SCREEN : POSITION 4.
PARAMETERS : p_dea RADIOBUTTON GROUP rb1
                   MODIF ID gr1 DEFAULT 'X'
                   USER-COMMAND dir.
SELECTION-SCREEN : COMMENT  6(37)  text-t04 MODIF ID gr1.
SELECTION-SCREEN: COMMENT   45(9) text-t06  MODIF ID gr1.
SELECTION-SCREEN: POSITION 60.
PARAMETERS : p_file1  TYPE rlgrap-filename
                      MODIF ID gr1.
SELECTION-SCREEN : END OF LINE.

SELECTION-SCREEN :BEGIN OF LINE.
SELECTION-SCREEN : POSITION 4.
PARAMETERS : p_state  RADIOBUTTON GROUP rb1
                      MODIF ID gr1.
SELECTION-SCREEN: COMMENT  6(37)  text-t05  MODIF ID gr1.
SELECTION-SCREEN: COMMENT  45(9)  text-t06  MODIF ID gr1.
SELECTION-SCREEN: POSITION 60.
PARAMETERS : p_file2  TYPE rlgrap-filename
                      MODIF ID gr1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN :BEGIN OF LINE.
SELECTION-SCREEN : POSITION 4.
PARAMETERS :p_cntrl  RADIOBUTTON GROUP rb1
                     MODIF ID gr1.
SELECTION-SCREEN: COMMENT  6(37)  text-t09   MODIF ID gr1.
SELECTION-SCREEN: COMMENT  45(9)  text-t06   MODIF ID gr1.
SELECTION-SCREEN: POSITION 60.
PARAMETERS : p_file3 TYPE rlgrap-filename
                     MODIF ID gr1.
SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK b2.


*----------------------------------------------------------------------*
*                          AT SELECTION SCREEN                         *
*----------------------------------------------------------------------*

AT SELECTION-SCREEN OUTPUT.

  IF p_rb1 EQ 'X'.
    CLEAR: p_file1,p_file2, p_file3.
    LOOP AT SCREEN.
      IF screen-group1 = 'GR1'.
        screen-active = 0.
        screen-input = 0.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.

  ELSEIF p_rb2 EQ 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'ID2'.
        screen-active = 0.
        screen-input = 0.
*      ENDIF.
      MODIFY SCREEN.
      ELSEIF screen-group1 = 'GR1' .
        screen-active = 1.
        screen-input = 1.
        MODIFY SCREEN.
        IF p_dea = 'X'  AND
          ( screen-name = 'P_FILE2' OR screen-name = 'P_FILE3' OR
          screen-name = 'P_DPATH').
          CLEAR: p_file2 ,p_file3.
          screen-input = 0.
          MODIFY SCREEN.

        ELSEIF  p_state = 'X' AND
          ( screen-name = 'P_FILE1' OR screen-name = 'P_FILE3' OR
          screen-name = 'P_DPATH').
          CLEAR: p_file1 ,p_file3.
          screen-input = 0.
          MODIFY SCREEN.

        ELSEIF p_cntrl = 'X' AND
          ( screen-name = 'P_FILE1' OR screen-name = 'P_FILE2' OR
          screen-name = 'P_DPATH').
          CLEAR: p_file1 ,p_file2.
          screen-input = 0.
          MODIFY SCREEN.
        ENDIF.
      ENDIF.
    ENDLOOP.

  ENDIF.

Regards,

Amit.

Edited by: Julius Bussche on Jan 22, 2009 2:27 PM

Code tags added...

Former Member
0 Kudos
286

Surendar

All these solutions are for a report program. For you Module Pool, you need to set a Function Code on the Radio Button so that when the user "clicks" on either one, PAI, then PBO are called.

In your PAI, you don't have to do anything within your CASE for the OK_CODE/SY-UCOMM. Simply let it pass through. Then in your PBO, set the input = 0 or 1 for the text field you want to enable/disable in the LOOP AT SCREEN loop.

Something like this.


LOOP AT SCREEN.
  IF screen-name EQ 'YOUR_TEXT_FIELD'.
    CASE 'X'.
      WHEN rb1.
        screen-input = '0'.
      WHEN rb2.
        screen-input = '1'.
    ENDCASE.
    MODIFY SCREEN.
  ENDIF.
ENDLOOP.

Edited by: Paul Chapman on Jan 26, 2009 8:43 AM

Former Member
0 Kudos
287

Hi,

Say the radiobuttons on the screen are rad1 and rad2 and the textbox is txt1. Assign a FCTcode to the radiobutton group. Now when ever you click on the radio button the PAI is called and in turn if the screen is calling itself the PBO is called. I the PBO double click on the module and write the following code

loop at screen.

if rad1 = 'X'.

if screen-name = 'TXT1'.

screen-input = 0.

else.

screen-input = 1.

endif.

modify screen.

elseif rad2 = 'X'.

if screen-name = 'TXT1'.

screen-input = 0.

else,

screen-input = 1.

endif.

modify screen.

endif.

endloop.

Hope this helps.

Regards,

Sachin.

I355602
Product and Topic Expert
Product and Topic Expert
0 Kudos
286

Hi Surendar,

Take the function code for both the radiobuttons say 'rb1' and 'rb2' as 'CS' and function type as 'S'.

and take the group1 for textbox as 'ABC'.

Now use code in PAI, its working:-


module modify_screen.
  if rb1 = 'X'.
    if screen-group1 = 'ABC'
      loop at screen.
        screen-active = 0.
        screen-input = 0. "disable field for input
      endloop.
      modify screen.
    endif.
  elseif rb2 = 'X'.
    if screen-group1 = 'ABC'
      loop at screen.
        screen-active = 1.
        screen-input = 1. "enable field for input
      endloop.
      modify screen.
    endif.
  endif.
endmodule.

Hope this solve your problem.

Thanks & Regards,

Tarun Gambhir

Former Member
0 Kudos
286

Hi

Assign function codes to your radiobuttons say R1 and R2.

In your PAI.

MODULE user_command_0100 INPUT.

case ok_code.

when 'R1'.

flag = 1 .

when 'R2'.

flag = 2.

In your PBO.

MODULE status_0100 OUTPUT.

*Set pf-status and titlebar

Loop At Screen.

IF screen-group1 = 'TXT'. " TXT is modification group for your Text field

IF flag = 1.

screen-input = '0'.

ELSEIF flag = 2.

screen-input = '1'.

ENDIF.

MODIFY SCREEN.

ENDIF.

Endloop.

Hope this helps

Regards,

Jayanthi.K